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
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
response | string | 最终回复文本 |
run_id | string | Run ID |
session_id | string | 会话 ID |
model | string | 实际使用的模型 |
usage | object | Token 用量 |
错误码
与 POST /run 相同。
适用场景
- 不需要流式输出的简单问答
- 后台脚本 / CI 集成
- 测试 Provider 连通性
对于交互式对话,推荐使用 POST /run(SSE 流式),用户体验更好。