Responses API
2026/7/28大约 2 分钟
Responses API
Responses API 是 OpenAI 推出的下一代 API 接口,支持通过 previous_response_id 实现多轮对话管理,无需手动维护消息历史。
接口信息
| 属性 | 值 |
|---|---|
| 基础 URL | https://api.quickapi.store |
| 端点 | POST /v1/responses |
| Content-Type | application/json |
| 认证方式 | Bearer Token |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称,如 gpt-4o、gpt-4o-mini |
input | string / array | 是 | 用户输入,可以是字符串或消息数组 |
instructions | string | 否 | 系统级指令,用于设定模型行为 |
previous_response_id | string | 否 | 上一次响应的 ID,用于多轮对话 |
max_output_tokens | integer | 否 | 最大输出 token 数 |
temperature | number | 否 | 采样温度,0-2,默认 1 |
top_p | number | 否 | nucleus 采样,0-1,默认 1 |
stream | boolean | 否 | 是否启用流式输出,默认 false |
tools | array | 否 | 工具定义数组 |
tool_choice | string/object | 否 | 工具调用策略,auto / none / 指定工具 |
示例
基础请求
curl https://api.quickapi.store/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"input": "请介绍一下量子计算的基本原理"
}'流式输出
curl https://api.quickapi.store/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"input": "写一首关于春天的诗",
"stream": true
}'使用 instructions
curl https://api.quickapi.store/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"input": "帮我写一段 Python 代码",
"instructions": "你是一个资深 Python 工程师,请给出简洁高效的代码示例"
}'多轮对话
curl https://api.quickapi.store/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"input": "那它的应用场景有哪些?",
"previous_response_id": "resp_abc123def456"
}'响应示例
{
"id": "resp_abc123def456",
"object": "response",
"created": 1721234567,
"model": "gpt-4o",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "量子计算是一种利用量子力学原理(如叠加态和纠缠态)来处理信息的新型计算模式。与传统计算机使用比特(0 或 1)不同,量子计算机使用量子比特(qubit),可以同时处于 0 和 1 的叠加态..."
}
]
}
],
"usage": {
"input_tokens": 15,
"output_tokens": 128,
"total_tokens": 143
}
}Python 示例
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.quickapi.store/v1"
)
# 基础调用
response = client.responses.create(
model="gpt-4o",
input="请介绍一下量子计算的基本原理"
)
print(response.output[0].content[0].text)
# 多轮对话
response2 = client.responses.create(
model="gpt-4o",
input="那它的应用场景有哪些?",
previous_response_id=response.id
)
print(response2.output[0].content[0].text)提示
使用 previous_response_id 进行多轮对话时,服务端会自动管理上下文,无需手动拼接历史消息。
注意
max_output_tokens 设置过小可能导致回复被截断,建议根据实际需求合理设置。

