POST
创建模型响应(调用联网)
POST /v1/responses — Responses API + 内置网页搜索工具
创建模型响应(调用联网)
使用 Responses API 的内置网页搜索工具,让模型实时获取互联网信息。
参考:OpenAI 官方文档
POST
https://api000.com/v1/responses
请求示例
{
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": "搜索 2025 年最新发布的大语言模型有哪些"
}
],
"tools": [
{
"type": "web_search_preview"
}
]
}
from openai import OpenAI
client = OpenAI(base_url="https://api000.com/v1", api_key="sk-xxxxxxxxxxxxxxxx")
response = client.responses.create(
model="gpt-4.1",
input=[{"role": "user", "content": "今天有什么 AI 相关的最新新闻?"}],
tools=[{"type": "web_search_preview"}]
)
for item in response.output:
if item.type == "message":
print(item.content[0].text)
elif item.type == "web_search_call":
print(f"[已搜索: {item.status}]")
使用 o3-deep-research(深度研究模型)
response = client.responses.create(
model="o3-deep-research-2025-06-26",
input=[{
"role": "user",
"content": "对比分析 GPT-4.1、Claude 4.5、Gemini 2.5 Pro 在编程能力方面的差异"
}],
tools=[{"type": "web_search_preview"}]
)
响应示例(包含搜索过程)
{
"id": "resp_xxx",
"output": [
{
"type": "web_search_call",
"id": "ws_xxx",
"status": "completed"
},
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "根据最新搜索结果,2025年最新发布的大模型包括..."
}
]
}
]
}
注意事项
- 联网搜索会增加响应时间(通常 5-15 秒)
- 搜索操作会额外计费(具体价格见控制台)
- 深度研究模型(
o3-deep-research)适合需要详尽研究的场景