https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses
const response = await client.responses.create({
model: "gpt-4.1",
tools: [ { type: "web_search_preview" } ],
input: "What was a positive news story from today?",
});
response
400 Bad Request [
generation-wrk-1 | [00] `message`: `Web search options not supported with this model.`,
generation-wrk-1 | [00] `type`: `invalid_request_error`,
generation-wrk-1 | [00] `param`: `web_search_options`,
generation-wrk-1 | [00] `code`: null
generation-wrk-1 | [00] ]: Requeuing: processing
sps
April 17, 2025, 10:50am
2
I can confirm that web-search-preview
tool is available on gpt-4.1
and that it worked in my tests.
Here's, the code I used:
// websearchtest.mjs
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
async function run() {
const response = await openai.responses.create({
model: "gpt-4.1",
input: "What's the current price of $NVDA ?",
text: {
format: {
type: "text",
},
},
reasoning: {},
tools: [
{
type: "web_search_preview",
user_location: {
type: "approximate",
},
search_context_size: "medium",
},
],
temperature: 1,
max_output_tokens: 2048,
top_p: 1,
store: false,
});
console.log(response);
}
run();
Output:
{
id: 'resp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
object: 'response',
created_at: 1744886536,
status: 'completed',
error: null,
incomplete_details: null,
instructions: null,
max_output_tokens: 2048,
model: 'gpt-4.1-2025-04-14',
output: [
{
id: 'ws_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
type: 'web_search_call',
status: 'completed'
},
{
id: 'msg_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
type: 'message',
status: 'completed',
content: [Array],
role: 'assistant'
}
],
parallel_tool_calls: true,
previous_response_id: null,
reasoning: { effort: null, summary: null },
service_tier: 'default',
store: false,
temperature: 1,
text: { format: { type: 'text' } },
tool_choice: 'auto',
tools: [
{
type: 'web_search_preview',
search_context_size: 'medium',
user_location: [Object]
}
],
top_p: 1,
truncation: 'disabled',
usage: {
input_tokens: 310,
input_tokens_details: { cached_tokens: 0 },
output_tokens: 155,
output_tokens_details: { reasoning_tokens: 0 },
total_tokens: 465
},
user: null,
metadata: {},
output_text: 'As of April 17, 2025, NVIDIA Corporation (NVDA) is trading at $104.49 per share, down $7.74 (6.89%) from the previous close.\n' +
'\n' +
'## Stock market information for NVIDIA Corp (NVDA)\n' +
'- NVIDIA Corp is a equity in the USA market.\n' +
'- The price is 104.49 USD currently with a change of -7.73 USD (-0.07%) from the previous close.\n' +
'- The latest trade time is Thursday, April 17, 03:26:51 PDT.\n' +
'\n' +
'\n' +
'Please note that stock prices fluctuate throughout the trading day. For the most current information, consult a financial news source or brokerage platform. '
}
Make sure you’re on the latest version of the openai
package.
You can also test this on Playground .
@sps can you share a working example on the Playground? On the chat completion side, it says “No access to live data” on the response API side it says “as of 2024 it was trading at …”
No options for web search on the Playground