Responses
/v1/responses 是 OpenAI Responses API 兼容入口,适合 Codex CLI 和 Responses 协议客户端。
接口说明
| 项目 | 值 |
|---|---|
| Method | POST |
| Path | /v1/responses、/v1/responses/* |
| Content-Type | application/json |
| 认证 | Authorization: Bearer YOUR_API_KEY |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 请求模型。 |
input | string 或 array | 是 | Responses API 输入。 |
stream | boolean | 否 | 是否流式响应。 |
instructions | string | 否 | 系统级指令。 |
reasoning | object | 否 | 推理强度等配置,按模型能力生效。 |
tools | array | 否 | 工具定义,是否生效取决于所选模型和接口模式。 |
请求示例
bash
curl https://api.llmapi.site/v1/responses \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5.1",
"input": "Write a concise release note.",
"stream": false
}'响应示例
json
{
"id": "resp_123",
"object": "response",
"status": "completed",
"model": "gpt-5.1",
"output": []
}| 字段 | 说明 |
|---|---|
id | 上游兼容接口返回的 Response ID。 |
status | 响应生命周期状态,非流式请求通常为 completed。 |
model | 本次响应使用的模型。 |
output | Responses API 输出项。 |
当 stream 为 true 时,响应使用 OpenAI Responses 兼容的 SSE。
WebSocket 入口
GET /v1/responses 可用于使用 Responses WebSocket 流程的客户端。
错误码
| 状态码 | 原因 |
|---|---|
400 | 请求体、模型名、输入、工具或 reasoning 参数无效。 |
401 | API Key 缺失或无效。 |
403 | 余额、额度、分组或订阅校验失败。 |
404 | 请求模型或 Responses 兼容路径不可用。 |
429 | 达到频率限制或并发限制。 |
500 / 502 / 503 | 网关或上游服务商失败。 |