POST /chat

同步对话接口。参数与 /run 相同,但返回 JSON 而非 SSE 流。

POST /cells/{cellID}/chat

请求参数

与 POST /run 完全相同。


curl 示例

curl -X POST http://localhost:9091/cells/my-cell/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "actor": "user-001",
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": [{"type": "text", "text": "1+1等于几?"}]}
    ]
  }'

响应

{
  "response": "1+1等于2。",
  "run_id": "run-def456",
  "session_id": "s-auto-001",
  "model": "gpt-4o",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 8
  }
}
字段类型说明
responsestring最终回复文本
run_idstringRun ID
session_idstring会话 ID
modelstring实际使用的模型
usageobjectToken 用量

错误码

与 POST /run 相同。


适用场景

对于交互式对话,推荐使用 POST /run(SSE 流式),用户体验更好。