Web Search (server tool) lets a model access real-time information from the web. When the model decides it needs current data, it requests a web search and then uses the returned results to craft a grounded answer (with citations when available).
Beta: Server tools and their parameters may change.
tools: [{ "type": "web_search" }]curl -X POST "https://api.lunos.tech/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{ "role": "user", "content": "What were the major AI announcements this week?" }
],
"tools": [
{ "type": "web_search" }
]
}'
import requests
url = "https://api.lunos.tech/v1/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"model": "openai/gpt-4o",
"messages": [
{ "role": "user", "content": "What were the major AI announcements this week?" }
],
"tools": [
{ "type": "web_search" }
],
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const response = await fetch("https://api.lunos.tech/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "openai/gpt-4o",
messages: [
{ role: "user", content: "What were the major AI announcements this week?" },
],
tools: [{ type: "web_search" }],
}),
});
const data = await response.json();
console.log(data);
You can customize web search behavior by passing an optional parameters object next to the tool type.
Example:
{
"tools": [
{
"type": "web_search",
"parameters": {
"engine": "exa",
"max_results": 5,
"max_total_results": 20,
"search_context_size": "medium",
"allowed_domains": ["example.com"],
"excluded_domains": ["reddit.com"]
}
}
]
}
Common parameters:
engine (auto): auto, native, exa, firecrawl, or parallelmax_results (default 5): max results per search call (engine-dependent range)max_total_results: cap the total results across all searches in one requestsearch_context_size (medium): controls how much snippet context is retrieved (engine-dependent)allowed_domains: restrict results to specific domains (engine-dependent)excluded_domains: exclude results from specific domains (engine-dependent)If supported by your engine, you can pass an approximate user location to bias results geographically:
{
"tools": [
{
"type": "web_search",
"parameters": {
"user_location": {
"type": "approximate",
"city": "San Francisco",
"region": "California",
"country": "US",
"timezone": "America/Los_Angeles"
}
}
}
]
}
Different engines may support different capabilities (like domain filtering or context sizing). Use:
auto (default): pick a native provider when available, otherwise fall back to an Exa-style enginenative: force provider-native web search where availableexa: use Exa search (keyword + embeddings-style)firecrawl: use Firecrawl search (BYOK — bring your own key)parallel: use Parallel searchTo restrict what the model is allowed to use, configure:
{
"type": "web_search",
"parameters": {
"allowed_domains": ["arxiv.org", "nature.com"],
"excluded_domains": ["reddit.com"]
}
}
Domain filtering behavior depends on the engine. If a given engine cannot apply those filters, Lunos/router may reject the request or ignore unsupported fields.
When the model performs multiple searches inside one request, use max_total_results to limit the cumulative number of results:
{
"type": "web_search",
"parameters": {
"max_results": 5,
"max_total_results": 15
}
}
Once the cap is reached, further searches in the same request should stop and the model is informed that the limit has been hit.
You may see errors in these cases:
If that happens, switch to a compatible model and/or adjust the tool parameters.
If the router returns it, the response usage object may include extra fields for server tool calls (for example, the number of web search requests).
type: "web_search".No headings found on this page.
