Create agent

Updated at:

Create a reusable agent configuration that stores the model, instructions, tools, and multi-agent settings.

Endpoint

Returns 201 and the complete agent object. Creation only saves the configuration. It does not start a session, model, or MCP server. Submitting the same request body again creates a new resource.

POST/agents

Request body

modelstringRequired

Model ID. It must match a model available in the current workspace; otherwise the API returns 404 model_not_found. For available models, see Available models.

namestring / nullOptional

Display name, up to 128 characters.

instructionsstring / nullOptional

Custom instructions appended to the agent's default instructions, up to 1,048,576 characters.

metadataobject / nullOptional

Metadata, string key-value pairs. Recommended limits are 16 items, key up to 64 characters, and value up to 512 characters. All values must be strings.

reasoningobject / nullOptional

Reasoning settings, containing the following fields.

Properties

effortstring / nullOptional

Reasoning effort: none, minimal, low, medium, high, xhigh, or max.

summarystring / nullOptional

Reasoning summary: concise, detailed, or auto.

textobject / nullOptional

Text output settings, containing the following fields.

Properties

format

typestringConditional

Output format type, fixed as text.

verbositystring / nullOptional

Output verbosity, low, medium, or high. Session execution currently accepts only medium.

toolsarray / nullOptional

Tool configuration. Each tool must provide a type. The current supported types are function, mcp, and web_search. Creation only saves the configuration; it does not mean the tool can execute.

Properties

function

namestringRequired

Function name

descriptionstring / nullRequired

Function description, can be null

parametersobjectRequired

Function input JSON Schema; must declare type: object

mcp

server_labelstringRequired

MCP server label

transportobjectRequired

Transport configuration; see the branches below

Properties

typestringRequired

Transport type, http or stdio

server_urlstring / nullConditional

MCP server URL

headersobject<string,string> / nullOptional

Additional HTTP headers; do not put secrets here

commandstringConditional

Command to start the server

cwdstringConditional

Working directory; must be an absolute path whose segments are not . or ..

argsarray<string> / nullOptional

Command arguments

allowed_toolsarray<string> / nullOptional

Allowed tool names; null means no filter

requiredbooleanOptional

Whether MCP initialization must succeed

connection_originstring / nullOptional

Connection origin, service or environment, defaults to service

multi_agentobject / nullOptional

Subagent configuration, containing the following fields.

Properties

enabledbooleanRequired

Whether subagent tools are enabled; required when the parent object is present.

max_concurrent_subagentsinteger / nullOptional

Concurrent subagent limit. Execution currently supports 1..32, default 6.

Unknown top-level fields do not produce an error and may be filtered out and recorded; do not assume a field is applied just because the request succeeds.

Request example

curl -sS -X POST "$BASE_URL/agents" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "OpenAI-Beta: agents=v1" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-max",
    "name": "support-agent",
    "instructions": "Answer briefly and include steps when necessary.",
    "metadata": {"team": "support"}
  }'
agent = client.beta.agents.create(
    model="qwen3.8-max",
    name="support-agent",
    instructions="Answer briefly and include steps when necessary.",
    metadata={"team": "support"},
)
print(agent.id)

Response fields

idstring

Agent ID. Treat it as an opaque string.

objectstring

Agent object type, fixed as agent.

created_atinteger

Creation time as a Unix timestamp in seconds.

updated_atinteger

Last modification time as a Unix timestamp in seconds, not a version number.

namestring / null

Display name.

metadataobject / null

Metadata, saved string key-value pairs.

modelstring

Saved model ID.

reasoningobject / null

Reasoning configuration. Either subfield can be null.

Properties

effortstring / null

Reasoning effort: none, minimal, low, medium, high, xhigh, max

summarystring / null

Reasoning summary: concise, detailed, auto

textobject / null

Text output configuration.

Properties

formatobject

Output format.

Properties

typestring / null

Output format type, fixed as text

verbositystring / null

Output verbosity, low, medium, high

instructionsstring / null

Saved custom instructions.

toolsarray / null

Saved tool configuration. Each branch returns only its own fields.

Properties

functionobject

Function tool configuration; returns name, description, and parameters

mcpobject

MCP tool configuration; returns server_label, transport, allowed_tools, required, and connection_origin; transport is http or stdio

web_searchobject

Web search tool configuration; returns type and the saved configuration

multi_agentobject / null

Subagent configuration.

Properties

enabledboolean

Whether subagent tools are enabled

max_concurrent_subagentsinteger / null

Maximum number of concurrent subagents; no default is applied

Response example

{
  "id": "agent_xxx",
  "object": "agent",
  "created_at": 1794117521,
  "updated_at": 1794117521,
  "name": "support-agent",
  "metadata": {"team": "support"},
  "model": "qwen3.8-max",
  "reasoning": null,
  "text": null,
  "instructions": "Answer briefly and include steps when necessary.",
  "tools": null,
  "multi_agent": null
}

Available models

model supports the following models:

BrandModel IDCapabilities
Qwenqwen4-maxReasoning, visual understanding, text generation
Qwenqwen3.8-maxReasoning, visual understanding, text generation
Qwenqwen3.7-maxReasoning, text generation
Qwenqwen3.7-plusReasoning, visual understanding, text generation
Qwenqwen3.6-plusReasoning, visual understanding, text generation
DeepSeekdeepseek-v4-proReasoning, text generation
Zhipu AIglm-5.3Reasoning, text generation
Zhipu AIglm-5.2Reasoning, text generation
Moonshot AIkimi-k3Reasoning, visual understanding, text generation

Models with visual understanding can process images passed when creating a session. See Create session.

NoteThe model list is continuously updated. The dropdown list shown when creating an agent in the console is authoritative.

Error codes

Business errors return an error object with type, code, message, and param. Common errors:

HTTP statusError type / codeSolution
400invalid_request_error / invalid_request_errorProvide model as described, fix field types and enums, satisfy tool cross-field constraints, and send valid JSON
400invalid_request_error / string_above_max_lengthShorten instructions to 1,048,576 characters or fewer
401authentication_error / invalid_api_keySend a valid Authorization: Bearer $DASHSCOPE_API_KEY header
404invalid_request_error / model_not_foundUse a model ID that is available in the current workspace
500server_error / server_errorRetry later. If it keeps failing, submit a ticket with x-request-id

Authentication, workspace routing, and rate-limit errors can be returned directly by the gateway with a different structure.