OpenAI 新一代对话接口,统一处理文本、工具调用与结构化输出。
Responses API 是 OpenAI 新一代对话接口,用 input 替代 messages,交互方式更统一。
有什么用:与 Chat 对话类似,适合需要工具调用(function calling)、结构化输出的新项目。习惯传统方式的用户直接用 Chat 对话 即可。
| 项目 | 值 |
|---|---|
| 请求方法 | POST |
| 请求路径 | https://103.236.87.35/v1/responseshttps://103.236.87.35/v1/responses/compact(会话压缩) |
| 请求头 | Authorization: Bearer <你的密钥>Content-Type: application/json |
| 是否需要鉴权 | 必需 |
| 是否计费 | 按 Token 计费 |
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
model | string | 是 | - | 模型名称 |
input | string/array | 是 | - | 输入内容:字符串或消息对象数组(含 role/content) |
instructions | string | 否 | - | 系统指令,相当于 system 消息 |
max_output_tokens | integer | 否 | 模型默认 | 输出最大 token 数 |
temperature | number | 否 | 1 | 随机性 |
stream | boolean | 否 | false | 是否流式返回 |
tools | array | 否 | - | 工具定义(function calling) |
curl https://103.236.87.35/v1/responses \
-H "Authorization: Bearer <你的密钥>" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"instructions": "你是一个简洁的助手",
"input": "用一句话介绍你自己",
"max_output_tokens": 200
}'
from openai import OpenAI
client = OpenAI(api_key="<你的密钥>", base_url="https://103.236.87.35/v1")
resp = client.responses.create(
model="deepseek-v4-flash",
instructions="你是一个简洁的助手",
input="用一句话介绍你自己",
)
print(resp.output_text)
{
"id": "resp_xxx",
"object": "response",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [{"type": "output_text", "text": "我是你的 AI 助手。"}]
}
],
"usage": {"input_tokens": 15, "output_tokens": 20, "total_tokens": 35}
}
| 字段名 | 类型 | 说明 |
|---|---|---|
id | string | 本次响应唯一 ID |
status | string | 状态:completed 完成 / in_progress 进行中 |
output[].content[].text | string | 回复文本内容 |
usage | object | token 用量(计费依据) |