创建智能体
通过 OMA API 创建智能体。
curl --request POST \
--url 'http://localhost:38080/v1/agents?beta=true' \
--header 'Content-Type: application/json' \
--header 'anthropic-version: 2023-06-01' \
--header 'anthropic-beta: managed-agents-2026-04-01' \
--header 'X-Api-Key: sk-ant-local-default' \
--data '{
"model": "claude-sonnet-4-6",
"name": "我的第一个智能体",
"description": "通用入门智能体。",
"metadata": {
"foo": "bar"
},
"system": "你是一个通用智能体,可以研究问题、编写代码、运行命令并使用已连接的工具,端到端地完成用户任务。",
"tools": [
{
"type": "agent_toolset_20260401"
}
]
}'import requests
url = "http://localhost:38080/v1/agents"
payload = {
"model": "claude-sonnet-4-6",
"name": "我的第一个智能体",
"description": "通用入门智能体。"
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'claude-sonnet-4-6', name: '我的第一个智能体', description: '通用入门智能体。'})
};
fetch('http://localhost:38080/v1/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:38080/v1/agents"
payload := strings.NewReader("{\n \"model\": \"claude-sonnet-4-6\",\n \"name\": \"我的第一个智能体\",\n \"description\": \"通用入门智能体。\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "agent_011CZkYpogX7uDKUyvBTophP",
"archived_at": null,
"created_at": "2026-03-15T10:00:00Z",
"description": "通用入门智能体。",
"mcp_servers": [
{
"name": "example-mcp",
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
],
"metadata": {
"foo": "bar"
},
"model": {
"id": "claude-sonnet-4-6",
"effort": {
"type": "low"
},
"inference_geo": "inference_geo",
"speed": "standard"
},
"multiagent": {
"agents": [
{
"id": "agent_011CZkYqphY8vELVzwCUpqiQ",
"type": "agent",
"version": 1
}
],
"type": "coordinator"
},
"name": "我的第一个智能体",
"skills": [
{
"skill_id": "xlsx",
"type": "anthropic",
"version": "1"
},
{
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"type": "custom",
"version": "2"
}
],
"system": "你是一个通用智能体,可以研究问题、编写代码、运行命令并使用已连接的工具,端到端地完成用户任务。",
"tools": [
{
"configs": [
{
"enabled": true,
"name": "bash",
"permission_policy": {
"type": "always_allow"
}
}
],
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_ask"
}
},
"type": "agent_toolset_20260401"
}
],
"type": "agent",
"updated_at": "2026-03-15T10:00:00Z",
"version": 1
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}?beta=true。授权
OMA 工作区 API 密钥。
查询参数
为此接口启用 Beta API 合同,必须为 true。
true 请求体
创建 agent 的请求参数。
模型标识符。接受模型字符串(例如 claude-opus-4-6),或用于更多配置控制的 model_config 对象
"claude-sonnet-4-6"
智能体的人类可读名称。
1 - 256"我的第一个智能体"
对智能体功能的描述。
2048"一个通用入门智能体。"
该智能体连接的 MCP 服务器。最多 20 个。名称在数组内必须唯一。每个服务器都必须被 tools 中的某个 mcp_toolset 引用;未被引用的服务器会被拒绝。参见 MCP 连接器指南。
Show child attributes
Show child attributes
任意键值元数据。最多 16 对,键最多 64 个字符,值最多 512 个字符。
Show child attributes
Show child attributes
{ "foo": "bar" }
多智能体编排配置。目前支持 coordinator 拓扑,名册中包含 1-20 个智能体。
Show child attributes
Show child attributes
{
"type": "coordinator",
"agents": [
"agent_011CZkYqphY8vELVzwCUpqiQ",
{ "type": "self" }
]
}
智能体可用的技能。
要加载到会话容器中的技能。
- Option 1
- Option 2
Show child attributes
Show child attributes
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
}
智能体的系统提示词。
100000"你是一个通用智能体,可以研究问题、编写代码、运行命令并使用已连接的工具,端到端地完成用户任务。"
智能体可用的工具配置。所有工具集合计最多允许 128 个工具。
内置智能体工具的配置。用于启用或禁用智能体可用的工具组。
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
[{ "type": "agent_toolset_20260401" }]
响应
请求成功。
托管智能体的 agent。
"agent_011CZkYpogX7uDKUyvBTophP"
智能体的归档时间。未归档时为 null。
null
RFC 3339 格式的时间戳
"2026-03-15T10:00:00Z"
"一个通用入门智能体。"
Show child attributes
Show child attributes
[
{
"type": "url",
"name": "example-mcp",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
]
Show child attributes
Show child attributes
{ "foo": "bar" }
模型标识符和配置。
Show child attributes
Show child attributes
{
"id": "claude-sonnet-4-6",
"effort": { "type": "low" },
"inference_geo": "inference_geo",
"speed": "standard"
}
多智能体编排配置。当智能体为单线程时为 null。
Show child attributes
Show child attributes
{
"agents": [
{
"id": "agent_011CZkYqphY8vELVzwCUpqiQ",
"type": "agent",
"version": 1
}
],
"type": "coordinator"
}
"我的第一个智能体"
API 响应中返回的已解析技能。
- Option 1
- Option 2
Show child attributes
Show child attributes
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
}
[
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
},
{
"type": "custom",
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"version": "2"
}
]
"你是一个通用智能体,可以研究问题、编写代码、运行命令并使用已连接的工具,端到端地完成用户任务。"
API 响应中返回的工具配置的联合类型。
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
[
{
"configs": [
{
"enabled": true,
"name": "bash",
"permission_policy": { "type": "always_allow" }
}
],
"default_config": {
"enabled": true,
"permission_policy": { "type": "always_ask" }
},
"type": "agent_toolset_20260401"
}
]
agent "agent"
RFC 3339 格式的时间戳
"2026-03-15T10:00:00Z"
智能体的当前版本。从 1 开始,每次修改智能体时递增。
1
此页面对您有帮助吗?
curl --request POST \
--url 'http://localhost:38080/v1/agents?beta=true' \
--header 'Content-Type: application/json' \
--header 'anthropic-version: 2023-06-01' \
--header 'anthropic-beta: managed-agents-2026-04-01' \
--header 'X-Api-Key: sk-ant-local-default' \
--data '{
"model": "claude-sonnet-4-6",
"name": "我的第一个智能体",
"description": "通用入门智能体。",
"metadata": {
"foo": "bar"
},
"system": "你是一个通用智能体,可以研究问题、编写代码、运行命令并使用已连接的工具,端到端地完成用户任务。",
"tools": [
{
"type": "agent_toolset_20260401"
}
]
}'import requests
url = "http://localhost:38080/v1/agents"
payload = {
"model": "claude-sonnet-4-6",
"name": "我的第一个智能体",
"description": "通用入门智能体。"
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'claude-sonnet-4-6', name: '我的第一个智能体', description: '通用入门智能体。'})
};
fetch('http://localhost:38080/v1/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:38080/v1/agents"
payload := strings.NewReader("{\n \"model\": \"claude-sonnet-4-6\",\n \"name\": \"我的第一个智能体\",\n \"description\": \"通用入门智能体。\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "agent_011CZkYpogX7uDKUyvBTophP",
"archived_at": null,
"created_at": "2026-03-15T10:00:00Z",
"description": "通用入门智能体。",
"mcp_servers": [
{
"name": "example-mcp",
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
],
"metadata": {
"foo": "bar"
},
"model": {
"id": "claude-sonnet-4-6",
"effort": {
"type": "low"
},
"inference_geo": "inference_geo",
"speed": "standard"
},
"multiagent": {
"agents": [
{
"id": "agent_011CZkYqphY8vELVzwCUpqiQ",
"type": "agent",
"version": 1
}
],
"type": "coordinator"
},
"name": "我的第一个智能体",
"skills": [
{
"skill_id": "xlsx",
"type": "anthropic",
"version": "1"
},
{
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"type": "custom",
"version": "2"
}
],
"system": "你是一个通用智能体,可以研究问题、编写代码、运行命令并使用已连接的工具,端到端地完成用户任务。",
"tools": [
{
"configs": [
{
"enabled": true,
"name": "bash",
"permission_policy": {
"type": "always_allow"
}
}
],
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_ask"
}
},
"type": "agent_toolset_20260401"
}
],
"type": "agent",
"updated_at": "2026-03-15T10:00:00Z",
"version": 1
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}