Skip to main content

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

POST /agents

Request body

name string (必选)Agent name, used for identification in the console and list viewsdescription string (可选)Description of the agent's purposemodel object (必选)Model configuration. Required sub-field id (model ID, e.g. qwen3.7-max); optional sub-fields enable_thinking (bool, whether to enable thinking mode), max_tokens (int32, maximum generation length), temperature (double, sampling temperature that controls randomness), and thinking_budget (int32, thinking budget length)system string (可选)System prompt that defines the role and behavioral constraintstools array<object> (可选)Toolkit list, grouped by type. Each item contains type (builtin_toolkit / mcp_toolkit), default_config (includes enabled and permission_policy), and configs (per-tool config that overrides default_config; each tool config supports params for tool-specific parameters). MCP types also require mcp_server_name. At most one builtin_toolkit is allowed; multiple mcp_toolkit items are allowedmcp_servers array<object> (可选)MCP Server reference list. Each item contains type (official / customer) and name. The 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)skills array<object> (可选)Mounted skill list. Each item contains type (official / customer), skill_id, and version (must be locked to a concrete version number). The skill_id can be viewed on the skill detail page in the Skill Management menu of the Bailian consolemultiagent object (可选)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) and agents (1-20 fleet entries; pass an empty array to clear the fleet). Each 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)metadata object (可选)Custom business key-value pairs; does not affect model behaviorpermission_policy.type takes 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, whose 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"}
  }'

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

id stringAgent ID, format: agent_&lt;ULID&gt;type stringAlways agentversion intCurrent version number, auto-incremented on each update; locked when a session is createdname / description / system stringSame as request bodymodel / tools / mcp_servers / skills / multiagent / metadata object / arraySame as request bodyarchived_at string / nullArchive timestamp; null if not archivedcreated_at / updated_at stringCreation / last update time, ISO 8601workspace_id stringWorkspace IDrequest_id stringUnique identifier for this request; include when troubleshooting

Response example

{
  "id": "agent_xxx",
  "type": "agent",
  "version": 1,
  "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": [],
  "mcp_servers": [],
  "skills": [],
  "multiagent": {
    "type": "coordinator",
    "agents": [
      {"type": "self"},
      {"type": "agent", "id": "agent_researcher", "version": 3}
    ]
  },
  "metadata": {"team": "data"},
  "created_at": "2026-05-28T16:23:11.456+08:00",
  "updated_at": "2026-05-28T16:23:11.456+08:00",
  "archived_at": null,
  "workspace_id": "ws_xxx",
  "request_id": "req_xxx"
}