Documentation Index
Fetch the complete documentation index at: https://wisdom-docs.juheapi.com/llms.txt
Use this file to discover all available pages before exploring further.
responses 是 OpenAI 最先进的模型响应生成接口,支持更丰富的交互能力和工具集成。此端点遵循 OpenAI Responses API 格式,提供超越标准对话补全端点的增强功能。
核心功能
- 多模态输入:支持文本、图像和文件输入
- 文本输出:生成高质量的文本响应
- 有状态交互:将先前响应的输出用作后续输入,保持对话连贯性
- 内置工具:集成文件搜索、网络搜索、代码解释器等功能
- 函数调用:允许模型访问外部系统和数据源
- 流式支持:通过服务器发送事件(SSE)实现实时流式响应
- 推理模型:支持 gpt-5 和 o 系列模型的推理配置
重要说明
模型差异不同的模型提供商可能支持不同的请求参数并返回不同的响应字段。我们强烈建议查阅 模型目录 了解每个模型的完整参数列表和使用说明。
响应透传原则WisGate 通常不会在逆向格式之外修改模型响应,确保您收到与原始 API 提供商一致的响应内容。
何时使用 Responses API当使用 OpenAI Pro 系列模型(如 o3-pro、o3-mini)以及需要内置工具、多模态输入或有状态对话等高级功能时,请使用 /v1/responses 端点。对于标准对话补全,请使用 /v1/chat/completions。
参考文档
有关 responses 接口的更多详细信息,请参阅 OpenAI 官方文档。
OpenAI 相关指南:
自动生成的文档请求参数和响应格式从 OpenAPI 规范自动生成。所有参数、其类型、描述、默认值和示例都直接从 openapi.json 提取。向下滚动查看交互式 API 参考。
常见问题
/v1/chat/completions 和 /v1/responses 有什么区别?
/v1/responses 端点是 OpenAI 更先进的接口,提供:
- 内置工具:网络搜索、文件搜索、代码解释器
- 多模态输入:除文本外还支持图像和文件
- 有状态对话:更好的对话状态管理
- Pro 模型必需:OpenAI Pro 系列模型(o3-pro、o3-mini)必须使用此端点
对于大多数模型的标准聊天交互,使用 /v1/chat/completions。当需要高级功能或使用 Pro 系列模型时,使用 /v1/responses。
如何使用多模态输入(文本 + 图像)?
您可以在单个请求中组合文本和图像:
response = client.responses.create(
model="gpt-4.1",
input=[
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "这张图片里有什么?"
},
{
"type": "input_image",
"image_url": "https://example.com/image.jpg"
}
]
}
]
)
如何使用内置工具如网络搜索?
通过在 tools 数组中包含内置工具来启用:
response = client.responses.create(
model="gpt-4.1",
input="今天有什么好消息?",
tools=[
{"type": "web_search_preview"}
]
)
如何维护对话状态?
使用 previous_response_id 创建多轮对话:
# 第一条消息
response1 = client.responses.create(
model="gpt-4.1",
input="你好,我叫 Alice。"
)
# 后续消息
response2 = client.responses.create(
model="gpt-4.1",
input="我叫什么名字?",
previous_response_id=response1.id
)
或者,使用 conversation 参数自动管理对话状态。
如何使用函数调用?
定义自定义函数并将其包含在 tools 数组中:
response = client.responses.create(
model="gpt-4.1",
input="今天波士顿的天气怎么样?",
tools=[
{
"type": "function",
"name": "get_current_weather",
"description": "获取指定位置的当前天气",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "城市和州,例如 San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location", "unit"]
}
}
],
tool_choice="auto"
)
如何使用推理模型(o3、gpt-5)?
对于推理模型,您可以配置推理强度:
response = client.responses.create(
model="o3-mini",
input="土拨鼠能啃多少木头?",
reasoning={
"effort": "high" # 选项:minimal、low、medium、high
}
)
更高的 effort 值会产生更深入的推理,但可能需要更长时间并使用更多令牌。
如何启用流式传输?
设置 stream: true 启用服务器发送事件流式传输:
stream = client.responses.create(
model="gpt-4.1",
input="给我讲个故事",
stream=True
)
for chunk in stream:
# 处理流式块
print(chunk, end="")