跳转到内容
控制台

OpenAI 兼容

Responses

POST /v1/responses —— OpenAI Responses 协议,适合长会话与工具编排,Codex CLI 使用此接口

OpenAI Responses 协议接口,通过 previous_response_id 串联多轮对话,适合长会话与工具编排。Codex CLI 使用此接口。

POSThttps://visioncoder.cn/v1/responses

两种 Header 任选其一,使用同一个 Key(在 API Key 管理 创建):

Authorization: Bearer YOUR_API_KEY
x-api-key: YOUR_API_KEY

OpenAI 协议的 Base URL 为 https://visioncoder.cn/v1。

参数 类型 必填 说明
model string 是 模型 ID,可用值见 GET /v1/models
input string | array 是 用户输入,字符串或结构化输入数组
instructions string 否 系统级指令,等价于 Chat Completions 的 system 消息
reasoning object 否 推理配置,Responses 独有
max_output_tokens integer 否 最大输出 token 数
temperature number 否 采样温度
top_p number 否 核采样,与 temperature 二选一
stream boolean 否 以 SSE 流式返回
previous_response_id string 否 上一轮响应的 ID,用于串联多轮对话,无需重发完整历史
store boolean 否 是否在服务端保留本次响应
tools array 否 工具定义
tool_choice string | object 否 工具选择策略
metadata object 否 自定义标记,用于自行做用量归因
Terminal window
curl https://visioncoder.cn/v1/responses \
-H "Authorization: Bearer $VISIONCODER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"input": "Hello",
"stream": false
}'
{
"id": "resp_01HG7K2P5N6Q3T8XY",
"object": "response",
"created_at": 1779438767,
"status": "completed",
"model": "gpt-5.5",
"output": [
{
"id": "msg_01HG7K2P5N6Q3T8XZ",
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Hi! How can I help you today?"
}
]
}
],
"output_text": "Hi! How can I help you today?",
"usage": {
"input_tokens": 8,
"output_tokens": 9,
"total_tokens": 17
}
}
字段 说明
id 响应 ID,作为下一轮的 previous_response_id
status 响应状态,正常完成为 completed
output 输出项数组,文本在 type: "message" 项的 content[].text
output_text SDK 提供的文本汇总字段
usage input_tokens / output_tokens / total_tokens,计费依据

响应头 X-Request-Id 是请求唯一标识,X-Served-Model 等于请求的模型(网关不改写模型)。

错误体为 OpenAI 格式。流式响应开始后出错,以 SSE 错误事件结束。排障时记录 X-Request-Id 并报给客服。

状态码 含义 处理
400 请求体格式或参数错误 查看 error.message
401 API Key 无效 到 API Key 管理 确认
403 模型对该 Key 不可用 用 GET /v1/models 确认
429 限流,或额度用完 限流带 Retry-After,退避重试。error.code 为 insufficient_quota 表示没有可用的套餐、加油包或企业余额(业务码 402072)或额度已用完,不带 Retry-After,重试无效,需到 定价 获取额度
503 上游全部过载或无可用端点 稍后重试