Skip to main content

Create agent

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

Endpoint

POST /agents 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.

Request body

FieldRequiredTypeDescription
modelYesstringModel 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.
nameNostring / nullDisplay name, up to 128 characters.
instructionsNostring / nullCustom instructions appended to the agent's default instructions, up to 1,048,576 characters.
metadataNoobject / nullMetadata, 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.
reasoningNoobject / nullReasoning settings, containing the following fields.
reasoning.effortNostring / nullReasoning effort: none, minimal, low, medium, high, xhigh, or max.
reasoning.summaryNostring / nullReasoning summary: concise, detailed, or auto.
textNoobject / nullText output settings, containing the following fields.
text.format.typeConditionalstringOutput format type, fixed as text.
text.verbosityNostring / nullOutput verbosity, low, medium, or high. Session execution currently accepts only medium.
toolsNoarray / nullTool 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.
tools[].function.nameYesstringFunction name
tools[].function.descriptionYesstring / nullFunction description, can be null
tools[].function.parametersYesobjectFunction input JSON Schema; must declare type: object
tools[].mcp.server_labelYesstringMCP server label
tools[].mcp.transportYesobjectTransport configuration; see the branches below
tools[].mcp.allowed_toolsNoarray<string> / nullAllowed tool names; null means no filter
tools[].mcp.requiredNobooleanWhether MCP initialization must succeed
tools[].mcp.connection_originNostring / nullConnection origin, service or environment, defaults to service
tools[].mcp.transport.typeYesstringTransport type, http or stdio
tools[].mcp.transport.server_urlConditionalstring / nullMCP server URL
tools[].mcp.transport.headersNoobject<string,string> / nullAdditional HTTP headers; do not put secrets here
tools[].mcp.transport.commandConditionalstringCommand to start the server
tools[].mcp.transport.cwdConditionalstringWorking directory; must be an absolute path whose segments are not . or ..
tools[].mcp.transport.argsNoarray<string> / nullCommand arguments
tools[].web_search.typeYesstringTool type, fixed as web_search
multi_agentNoobject / nullSubagent configuration, containing the following fields.
multi_agent.enabledYesbooleanWhether subagent tools are enabled; required when the parent object is present.
multi_agent.max_concurrent_subagentsNointeger / nullConcurrent 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"}
  }'

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
}

Response fields

FieldTypeDescription
idstringAgent ID. Treat it as an opaque string.
objectstringAgent object type, fixed as agent.
created_atintegerCreation time as a Unix timestamp in seconds.
updated_atintegerLast modification time as a Unix timestamp in seconds, not a version number.
namestring / nullDisplay name.
metadataobject / nullMetadata, saved string key-value pairs.
modelstringSaved model ID.
reasoningobject / nullReasoning configuration. Either subfield can be null.
reasoning.effortstring / nullReasoning effort: none, minimal, low, medium, high, xhigh, max
reasoning.summarystring / nullReasoning summary: concise, detailed, auto
textobject / nullText output configuration.
text.formatobjectOutput format.
text.format.typestring / nullOutput format type, fixed as text
text.verbositystring / nullOutput verbosity, low, medium, high
instructionsstring / nullSaved custom instructions.
toolsarray / nullSaved tool configuration. Each branch returns only its own fields.
tools[].functionobjectFunction tool configuration; returns name, description, and parameters
tools[].mcpobjectMCP tool configuration; returns server_label, transport, allowed_tools, required, and connection_origin; transport is http or stdio
tools[].web_searchobjectWeb search tool configuration; returns type and the saved configuration
multi_agentobject / nullSubagent configuration.
multi_agent.enabledbooleanWhether subagent tools are enabled
multi_agent.max_concurrent_subagentsinteger / nullMaximum number of concurrent subagents; no default is applied

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.
The 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.