跳转到主要内容
/v1/responses 端点实现了 OpenAI 的 Responses API 格式——一种比 Chat Completions 更新的替代方案,专为多轮上下文管理设计。你无需每次请求都发送完整对话历史,只需通过 ID 引用上一个响应,让 API 自动管理上下文。OpenOpen8 将这些请求转发到支持 Responses 格式的上游渠道;并非所有模型和渠道都支持此端点,使用前请确认你的渠道支持。

端点

方法路径说明
POST/v1/responses创建模型响应
POST/v1/responses/compact创建响应并压缩对话上下文

认证

Authorization: Bearer YOUR_TOKEN

与 Chat Completions 的区别

Chat Completions 格式(/v1/chat/completions)要求每次请求发送完整对话历史。Responses 格式在服务端管理上下文:你发送 previous_response_id,API 自动检索之前的上下文。/v1/responses/compact 变体在处理前还会压缩对话历史,为长对话节省 token 用量。
并非所有上游渠道都支持 Responses 格式。如果收到 503 错误,说明该模型的渠道不支持此端点。请改用 /v1/chat/completions

请求参数

model
string
必填
要使用的模型标识符。OpenOpen8 将请求路由到该模型对应的上游渠道。
input
string | object[]
必填
模型的输入。可以是字符串或带 type 字段的结构化输入部分数组(input_textinput_imageinput_file)。
instructions
string | object
系统级指令,等同于 Chat Completions 中的 system 消息。
previous_response_id
string
之前响应的 ID。设置后模型使用该响应的上下文作为对话历史,无需重新发送完整消息列表。
stream
boolean
默认值:"false"
设为 true 时,响应以 SSE 流式返回。
stream_options
object
仅在 streamtrue 时生效的选项。
temperature
number
采样温度,范围 02
top_p
number
核采样概率质量,取值 01
max_output_tokens
integer
响应中模型可生成的最大 token 数量。
reasoning
object
控制支持推理的模型的推理行为。
tools
object[]
模型可用的工具。支持函数工具和 MCP 风格的工具配置。
tool_choice
string | object
默认值:"auto"
控制模型如何选择工具。"none""auto""required" 或指定函数对象。
truncation
string | object
控制模型如何处理超出上下文窗口的内容。传 "auto" 由模型决定。
context_management
object
高级上下文管理选项,包括 /v1/responses/compact 端点的压缩策略设置。
metadata
object
附加到响应的键值元数据。值必须为字符串,最多 16 对。
top_logprobs
integer
在每个位置返回最可能的 token 数量及其对数概率。取值 020
max_tool_calls
integer
模型在单次响应中可发起的最大 tool calling 次数。

示例

curl https://openopen8.ai/v1/responses \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "Summarize the concept of entropy in thermodynamics.",
    "instructions": "You are a physics professor. Keep explanations concise."
  }'
使用 previous_response_id 的多轮对话:
cURL
# 第一轮
curl https://openopen8.ai/v1/responses \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "What is the speed of light?"
  }'

# 第二轮——通过 ID 引用第一个响应
curl https://openopen8.ai/v1/responses \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "How does that relate to Einstein'\''s theory of relativity?",
    "previous_response_id": "resp_abc123"
  }'
对话压缩:
cURL
curl https://openopen8.ai/v1/responses/compact \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "Continue our discussion.",
    "previous_response_id": "resp_abc123"
  }'
/v1/responses/compact 端点在生成下一个响应前压缩之前的对话上下文,为长多轮会话节省 token 用量。