三分钟完成接入
使用托管 API origin,创建带 scope 的 token,然后发送 OpenAI 兼容请求;model 字段填写 Manyfold agent id。
- Base URL
-
https://api.manyfold.ai/api/v1
- 认证
-
Authorization: Bearer
- 推荐 scope
-
chat.completions
- 创建或选择一个 Agent,并复制它的 agt_ id。
- 在 Settings -> API tokens 创建 API token。
- 调用 /chat/completions,并带上 Authorization: Bearer $MF_API_TOKEN。
示例
创建非流式 turn
curl https://api.manyfold.ai/api/v1/chat/completions \
-H "Authorization: Bearer $MF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "agt_your_agent_id",
"messages": [
{ "role": "user", "content": "Summarize this repository." }
]
}'
响应
{
"object": "chat.completion",
"model": "agt_your_agent_id",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}
],
"metadata": {
"session_id": "cts_...",
"assistant_message_id": "..."
}
}
流式响应
设置 stream: true 后会返回 Server-Sent Events。响应里的 x-session-id header 表示 Manyfold session。
curl -N https://api.manyfold.ai/api/v1/chat/completions \
-H "Authorization: Bearer $MF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "agt_your_agent_id",
"stream": true,
"stream_options": { "include_usage": true },
"messages": [
{ "role": "user", "content": "Write a short release note." }
]
}'
列出最近会话
curl "https://api.manyfold.ai/api/v1/conversations?limit=20" \
-H "Authorization: Bearer $MF_API_TOKEN"
回放一个会话
curl "https://api.manyfold.ai/api/v1/conversations/cts_your_session_id/messages?order=asc" \
-H "Authorization: Bearer $MF_API_TOKEN"
错误格式
错误使用 OpenAI 风格 envelope,方便兼容客户端统一处理认证和参数校验失败。
{
"error": {
"message": "API token does not have chat.completions scope",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
完整 Chat 指南 · Conversation 指南