Create agent
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.
/agentsRequest body
modelstringRequiredModel 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 / nullOptionalDisplay name, up to 128 characters.
instructionsstring / nullOptionalCustom instructions appended to the agent's default instructions, up to 1,048,576 characters.
metadataobject / nullOptionalMetadata, 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 / nullOptionalReasoning settings, containing the following fields.
Properties
effortstring / nullOptionalReasoning effort: none, minimal, low, medium, high, xhigh, or max.
summarystring / nullOptionalReasoning summary: concise, detailed, or auto.
textobject / nullOptionalText output settings, containing the following fields.
Properties
format
typestringConditionalOutput format type, fixed as text.
verbositystring / nullOptionalOutput verbosity, low, medium, or high. Session execution currently accepts only medium.
toolsarray / nullOptionalTool 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
namestringRequiredFunction name
descriptionstring / nullRequiredFunction description, can be null
parametersobjectRequiredFunction input JSON Schema; must declare type: object
mcp
server_labelstringRequiredMCP server label
transportobjectRequiredTransport configuration; see the branches below
Properties
typestringRequiredTransport type, http or stdio
server_urlstring / nullConditionalMCP server URL
headersobject<string,string> / nullOptionalAdditional HTTP headers; do not put secrets here
commandstringConditionalCommand to start the server
cwdstringConditionalWorking directory; must be an absolute path whose segments are not . or ..
argsarray<string> / nullOptionalCommand arguments
allowed_toolsarray<string> / nullOptionalAllowed tool names; null means no filter
requiredbooleanOptionalWhether MCP initialization must succeed
connection_originstring / nullOptionalConnection origin, service or environment, defaults to service
web_search
typestringRequiredTool type, fixed as web_search
multi_agentobject / nullOptionalSubagent configuration, containing the following fields.
Properties
enabledbooleanRequiredWhether subagent tools are enabled; required when the parent object is present.
max_concurrent_subagentsinteger / nullOptionalConcurrent 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
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.
Properties
effortstring / nullReasoning effort: none, minimal, low, medium, high, xhigh, max
summarystring / nullReasoning summary: concise, detailed, auto
textobject / nullText output configuration.
Properties
formatobjectOutput format.
Properties
typestring / nullOutput format type, fixed as text
verbositystring / nullOutput verbosity, low, medium, high
instructionsstring / nullSaved custom instructions.
toolsarray / nullSaved tool configuration. Each branch returns only its own fields.
Properties
functionobjectFunction tool configuration; returns name, description, and parameters
mcpobjectMCP tool configuration; returns server_label, transport, allowed_tools, required, and connection_origin; transport is http or stdio
web_searchobjectWeb search tool configuration; returns type and the saved configuration
multi_agentobject / nullSubagent configuration.
Properties
enabledbooleanWhether subagent tools are enabled
max_concurrent_subagentsinteger / nullMaximum 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:
| Brand | Model ID | Capabilities |
|---|---|---|
| Qwen | qwen4-max | Reasoning, visual understanding, text generation |
| Qwen | qwen3.8-max | Reasoning, visual understanding, text generation |
| Qwen | qwen3.7-max | Reasoning, text generation |
| Qwen | qwen3.7-plus | Reasoning, visual understanding, text generation |
| Qwen | qwen3.6-plus | Reasoning, visual understanding, text generation |
| DeepSeek | deepseek-v4-pro | Reasoning, text generation |
| Zhipu AI | glm-5.3 | Reasoning, text generation |
| Zhipu AI | glm-5.2 | Reasoning, text generation |
| Moonshot AI | kimi-k3 | Reasoning, 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 status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error | Provide model as described, fix field types and enums, satisfy tool cross-field constraints, and send valid JSON |
400 | invalid_request_error / string_above_max_length | Shorten instructions to 1,048,576 characters or fewer |
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
404 | invalid_request_error / model_not_found | Use a model ID that is available in the current workspace |
500 | server_error / server_error | Retry 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.