OpenAI(Responses)
Codex 等新一代 Agent 需要使用 Responses 协议, 新模型优先用这个格式以获得完整的支持和高缓存率。
POST
/v1/responses鉴权
Authorization: Bearer <API_KEY>请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型调用名。 |
| input | string | array | 是 | 用户输入或输入项数组。 |
| stream | boolean | 否 | 为 true 时流式返回事件。 |
| instructions | string | 否 | 系统级指令。 |
| max_output_tokens | integer | 否 | 最大输出 tokens。 |
| temperature | number | 否 | 采样温度。 |
| top_p | number | 否 | 核采样概率。 |
| tools | array | 否 | 工具定义。 |
| tool_choice | string | object | 否 | 工具选择策略。 |
| prompt_cache_key | string | 否 | 用于提高缓存命中率的稳定键。 |
请求示例
curl https://api.xiaocaseai.com/v1/responses \
-H "Authorization: Bearer $XIAOCASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"<模型调用名>","input":"你好"}'响应示例
200JSON
{
"id": "resp_xxx",
"object": "response",
"status": "completed",
"output": [{ "type": "message", "content": [{ "type": "output_text", "text": "你好!" }] }]
}错误码
| 状态码 | 说明 |
|---|---|
| 404 | 模型不支持 Responses,或模型调用名错误。 |