文档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://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 取纯文本。
其他 OpenAI 兼容入口
同一鉴权头下还提供以下入口,请求/响应形状与 OpenAI 官方一致:
| 入口 | 用途 | 计费 |
|---|---|---|
POST /v1/embeddings | 文本向量(text-embedding-3-small / -large) | 按输入 token |
POST /v1/images/generations · /v1/images/edits | 图像生成与编辑,见图像与视频 | 按张 |
POST /v1/videos/generations · /v1/videos/edits · GET /v1/videos/{request_id} | 异步视频生成(Grok Imagine),见图像与视频 | 按秒,成片后结算 |
POST /v1/responses/compact · /v1/responses/input_tokens · /v1/alpha/search | Codex 客户端使用的上下文压缩、输入 token 预估与联网搜索 | 压缩按 token;预估免费;搜索按次 |
GET /v1/usage | 账户余额与累计消费,见计费与余额 | 免费,计入 RPM |
curl https://soleapi.com/v1/embeddings \
-H "Authorization: Bearer $SOLEAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "The quick brown fox"
}'POST /v1/chat/completions 仅作历史兼容保留。新集成一律使用 Responses API。