Web Search
Use web search with haimaker to get real-time information from the internet.
| Feature | Details |
|---|---|
| Supported Endpoints | - /chat/completions - /responses |
| Supported Providers | openai, xai, vertex_ai, anthropic, gemini, perplexity |
Which Search Engine is Used?
Each provider uses their own search backend:
| Provider | Search Engine | Notes |
|---|---|---|
OpenAI (gpt-5-search-api, gpt-4o-search-preview, gpt-4o-mini-search-preview) | OpenAI's internal search | Real-time web data |
xAI (grok-3) | xAI's search + X/Twitter | Real-time social media data |
Google AI/Vertex (gemini-2.0-flash) | Google Search | Uses actual Google search results |
Anthropic (claude-3-5-sonnet) | Anthropic's web search | Real-time web data |
| Perplexity | Perplexity's search engine | AI-powered search and reasoning |
web_search_optionsFor OpenAI, only dedicated search models support the web_search_options parameter:
gpt-4o-search-previewgpt-4o-mini-search-previewgpt-5-search-api
Regular models like gpt-5, gpt-4.1, gpt-4o do not support web_search_options
web_search_options parameter is optionalSearch models (like gpt-4o-search-preview) automatically search the web even without the web_search_options parameter.
Use web_search_options when you need to:
- Adjust
search_context_size("low","medium","high") - Specify
user_locationfor localized results
Anthropic Web Search Models: Claude models that support web search: claude-3-5-sonnet-latest, claude-3-5-sonnet-20241022, claude-3-5-haiku-latest, claude-3-5-haiku-20241022, claude-3-7-sonnet-20250219
OpenAI Web Search: Two Approaches
OpenAI offers two distinct ways to use web search depending on the endpoint and model:
| Approach | Endpoint | Models | How to enable |
|---|---|---|---|
| Search Models | /chat/completions | gpt-5-search-api, gpt-4o-search-preview, gpt-4o-mini-search-preview | Pass web_search_options parameter |
| Web Search Tool | /responses | gpt-5, gpt-4.1, gpt-4o, and other regular models | Pass web_search_preview tool |
Search models like gpt-5-search-api automatically search the web even without the web_search_options parameter. Use web_search_options to set search_context_size ("low", "medium", "high") or specify user_location for localized results.
/chat/completions
Quick Start
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.chat.completions.create(
model="gpt-5-search-api",
messages=[
{
"role": "user",
"content": "What was a positive news story from today?"
}
],
extra_body={
"web_search_options": {
"search_context_size": "medium" # Options: "low", "medium", "high"
}
}
)
print(response.choices[0].message.content)
cURL
curl https://api.haimaker.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5-search-api",
"messages": [
{
"role": "user",
"content": "What was a positive news story from today?"
}
],
"web_search_options": {
"search_context_size": "medium"
}
}'
Search Context Size
The search_context_size parameter controls how much search context is provided to the model:
| Value | Description |
|---|---|
"low" | Minimal search context, faster responses |
"medium" | Balanced search context (default) |
"high" | Maximum search context, more comprehensive |
response = client.chat.completions.create(
model="gpt-5-search-api",
messages=[{"role": "user", "content": "What's happening in tech today?"}],
extra_body={
"web_search_options": {
"search_context_size": "high"
}
}
)
Using Different Providers
xAI Grok
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.chat.completions.create(
model="xai/grok-3",
messages=[
{
"role": "user",
"content": "What are people saying about AI on Twitter today?"
}
],
extra_body={
"web_search_options": {
"search_context_size": "high"
}
}
)
print(response.choices[0].message.content)
Anthropic Claude
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.chat.completions.create(
model="anthropic/claude-3-5-sonnet-latest",
messages=[
{
"role": "user",
"content": "What are the latest developments in AI?"
}
],
extra_body={
"web_search_options": {
"search_context_size": "medium",
"user_location": {
"type": "approximate",
"approximate": {
"city": "San Francisco"
}
}
}
}
)
print(response.choices[0].message.content)
Google Gemini
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.chat.completions.create(
model="gemini/gemini-2.0-flash",
messages=[
{
"role": "user",
"content": "What are the top news stories today?"
}
],
extra_body={
"web_search_options": {
"search_context_size": "low"
}
}
)
print(response.choices[0].message.content)
/responses
Use the web_search_preview tool with models like gpt-5, gpt-4.1, gpt-4o, etc.
Search-dedicated models like gpt-5-search-api and gpt-4o-search-preview do not support the /responses endpoint. Use them with /chat/completions + web_search_options instead (see above).
Quick Start
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
response = client.responses.create(
model="gpt-5",
input="What is the capital of France?",
tools=[{
"type": "web_search_preview" # enables web search with default medium context size
}]
)
print(response.output_text)
Search Context Size
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)
# Customize search context size
response = client.responses.create(
model="gpt-5",
input="What is the capital of France?",
tools=[{
"type": "web_search_preview",
"search_context_size": "low" # Options: "low", "medium" (default), "high"
}]
)
print(response.output_text)
Checking if a Model Supports Web Search
Call the /v1/model_group/info endpoint to check if a model supports web search:
curl https://api.haimaker.ai/v1/model_group/info \
-H "Authorization: Bearer YOUR_API_KEY"
The response includes a supports_web_search field for each model:
{
"data": [
{
"model_group": "gpt-5-search-api",
"providers": ["openai"],
"max_tokens": 128000,
"supports_web_search": true
},
{
"model_group": "gpt-4o-search-preview",
"providers": ["openai"],
"max_tokens": 128000,
"supports_web_search": true
},
{
"model_group": "grok-3",
"providers": ["xai"],
"max_tokens": 131072,
"supports_web_search": true
},
{
"model_group": "gemini-2-flash",
"providers": ["vertex_ai"],
"max_tokens": 8192,
"supports_web_search": true
}
]
}
You can also check the full list of available models at haimaker.ai/models or call /v1/models for models available to your API key.