Create Agent
Creates an agent. The request body contains the model, system prompt, toolkit, skill, and multi-agent collaboration configurations. The response returns the complete Agent object, with an initial version of 1.
Prerequisites
Endpoint and authentication configured. For details, see Overview and authentication.
Endpoint
/agentsRequest body
namestringRequiredAgent name, used for identification in the console and list views
descriptionstringOptionalDescription of the agent's purpose
modelobjectRequiredModel configuration. Contains the following sub-fields:
model properties
idstringModel ID, e.g. qwen3.7-max
enable_thinkingbooleanWhether to enable thinking mode
max_tokensintegerMaximum generation length
temperaturenumberTemperature that controls randomness
thinking_budgetintegerThinking budget length
systemstringOptionalSystem prompt that defines the role and behavioral constraints
toolsarray<object>OptionalToolkit list, grouped by type. Each item contains the following fields:
type:builtin_toolkit/mcp_toolkitdefault_config: includesenabledandpermission_policyconfigs: per-tool config that overridesdefault_config; each tool config supportsparamsfor tool-specific parametersmcp_server_name: MCP types also require it
At most one builtin_toolkit is allowed; multiple mcp_toolkit items are allowed
tools properties
typestringbuiltin_toolkit or mcp_toolkit
default_configobjectDefault tool config with enabled and permission_policy
configsarray<object>Per-tool config that overrides default_config; supports params
mcp_server_namestringRequired for MCP tools
mcp_serversarray<object>OptionalMCP Server reference list. Each item contains the following fields:
type:official/customername: can be found as the service ID on the service card in the MCP Management menu of the Bailian console (custom services are named at creation time)
mcp_servers properties
typestringofficial or customer
namestringMCP server name
skillsarray<object>OptionalMounted skill list. Each item contains the following fields:
type:official/customerskill_id: can be viewed on the skill detail page in the Skill Management menu of the Bailian consoleversion: must be locked to a concrete version number
skills properties
typestringofficial or customer
skill_idstringSkill ID
versionstringMust be a concrete version number
multiagentobjectOptionalMulti-agent collaboration configuration. Omitting or leaving empty indicates a single agent. Once configured, the agent acts as a coordinator that orchestrates fleet members. Contains type (currently only coordinator), agents (1-20 fleet entries; pass an empty array to clear the fleet), workflows (inline script configuration), and reuse_workflows (published workflow reuse configuration). Each agents entry contains type (agent (references another Agent) / self (the coordinator itself, at most one in the fleet)), id (required when type=agent, max 64 chars; forbidden when type=self), and version (optional when type=agent, >=1, defaults to latest if not specified; forbidden when type=self). workflows contains type (enabled / disabled; required when the object is provided), inline_agents (type is enabled / disabled, default disabled), and predefined_agents (fixed agent versions, up to 20 items; id values in the list must be unique). reuse_workflows contains type (default disabled) and workflows (fixed published version references, up to 20 items; the same Workflow ID cannot be repeated; each item contains id and version). For details, see Dynamic Workflow.
multiagent properties
typestringCurrently only coordinator
agentsarray<object>Fleet entries (1-20); each contains type, id, and version
metadataobjectOptionalCustom business key-value pairs; does not affect model behavior
permission_policy.type takes the following values:
always_allow: execute directlyalways_ask: pause and wait for manual confirmation before each call
Tool approval is only supported on the main agent, not sub-agents. The approval policy for MCP tools is configured in the default_config / configs of the tools[].type=mcp_toolkit item, not in mcp_servers[].
configs[].params is at the same level as name, enabled, and permission_policy, and passes tool-specific parameters.
When enabling search_knowledgebases:
- You must provide a non-empty
params.knowledge_application_id - Its value is the knowledge retrieval service ID, not an individual knowledge base ID
- If it is missing or empty, agent creation returns 400
An agent can have at most one instance of this tool.
Request example
curl -X POST "$AGENTSTUDIO_URL/agents" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "data-analyst",
"description": "Data analysis assistant",
"model": {"id": "qwen3.7-max"},
"system": "You are a data analysis expert who uses pandas to process CSV files.",
"tools": [
{
"type": "builtin_toolkit",
"default_config": {"enabled": true, "permission_policy": {"type": "always_allow"}},
"configs": [
{"name": "bash", "enabled": true, "permission_policy": {"type": "always_ask"}},
{"name": "read", "enabled": true},
{"name": "write", "enabled": true}
]
}
],
"mcp_servers": [],
"skills": [
{"type": "customer", "skill_id": "skill_xxx", "version": "1.0"}
],
"multiagent": {
"type": "coordinator",
"agents": [
{"type": "self"},
{"type": "agent", "id": "agent_researcher", "version": 3}
]
},
"metadata": {"team": "data"}
}'
agent = client.agents.create(
name="data-analyst",
model="qwen3.8-max",
description="Data analysis assistant",
system_prompt="You are a data analysis expert who uses pandas to process CSV files.",
tools=[
{"type": "builtin_toolkit",
"default_config": {"enabled": True},
"configs": [
{"name": "bash", "enabled": True},
{"name": "read", "enabled": True},
{"name": "write", "enabled": True},
]}
],
mcp_servers=[],
skills=[{"type": "customer", "skill_id": "skill_xxx", "version": "1.0"}],
metadata={"team": "data"},
)
print(agent.id) # "agent_xxx"
print(agent.version) # 1
Agent agent = client.agents().create(AgentCreateParam.builder()
.name("data-analyst")
.model("qwen3.7-max")
.description("Data analysis assistant")
.instructions("You are a data analysis expert who uses pandas to process CSV files.")
.metadata(Map.of("team", "data"))
.build());
System.out.println(agent.getId()); // "agent_xxx"
System.out.println(agent.getVersion()); // 1
Dynamic Workflow Configuration Example
Enable inline scripts and published workflow reuse in multiagent. workflows and reuse_workflows can be enabled independently; you can omit workflows when only reusing published workflows. To restrict inline scripts to fixed agents, set workflows.inline_agents.type to disabled to prevent inline scripts from using the session default agent, then add the available agent id and version to predefined_agents. To allow the default agent, keep inline_agents.type=enabled; predefined_agents can be empty. Replace reuse_workflows.workflows[].id with a bound workflow ID; do not run the example value as is. The snippet above shows only the workflows and reuse_workflows fields; an empty agents array means no formation is configured.
{
"multiagent": {
"type": "coordinator",
"agents": [],
"workflows": {
"type": "enabled",
"inline_agents": {"type": "enabled"},
"predefined_agents": []
},
"reuse_workflows": {
"type": "enabled",
"workflows": [
{"id": "wf_01M7RMD9PRNVEPY2QKW1MA36TE", "version": 1}
]
}
}
}
Knowledge Retrieval Configuration Example
Enable search_knowledgebases in builtin_toolkit.configs[] and specify the knowledge retrieval service (ID format aid-...) through params.knowledge_application_id:
{
"tools": [
{
"type": "builtin_toolkit",
"configs": [
{
"name": "search_knowledgebases",
"enabled": true,
"params": {
"knowledge_application_id": "aid-xxxxxxxx"
}
}
]
}
]
}
- When
search_knowledgebasesis not configured, retrieval is disabled. - The model invokes it as needed and combines multi-turn conversations to generate the search query.
- Create a knowledge retrieval service before use; see Knowledge Retrieval.
- When updating an existing agent, retain the other tools that are still in use. For usage details, see Agent Tool Configuration.
Response fields
idstringAgent ID, format: agent_<ULID>
typestringAlways agent
versionintCurrent version number, auto-incremented on each update; locked when a session is created
namestringAgent name
descriptionstringDescription
systemstringSystem prompt
modelobjectModel configuration, including id and other model parameters
model properties
idstringModel ID, e.g. qwen3.7-max
enable_thinkingbooleanWhether to enable thinking mode
max_tokensintegerMaximum generation length
temperaturenumberTemperature that controls randomness
thinking_budgetintegerThinking budget length
toolsarray<object>Toolkit list, grouped by type
tools properties
typestringbuiltin_toolkit or mcp_toolkit
default_configobjectDefault tool config with enabled and permission_policy
configsarray<object>Per-tool config that overrides default_config; supports params
mcp_server_namestringRequired for MCP tools
mcp_serversarray<object>MCP server reference list
mcp_servers properties
typestringofficial or customer
namestringMCP server name
skillsarray<object>Mounted skill list
skills properties
typestringofficial or customer
skill_idstringSkill ID
versionstringMust be a concrete version number
multiagentobjectMulti-agent configuration
multiagent properties
typestringCurrently only coordinator
agentsarray<object>Fleet entries (1-20); each contains type, id, and version
metadataobjectCustom business key-value pairs that do not affect model behavior.
archived_atstring / nullArchive timestamp; null if not archived
created_atstringCreation time (ISO 8601)
updated_atstringLast update time (ISO 8601)
workspace_idstringWorkspace ID
request_idstringUnique identifier for this request; include when troubleshooting
Response example
{
"type": "agent",
"id": "agent_xxx",
"name": "data-analyst",
"model": {
"id": "qwen3.8-max",
"temperature": null,
"max_tokens": null,
"enable_thinking": null,
"thinking_budget": null
},
"system": "You are a data analysis expert.",
"description": "Data analysis assistant",
"tools": null,
"mcp_servers": null,
"skills": null,
"multiagent": {
"type": "coordinator",
"agents": [
{"type": "self"},
{"type": "agent", "id": "agent_researcher", "version": 3}
],
"workflows": {
"type": "enabled",
"inline_agents": {"type": "enabled"},
"predefined_agents": []
},
"reuse_workflows": {
"type": "enabled",
"workflows": [
{"id": "wf_01M7RMD9PRNVEPY2QKW1MA36TE", "version": 1}
]
}
},
"metadata": null,
"version": 1,
"created_at": "2026-05-28T16:23:11.456+08:00",
"updated_at": "2026-05-28T16:30:00.000+08:00",
"archived_at": null,
"workspace_id": "ws_xxx",
"request_id": "req_xxx"
}