Responses API
POST /v1/responses — OpenAI 新一代 Responses API,提供更灵活的对话控制和更结构化的响应格式。
概述
Responses API 是 OpenAI 推出的新一代对话接口,与 Chat Completions API 相比,它使用 input 替代 messages 数组,并提供了更丰富的输出格式控制。
| 特性 | Chat Completions | Responses |
|---|---|---|
| 输入格式 | messages 数组 | input 字段 |
| 输出格式 | choices 数组 | output 数组 |
| 状态管理 | 无 | 支持异步任务状态 |
| 流式支持 | stream: true | stream: true |
请求示例
cURLBash
curl https://www.ulovegpt.com/v1/responses \
-H "Authorization: Bearer <你的 API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-mini",
"input": "解释一下量子计算的基本原理",
"text": {
"format": {"type": "text"}
},
"max_output_tokens": 1024
}'请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称 |
input | string/array | 是 | 输入内容,支持文本或消息对象 |
max_output_tokens | integer | 否 | 最大输出 token 数 |
text.format | object | 否 | 输出格式控制(text / json_schema) |
stream | boolean | 否 | 是否启用流式输出 |
temperature | number | 否 | 采样温度 |
响应格式
响应示例Json
{
"id": "resp_abc123",
"object": "response",
"created_at": 1704067200,
"model": "openai/gpt-5.4-mini",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "量子计算是一种利用量子力学原理进行信息处理的计算方式..."
}
]
}
],
"usage": {
"input_tokens": 20,
"output_tokens": 128,
"total_tokens": 148
}
}