Web search
A model can search the web on its own, and the router runs the search for it. You ask for it the way you already would on your endpoint, and you get back a finished response with a list of sources.
This is not an ordinary tool call: you do not receive a request from the model, run the search, and send the result back. The router does all three steps itself, inside your single request.
Web search works on all three endpoints. Only two things differ: how you ask for it and what form the sources take.
Turning it on
Section titled “Turning it on”On POST /v1/chat/completions, use the web_search_options field. An empty object is enough, and you can set max_uses inside it. Instead of the field, you can pass web_search in tools:
curl https://api.waibee.com/v1/chat/completions \ -H "Authorization: Bearer $WAIBEE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-5.4-mini", "web_search_options": {}, "messages": [{ "role": "user", "content": "What is the latest Python version? One line." }] }'On POST /v1/messages, search is a tool in Anthropic format. The max_uses field is optional, and any tool version Anthropic releases works:
curl https://api.waibee.com/v1/messages \ -H "x-api-key: $WAIBEE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-haiku-4.5", "max_tokens": 512, "tools": [{ "type": "web_search_20250305", "name": "web_search", "max_uses": 2 }], "messages": [{ "role": "user", "content": "What is the latest Python version? One line." }] }'On POST /v1/responses, it is the web_search tool in tools:
"tools": [{ "type": "web_search" }]What the response contains
Section titled “What the response contains”On chat completions and messages, sources come in the same shape as from the built-in search of OpenAI and Anthropic. A client written for their search reads the response without changes.
On /v1/chat/completions, sources are citations in message.annotations:
"annotations": [ { "type": "url_citation", "url_citation": { "url": "https://www.python.org/downloads/release/python-3148/", "title": "Python Release Python 3.14.8 | Python.org", "start_index": 0, "end_index": 0 } }]Both indexes are always 0. The OpenAI schema requires these fields, so they are present, but they point at no real span of text: a source supports the response as a whole, not particular words in it.
On /v1/messages, sources are server_tool_use and web_search_tool_result blocks before the response text.
On /v1/responses, the sources found come in waibee:web_search items in output, next to the response. A search that finds nothing is still billed, but it may have no item of its own:
{ "type": "waibee:web_search", "id": "ws_call_abc", "status": "completed", "action": { "type": "search", "query": "latest python release", "sources": [{ "type": "url", "url": "https://www.python.org/downloads/" }] }}The waibee: prefix is ours: the Responses format allows custom item types under their own prefix. The intermediate turns, where the model asks for a search and gets the results, are not returned to you.
With "stream": true, sources arrive in the same stream: as an annotation in delta on chat completions, a pair of blocks on messages, and a pair of events on responses. It stays one stream however many searches the model makes: one opening event and one closing event.
How many searches the model makes
Section titled “How many searches the model makes”By default, the model makes up to 10 searches per request. To set your own number, use the max_uses field on any of the three surfaces: in web_search_options or the tool entry on chat completions, and in the tool entry on messages and responses. The lower of your number and our maximum applies, and our maximum is 20. A number above the maximum is not an error: it is lowered to 20.
When the limit runs out, the model is told so and answers with what it has found.
If search is unavailable, the request does not fail. The model gets an empty result marked as unavailable and answers without it.
The output limit you set covers the whole request, not each search separately. If it runs out while the model is still searching, the response comes back marked as cut off:
| Endpoint | How it is marked |
|---|---|
/v1/chat/completions | finish_reason: "length" |
/v1/messages | stop_reason: "max_tokens" |
/v1/responses | status: "incomplete" |
What it costs
Section titled “What it costs”Each search that runs is billed at its own rate, separately from tokens, including a search that finds nothing. A failed search is not billed. The number of searches run is in usage; see Tokens and usage.
Two more things show up on the bill:
- Input tokens grow noticeably. Search results go into the model’s input for the next step, which adds a few thousand tokens per request.
- If a request fails after a search, you still pay for the searches that ran and the tokens of the generation steps that completed.
What to know up front
Section titled “What to know up front”- Search results do not carry over to the next request. Your history and the response text go into it, but the search results do not. If the conversation needs a fact later, it has to be in the response text. When you send search blocks on messages or
waibee:web_searchitems on responses back in the history, the router removes them. - The model must support tool calling. The model asks for a search with a tool call, so its
capabilities.featuresmust includetools; see Models. - Of the built-in search settings, the router reads only
max_uses. The other fields of the tool entry and ofweb_search_options(domains, location, context size) are not applied. - Your own function named
web_searchstays yours. The router does not replace it or intercept calls to it. - On
/v1/chat/completions, search does not work withngreater than 1. The request runs without search.