根据 Agent ID 返回完整的 Agent 配置。
接口
成功返回 200 和完整 Agent 对象。
GET
/agents/{agent_id}路径参数
agent_idstring必填Agent ID,按不透明字符串使用
本接口没有 Query 参数。agent_id 格式错误、不存在、已删除或属于其他工作空间时返回 404。
请求示例
curl -sS "$BASE_URL/agents/agent_xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1"
agent = client.beta.agents.retrieve("agent_xxx")
print(agent.id, agent.model)
响应字段
未设置的可选字段可能返回 null。
idstringAgent ID,按不透明字符串使用
objectstringAgent 对象类型,固定为 agent
created_atinteger创建时间的 Unix 秒时间戳
updated_atinteger最近修改时间的 Unix 秒时间戳,不是版本号
namestring / null展示名称
metadataobject / null元数据,保存的字符串键值对
modelstring保存的模型 ID
reasoningobject / null推理配置。两项均可为 null。
effortstring / null推理强度:none、minimal、low、medium、high、xhigh、max
summarystring / null推理摘要:concise、detailed、auto
textobject / null文本输出配置。
formatobject输出格式。
typestring / null输出格式类型,固定为 text
verbositystring / null输出详细程度,low、medium、high
instructionsstring / null保存的自定义指令
toolsarray / null保存的工具配置;每个分支只返回本分支字段
functionobjectFunction 工具配置,返回 name、description、parameters
mcpobjectMCP 工具配置,返回 server_label、transport、allowed_tools、required、connection_origin;transport 为 http 或 stdio
web_searchobjectWeb Search 工具配置,返回 type 和已保存的配置
multi_agentobject / null子 Agent 配置。
enabledboolean是否启用子 Agent 工具
max_concurrent_subagentsinteger / null最大并发子 Agent 数;不补默认值
响应示例
{
"id": "agent_xxx",
"object": "agent",
"created_at": 1794117521,
"updated_at": 1794117521,
"name": "quickstart-agent",
"metadata": null,
"model": "qwen3.8-max",
"reasoning": null,
"text": null,
"instructions": "回答简洁,只输出必要信息。",
"tools": null,
"multi_agent": null
}
错误码
业务错误返回 error 对象,包含 type、code、message 和 param。常见错误如下:
| HTTP 状态码 | 错误类型 / 错误码 | 解决方案 |
|---|---|---|
401 | authentication_error / invalid_api_key | 在请求头携带有效的 Authorization: Bearer $DASHSCOPE_API_KEY |
404 | not_found_error / not_found_error | 使用当前工作空间中存在且未删除的 Agent ID |
500 | server_error / server_error | 稍后重试;持续失败时提交工单并提供 x-request-id |
该文章对您有帮助吗?