Create Agent

Updated at:

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

POST/agents

Request body

namestringRequired

Agent name, used for identification in the console and list views

descriptionstringOptional

Description of the agent's purpose

modelobjectRequired

Model configuration. Contains the following sub-fields:

model properties

idstring

Model ID, e.g. qwen3.7-max

enable_thinkingboolean

Whether to enable thinking mode

max_tokensinteger

Maximum generation length

temperaturenumber

Temperature that controls randomness

thinking_budgetinteger

Thinking budget length

systemstringOptional

System prompt that defines the role and behavioral constraints

toolsarray<object>Optional

Toolkit list, grouped by type. Each item contains the following fields:

  • type: builtin_toolkit / mcp_toolkit
  • default_config: includes enabled and permission_policy
  • configs: per-tool config that overrides default_config; each tool config supports params for tool-specific parameters
  • mcp_server_name: MCP types also require it

At most one builtin_toolkit is allowed; multiple mcp_toolkit items are allowed

tools properties

typestring

builtin_toolkit or mcp_toolkit

default_configobject

Default tool config with enabled and permission_policy

configsarray<object>

Per-tool config that overrides default_config; supports params

mcp_server_namestring

Required for MCP tools

mcp_serversarray<object>Optional

MCP Server reference list. Each item contains the following fields:

  • type: official / customer
  • name: 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

typestring

official or customer

namestring

MCP server name

skillsarray<object>Optional

Mounted skill list. Each item contains the following fields:

  • type: official / customer
  • skill_id: can be viewed on the skill detail page in the Skill Management menu of the Bailian console
  • version: must be locked to a concrete version number

skills properties

typestring

official or customer

skill_idstring

Skill ID

versionstring

Must be a concrete version number

multiagentobjectOptional

Multi-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

typestring

Currently only coordinator

agentsarray<object>

Fleet entries (1-20); each contains type, id, and version

metadataobjectOptional

Custom business key-value pairs; does not affect model behavior

permission_policy.type takes the following values:

  • always_allow: execute directly
  • always_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_knowledgebases is 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

idstring

Agent ID, format: agent_<ULID>

typestring

Always agent

versionint

Current version number, auto-incremented on each update; locked when a session is created

namestring

Agent name

descriptionstring

Description

systemstring

System prompt

modelobject

Model configuration, including id and other model parameters

model properties

idstring

Model ID, e.g. qwen3.7-max

enable_thinkingboolean

Whether to enable thinking mode

max_tokensinteger

Maximum generation length

temperaturenumber

Temperature that controls randomness

thinking_budgetinteger

Thinking budget length

toolsarray<object>

Toolkit list, grouped by type

tools properties

typestring

builtin_toolkit or mcp_toolkit

default_configobject

Default tool config with enabled and permission_policy

configsarray<object>

Per-tool config that overrides default_config; supports params

mcp_server_namestring

Required for MCP tools

mcp_serversarray<object>

MCP server reference list

mcp_servers properties

typestring

official or customer

namestring

MCP server name

skillsarray<object>

Mounted skill list

skills properties

typestring

official or customer

skill_idstring

Skill ID

versionstring

Must be a concrete version number

multiagentobject

Multi-agent configuration

multiagent properties

typestring

Currently only coordinator

agentsarray<object>

Fleet entries (1-20); each contains type, id, and version

metadataobject

Custom business key-value pairs that do not affect model behavior.

archived_atstring / null

Archive timestamp; null if not archived

created_atstring

Creation time (ISO 8601)

updated_atstring

Last update time (ISO 8601)

workspace_idstring

Workspace ID

request_idstring

Unique 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"
}