文档API 参考Responses API
Responses API
OpenAI 兼容的 Responses 入口:请求字段、响应形状与流式。
POST
/v1/responses与 OpenAI Responses API 请求体兼容的对话入口,也是 Codex 等编码工具实际使用的接口。鉴权用 Authorization: Bearer。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 id,见模型列表。 |
input | string | array | 是 | 用户输入:纯文本,或多轮/多模态的消息数组。 |
instructions | string | 否 | 系统提示词。 |
max_output_tokens | integer | 否 | 输出 token 上限(不小于 16)。 |
stream | boolean | 否 | true 时以 SSE 流式返回,见流式响应。 |
temperature / tools / … | — | 否 | 其余官方字段原样转发,是否生效取决于目标模型。 |
curl https://api.soleapi.com/v1/responses \
-H "Authorization: Bearer $SOLEAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"input": "Write a haiku about the sea",
"max_output_tokens": 200
}'响应
{
"id": "resp_abc123",
"object": "response",
"model": "claude-fable-5",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{ "type": "output_text", "text": "Waves fold into foam..." }
]
}
],
"usage": {
"input_tokens": 14,
"output_tokens": 23,
"total_tokens": 37
}
}usage 里的 token 数就是计费依据;官方 SDK 可以直接用 resp.output_text 取纯文本。
相关入口
POST /v1/responses/compact与POST /v1/responses/input_tokens:Codex 客户端使用的上下文压缩与输入 token 预估辅助入口。
POST /v1/chat/completions 仅作历史兼容保留。新集成一律使用 Responses API。