Skip to content

Web Search

Web Search is a tool that lets the models access the web to help answer user queries. The tool call is executed in Netpreme's backend, and the answer comes with source URLs.

Overview

Use it for:

  • Recent news and events
  • Current software releases and documentation
  • Product or market research
  • Anything that may have changed since the model was trained
  • Claims that need checking against a source

All models support Web Search. Supported models are listed in Models.

The model decides when to search. Each request can run up to four searches, five results each. To turn search off, set tool_choice to none.

Search Triggering

The web search tool is triggered automatically in multi-turn inference calls. Tool calls are executed in the following turn, after they are requested in the current turn's response.

The model searches when the answer depends on information that is current, changing, or outside its training data:

  • Recent events and announcements
  • Current prices, rates, or statistics
  • Details about an organization or product that may have changed
  • Explicit requests to look something up

It answers directly, without searching, when the question draws on stable knowledge. Requesting a search explicitly makes one more likely, for example "Search the web for the latest Kubernetes release and cite the sources."

Web Search is available without declaring anything. Do not declare a function named web_search; that name is reserved.

curl "https://api.netpreme.com/v1/chat/completions" \
  -H "Authorization: Bearer <NETPREME_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zai-org/GLM-5.2-FP8",
    "messages": [
      {
        "role": "user",
        "content": "What changed in Kubernetes this week? Search the web and cite sources."
      }
    ]
  }'

The internal search transcript is hidden. The response carries the final assistant message and token usage summed across every model turn.

Streaming requests may receive SSE keepalives while search and intermediate model work happen. Search lifecycle events are not exposed here.

To disable search, set tool_choice to none:

{
  "model": "zai-org/GLM-5.2-FP8",
  "messages": [{"role": "user", "content": "Explain binary search."}],
  "tool_choice": "none"
}

Each search appears as a web_search_call output item.

curl "https://api.netpreme.com/v1/responses" \
  -H "Authorization: Bearer <NETPREME_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zai-org/GLM-5.2-FP8",
    "input": "Find the latest Kubernetes release notes and cite sources.",
    "tools": [{"type": "web_search"}]
  }'

A successful response carries a lifecycle item, then the answer:

{
  "status": "completed",
  "output": [
    {
      "id": "ws_...",
      "type": "web_search_call",
      "status": "completed",
      "action": {"type": "search", "query": "latest Kubernetes release notes"}
    },
    {
      "type": "message",
      "role": "assistant",
      "content": [{"type": "output_text", "text": "..."}]
    }
  ]
}

Declaring {"type":"web_search"} is recommended for compatibility and visibility, though search is available by default.

Set "stream": true to watch progress. Search emits:

response.web_search_call.in_progress
response.web_search_call.searching
response.web_search_call.completed

Each item is wrapped in response.output_item.added and response.output_item.done. The answer itself streams through the standard Responses events: response.content_part.added, response.output_text.delta, response.output_text.done, response.content_part.done, and, for caller tools, response.function_call_arguments.delta and .done.

Use sequence_number to preserve event ordering.

curl "https://api.netpreme.com/v1/messages" \
  -H "Authorization: Bearer <NETPREME_API_KEY>" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zai-org/GLM-5.2-FP8",
    "max_tokens": 2048,
    "messages": [
      {
        "role": "user",
        "content": "Find the latest Kubernetes release notes and cite sources."
      }
    ],
    "tools": [
      {"type": "web_search_20260318", "name": "web_search", "max_uses": 4}
    ]
  }'

Searches arrive as server_tool_use and web_search_tool_result blocks, followed by the final text. max_tokens is required and must be positive, and the anthropic-version header is required and must be 2023-06-01.

Usage reports how many searches the service admitted:

{"usage": {"server_tool_use": {"web_search_requests": 1, "web_fetch_requests": 0}}}

A fifth search is rejected before it reaches the provider, so it is not counted.

Claude Code. Claude Code declares its own WebSearch tool. When it does, that tool call goes back to Claude Code so its built-in search interface renders, and we do not add our own search to that turn. Other caller-defined tools remain caller-owned, and the service never executes them.

FAQ

Does every request run a search? No. The model searches only when it thinks current or externally verifiable information will help.
Can I turn search off? Yes. Set `tool_choice` to `none`.
Can I define my own web_search function? No. The name `web_search` is reserved on both the OpenAI and the Anthropic paths. Caller-defined tools remain caller-owned and are never executed by the service.
Can I raise max_uses above four? No. Four searches per request is a service limit, and a higher `max_uses` does not change it.
Can Web Search fetch a whole page? No. It works from bounded search-result excerpts. It is not a page-fetch or browsing tool and cannot retrieve a named URL in full.

Reference

Limits

Limit Value
Searches per request 4
Results per search 5
Model turns per request 5
Maximum query length 500 characters
Combined included and excluded domains 10
Search topics general, news, finance
Search time ranges day, week, month, year
Provider retries 1 bounded retry
Total request timeout 300 seconds

A fifth search never runs. The model then gets one chance to finish its answer from the results it already has.

Web Search Fields

Web Search accepts the tool fields both APIs define, but not all of them do something here.

OpenAI paths (Chat Completions and Responses)

Field What happens
web_search as a function name Reserved. A caller-defined tool with this name causes the request to be rejected.

Anthropic Messages

Field What happens
max_uses Accepted, but a value above 4 does not raise the limit.
allowed_domains, blocked_domains, user_location Accepted, but not enforced. Ask for domain or time limits in the prompt instead, and do not rely on that as a security boundary.

The rest of the request shape follows the API Documentation.

Citations and Sources

When search results shape an answer, the model includes source URLs for anything it took from the web.

  • Chat Completions puts source URLs in the assistant text.
  • Responses exposes lifecycle items and source URLs in the final text.
  • Anthropic Messages exposes web_search_tool_result blocks with result titles and URLs.

Source URLs must stay visible and clickable to end users, and must not be stripped in post-processing.

Web results can be incomplete, outdated, wrong, or malicious. A citation shows where something came from. It does not establish that the claim is true. Important claims should be checked against a primary source.

Error Handling

A search-provider failure does not necessarily fail the request. Where it can, the model finishes the answer and says Live search unavailable. It will not invent current facts or citations when search is down.

Provider failures include rate limiting, connection failure, timeout, an invalid provider response, and provider HTTP errors. On the Anthropic path a search-level error appears as:

{
  "type": "web_search_tool_result",
  "tool_use_id": "srvtoolu_...",
  "content": {"type": "web_search_tool_result_error", "error_code": "unavailable"}
}
Code Meaning
unavailable The search provider failed. The answer may be degraded.
max_uses_exceeded The four-search limit was reached.
mixed_tool_batch The model asked for a web search and a caller-defined tool in the same batch. The Anthropic API pauses the turn and searches on the next request; here the batch is rejected.
missing_web_citations The model used web results but could not produce an answer carrying source URLs.
not_ready (503) Web Search is temporarily unavailable. Retry, or check the Console for service status.

A client that disconnects from a non-streaming request receives 499, and the request is cancelled.

On Responses, a failed search shows as a web_search_call with a failed status. Chat Completions hides the internal error transcript and returns the recovered answer.

Usage Reporting

Each API reports search usage differently:

API Search visibility
Chat Completions Internal transcript hidden
Responses One web_search_call item per attempted search
Anthropic Messages Search blocks and usage.server_tool_use.web_search_requests

Data and Security

When the model searches, it writes a short query of its own and only that query goes to a third-party search provider. The prompt and the rest of the conversation do not. Even so, secrets, credentials and personal data should be kept out of any prompt that could turn into a search query.

  • Results count as untrusted content. Instructions inside them are not followed.
  • Excerpt and response sizes are capped.
  • Search queries, results, URLs, prompts and response text are kept out of Netpreme's normal application logs. That says nothing about what the search provider retains on its own side.
  • Provider-side safe search is off by default. It is not a content-moderation control.

Customers remain responsible for output moderation, legal compliance, and what their end users are allowed to do with the service.

See the Privacy Notice for the formal data-processing terms.

See Also

  • Inference for streaming, reasoning control, tool calling, and the Anthropic-compatible endpoint.
  • API Documentation for the full endpoint and parameter reference.