Using the Chat Completions API, you can directly access the fine-tuned models and tool used by Search in ChatGPT.
When using Chat Completions, the model always retrieves information from the web before responding to your query. To use web_search_preview as a tool that models like gpt-4o and gpt-4o-mini invoke only when necessary, switch to using the Responses API.
Currently, you need to use one of these models to use web search in Chat Completions:
gpt-4o-search-preview
gpt-4o-mini-search-preview
Web search parameter example
import OpenAI from "openai";
const client = new OpenAI();
const completion = await client.chat.completions.create({
model: "gpt-4o-search-preview",
web_search_options: {},
messages: [{
"role": "user",
"content": "What was a positive news story from today?"
}],
});
console.log(completion.choices[0].message.content);
Output and citations
The API response item in the choices array will include:
message.content with the text result from the model, inclusive of any inline citations
annotations with a list of cited URLs
By default, the model's response will include inline citations for URLs found in the web search results. In addition to this, the url_citation annotation object will contain the URL and title of the cited source, as well as the start and end index characters in the model's response where those sources were used.
Pricing
- Input Tokens: $2.500 /M tokens
- Output Tokens: $10.000 /M tokens
- Cache Read: $1.250 /M tokens
Input Modalities
- Text
- Vision
Output Modalities
- Text
Capabilities
- Web
- Tool calling
- Structured outputs
Providers
OpenAI gpt-4o-search-preview
Pricing$2.500$10.000
Cache$1.250
Context128K
Max output16K
Latency7.8S
Throughput19.1TPS
Uptime
100.00% uptime 2 days ago
100.00% uptime yesterday
0.00% uptime today
Azure gpt-4o-search-preview
Pricing$2.500$10.000
Cache$1.250
Context128K
Max output16K
Latency2.3S
Throughput120.9TPS
Uptime
0.00% uptime 2 days ago
0.00% uptime yesterday
0.00% uptime today
Performance for gpt-4o-search-preview
Uptime is the percentage of requests that succeeded over the past 72 hours. AIHubMix continuously monitors every provider and automatically retries with the next-best provider when one returns an error or responds too slowly; Latency is total round-trip time (lower is better); Throughput is how fast the model writes (tokens per second, higher is better).
Uptime
Loading...
Latency
Loading...
Throughput
Loading...
Try this model
Python
