Response 网络搜索 - QuickRouter API 中转接口
▼
Authorization
在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
部分OpenAI模型仅支持Response格式,例如o3-pro,codex-mini-latest
请求参数
Header 参数
Content-Type
string
必需
示例: application/json
Accept
string
必需
示例: application/json
Authorization
string
可选
示例: Bearer {{YOUR_API_KEY}}
Body 参数 application/json
model
string
可选
tools
array [object]
可选
模型在生成响应时可能调用的工具数组。
type
string
必需
网络搜索工具的类型。web_search_preview或web_search_preview_2025_03_11。
input
string
可选
{ "model": "gpt-4.1-2025-04-14", "tools": [ { "type": "web_search_preview" } ], "input": "what was a positive news story from today?" } 请求
示例
{
"model": "gpt-4.1-2025-04-14",
"tools": [
{
"type": "web_search_preview"
}
],
"input": "what was a positive news story from today?"
}
请求示例代码
curl --location --request POST 'https://api.quickrouter.ai/v1/responses' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
\"model\": \"gpt-4.1-2025-04-14\",
\"tools\": [
{
\"type\": \"web_search_preview\"
}
],
\"input\": \"what was a positive news story from today?\"
}'
var myHeaders = new Headers();
myHeaders.append(\"Accept\", \"application/json\");
myHeaders.append(\"Authorization\", \"Bearer YOUR_API_KEY\");
myHeaders.append(\"Content-Type\", \"application/json\");
var raw = JSON.stringify({
\"model\": \"gpt-4.1-2025-04-14\",
\"tools\": [
{
\"type\": \"web_search_preview\"
}
],
\"input\": \"what was a positive news story from today?\"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch(\"https://api.quickrouter.ai/v1/responses\", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import http.client
import json
conn = http.client.HTTPSConnection(\"api.quickrouter.ai\")
payload = json.dumps({
\"model\": \"gpt-4.1-2025-04-14\",
\"tools\": [
{
\"type\": \"web_search_preview\"
}
],
\"input\": \"what was a positive news story from today?\"
})
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
conn.request(\"POST\", \"/v1/responses\", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode(\"utf-8\"))
返回响应
响应参数 🟢 200 OK · application/json
id
string
必需
object
string
必需
created
integer
必需
choices
array [object]
必需
index
integer
可选
message
object
可选
finish_reason
string
可选
usage
object
必需
prompt_tokens
integer
必需
completion_tokens
integer
必需
total_tokens
integer
必需
{ "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "choices": [ { "index": 0, "message": { "role": "assistant", "content": "\n\nHello there, how may I assist you today?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 } }
示例
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}