Web search
Myra AI Workspace augments model requests with live web search results. When web search is active, the gateway intercepts the outbound request, retrieves relevant search results, and injects them into the conversation context before forwarding to the model. No changes to client code are required beyond an optional request header.
Confirmation in chat
By default web search and its page fetches run without asking. A tenant admin can switch the confirmation on under Governance › Privacy › Web-search confirmation. Once it is on and a chat contains web content (a fetched page, a search result), the user approves the main websites once before pages open. While it is off, web tools ask nothing; tools of connected apps that write or send data still ask, and the conversation is still treated as containing outside content. The change is recorded in the audit log and, with config approval on, needs a second administrator.
With the confirmation on, a held page fetch is shown to the user as one Allow these websites? card that lists the main websites (no page addresses), including those of the current turn's search results. The user approves the websites they trust; pages on approved websites then open without asking for the rest of that conversation, and a website that was not approved still asks. The approval is stored per conversation and user, can be undone from the card, and is not cleared when the conversation receives outside content. See Chat tool confirmation API. Approving github.com also covers the api.github.com request the gateway makes to read a GitHub folder; if github.com is not approved, neither that request nor the page is sent.
How it works
Two-leg buffered flow (when the tool loop does not take the turn)
For most providers, web search uses a buffered two-leg flow whenever the gateway's streaming tool loop does not take the turn (for example the request brings its own tools, the model cannot call function tools, or the client declined tools): On every other turn these providers use the gateway's streaming tool loop (described under model-driven streaming below).
- Leg 1 (buffered): The gateway injects a
web_searchtool into the request and makes a non-streaming, buffered call to the provider. - Tool decision: If the model answers directly without calling the tool, the Leg 1 response is returned to the client as-is. No search is performed.
- Search: If the model calls the
web_searchtool, the gateway runs its search queries in parallel against the configured search provider (Linkup on new gateways, otherwise Brave or Linkup as set in the gateway). -
URL fetch: The gateway fetches up to two of the top result URLs in parallel and appends the page content to the search results. The same fetch is used when a message references a page directly (for example a bare domain such as
example.com/page). The fetch follows up to five HTTP redirects — so a bare domain that redirects to itswwwhost (or anyLocationredirect) still yields the real page rather than a redirect stub — and re-applies the SSRF safety check to every redirect target before connecting, so a redirect to a private, loopback, or link-local address is rejected. The URL itself is validated at that same gate before the first connection: a URL carrying a control character (a CR/LF, a tab, a NUL — the shape of a request-line or header injection) is refused outright as an unsupported address, never sent; percent-encoded bytes are sent as they are. A page that cannot be read returns a clear "could not read the page" signal to the model instead of empty content — and that signal names the website's condition, never a gateway fault: a login wall (401), a site that blocks automated access (403), a paywall (402), a missing page (404), a site rate-limiting requests (429), a server error (any 5xx other than 504 — "may work later"), any other refusal (400/405/410/422/451…, described as a refusal, not an outage or a content problem), a request the site rejects as too large (413), a redirect loop (over the five-hop limit, with the reason), a site that does not respond within the fetch deadline — or answers 408 or 504 — ("did not respond in time"), a connection or TLS failure on the remote side ("could not be reached"), a blocked address, non-text content, or a page larger than the 20 MiB fetch cap (reported as unreadable content, like a non-text page — the site answered, it was not unreachable). In every case the model is told what happened, told to relay it to the user, and told not to invent results. When a page is reduced to readable text, the content of<script>,<style>, and<noscript>elements is dropped — not merely their tags — so text a JS-enabled reader never sees (inline script source, CSS,<noscript>fallbacks) cannot reach the model as page content; an unclosed such element is dropped through to the end of the page (fail-closed). Search-result titles and snippets get the same<script>/<style>/<noscript>content drop, then simple tag removal (a tag ends at the first>and is removed without a space). For fetched page text only, a>inside a quoted attribute value of an element tag (a<followed by an ASCII letter (A-Z, a-z), or</followed by an ASCII letter; as in an Alpine or Vue handler such as@click="a > b") does not end the tag, so handler code does not appear as page text. This approximates browser attribute parsing: a quote opens a value only when the nearest byte before it that is not HTML whitespace (tab, line feed, form feed, carriage return, space) is=(any other quote is an ordinary byte); an unterminated value, a value whose closing quote is followed by any other byte than HTML whitespace,>or/, or values beyond 64 KiB per tag make the tag end at its first>exactly as before. An element tag with no>outside its accepted quoted values (or a rejected value in a tag whose first>sat inside an earlier accepted value) switches quote-aware reading off for the rest of that page, which then uses the previous rule, so the work stays linear. Only a tag in which every value-opening quote is accepted can hide more than the previous rule: its own quoted values, at most 64 KiB in total, plus its unquoted attribute bytes up to its real>.Documents (PDF, DOCX, XLSX). The top-two auto-fetch described here now also reads a linked PDF, DOCX, or XLSX among the search results, extracting its embedded text layer so the model can answer over the document — a PDF surfaced by the search is no longer skipped. To keep an interactive turn fast and off the inference fleet, the auto-fetch is text-layer only: it does not OCR. A scanned-image PDF (no text layer) contributes no text and is disclosed to the model (
N of M pages are scanned images…); a fully-scanned document returns a short "no extractable text layer — fetch it directly to OCR" marker. When the model instead fetches a URL directly (thefetch_url/agentic_fetchtools — a link it found, or one the user pasted), it additionally OCRs scanned pages. See Document fetch below.What the SSRF guard accepts and rejects. The fetch only performs an HTTP(S)
GETto a public address, and the web-search auto-fetch returns readabletext/*/HTML/XML content (application/xmlandapplication/*+xmlincluded, e.g. sitemaps; see the API reference for the exact accepted content types and the CDATA limitation for feeds) plus the extracted text layer of a magic-sniffed PDF/DOCX/XLSX (see the Documents note above); every other binary is unreadable. It rejects, fail-closed (the request is never sent), any of: a private, loopback, link-local, unique-local, or cloud-metadata address (127.0.0.0/8,10/8,172.16/12,192.168/16,169.254/16,::1,fc00::/7,fe80::/10, IPv4-mapped forms, and the0.0.0.0/unspecified address); any numeric IP encoding that resolves to one of those (decimal, octal, hex, shorta.b/a.b.cforms, and expanded/compressed IPv6); a URL carrying userinfo (user@host, which HTTP clients treat as the connect host); a hostname whose DNS answer includes any such address; any malformed authority; and a host name that can never resolve (an empty label, a label over 63 bytes, a name over 253 bytes, or a control, space or non-ASCII byte), which is refused before any DNS query is made and is treated as a name that does not resolve (an underscore is allowed). DNS names are resolved once and the fetch connects to that exact validated IP — it does not re-resolve the name at connect time, so a rebinding DNS answer that returns a public address to the check and a private address to the connect is defeated (the TLS SNI andHostheader still carry the original hostname, so certificate verification and virtual-host routing are unchanged). Each redirect hop repeats this resolve-and-pin. An operator allowlist (configured by your operator: exacthost:portentries, port required) is the only way to permit an internal address, and it never widens which port is reached. -
SSE status event: For streaming requests from a client that opted into the
aig_*side channel, anaig_statusevent is emitted before the URL fetch so the client can display a loading indicator. See SSE status event. - Leg 2 (streaming): The enriched results are injected into the conversation as tool results, and the final request is forwarded to the provider. Streaming is used if the original request requested it.
Your own function tools on a web-search turn
If the request brings its own function tools, they stay available throughout. Leg 1 offers your tools next to web_search. Leg 2 offers your tools again, with web_search withdrawn, so the model can still call one of them after reading the results. Your tool_choice is restored on leg 2, unless it forced a specific tool: a forcing tool_choice was already honoured on leg 1 and is dropped for leg 2, since the search results are what leg 2 needs to answer. If the model calls one of your tools on leg 1 beside the search, that call is not lost: the gateway runs the search and the model is asked again, with the results, so it can repeat the call. Only the gateway's own web_search calls are replayed into the conversation, and each one gets exactly one result message. See Your own tools on a web-search turn.
Google Gemini — native grounding
For Google Gemini, web search uses the built-in googleSearch grounding feature of Gemini. No search-provider call is made, and the api_key in the gateway config is not used for Gemini requests. The gateway automatically converts the web search instruction to the Gemini grounding format. This is a single-leg request with no tool injection.
Model-driven streaming (Myra / vLLM)
For Myra-hosted models (Qwen3, Gemma) served over vLLM, web search is handled inside the gateway's streaming tool loop rather than the buffered two-leg flow above. The gateway offers the model a web_search tool on the live streaming request; when the model calls it, the gateway runs the same search queries and URL fetch and feeds the results back into the same turn. There is no separate buffered Leg 1 — the tool call and the final answer stream in one loop.
A denied search or fetch is not retried in the same reply
When the gateway refuses web_search, fetch_url or agentic_fetch for a reason that cannot change within the reply (no egress allowed, an agent egress constraint of never, a tool policy floor or block), the tool is withdrawn for the rest of that reply (unless it is the only tool offered; then the reply ends with one final answer written without tools, from what it already has): the model is told once that it is not available and answers without it, and a repeat call is refused without contacting any service. A transient failure of the search provider does not withdraw the tool.
Per-turn cap and within-turn de-duplication
The streaming tool loop lets the model call web_search across many rounds in one turn, and smaller local models (Qwen3, Gemma) tend to over-call it — re-issuing near-identical low-value queries every iteration, which multiplies the paid search-provider (e.g. linkup) egress cost. Two controls bound this, on every turn the gateway's tool loop runs:
- Within-turn de-duplication — repeat and near-identical queries in the same turn (compared after lower-casing, collapsing whitespace, and trimming) are served from the first query's result. No second search is sent to the provider, so there is no duplicate cost, search card, or citation. Sub-second "freshness" between rounds is illusory, and the repeat is exactly the waste being removed.
- Per-turn cap (
max_searches_per_turn, default 8) — a hard ceiling on the number of distinct searches per turn. It sits well above typical legitimate research (roughly 2–6 distinct searches, since de-duplication already removes the near-duplicates) and well below the pathological fanout. When the cap is reached,web_searchis taken off the tools offered to the model for the rest of the turn (the other tools stay), so the model answers from what it has already gathered. A search call the model still makes receives a short notice instead of a result — "no longer available in this reply; answer from the results already gathered" — never a silent truncation. Ifweb_searchis the only tool offered, there is nothing left to offer: the reply ends at once with one final answer written without tools from the results gathered so far, with no stop note when that answer is delivered (if the model cannot produce it, the reply ends with a short note saying the tools were no longer available). Raisemax_searches_per_turnfor research-heavy workloads. The same setting also caps how manyweb_searchcalls the gateway takes from ONE model reply on every two-leg turn (including client-tools turns): extra calls in that reply are dropped and logged once, and the cap never exceeds 999.
These controls apply to every turn the gateway tool loop runs, not only to Myra / vLLM models. The one exception is the buffered two-leg flow, which the gateway uses only when its tool loop does not take the turn (for example the request brings its own tools, the model cannot call function tools, or the client declined tools): it issues its searches in a single leg and is unaffected.
Document fetch (PDF, DOCX, XLSX)
The gateway reads not only web pages but also PDF, DOCX, and XLSX documents, extracting their text so the model can answer over the document's content. This applies on two paths, which differ only in whether scanned pages are OCR'd:
- Direct fetch — the
fetch_urlandagentic_fetchtools, offered when a fetchable URL is present in the conversation (or co-armed with web search): reads web pages and documents, and OCRs scanned pages (up to the full 200-page / 300-second budget below). -
Web-search top-two auto-fetch (step 4): now also extracts a linked PDF/DOCX/XLSX, but text-layer only — no OCR, on a tight per-document budget (default 50 pages / 20 s, tenant-overridable via
url_fetch.auto_doc_max_pages/url_fetch.auto_doc_timeout_ms). A scanned page is skipped and disclosed (N of M pages are scanned images…); an all-scanned document returns a "fetch it directly to OCR" marker. This keeps every web search fast and off the inference fleet while still reading the common text-layer report/PDF; the model can always fetch a scanned document directly for OCR. The auto-fetch does not consume the model's per-turnfetch_urlbudget below. -
Type detection is by content, not by claim. The document type is determined by the file's magic bytes, never by the server's
Content-Typeheader or the URL's extension (both are untrusted and only used to reject spoofs). A URL ending in.pdfthat actually serves an HTML paywall is read as a web page; atext/html-labelled response whose bytes are a real PDF is read as a PDF. Only PDF, DOCX, and XLSX are extracted; images, presentations (PPTX), OpenDocument (ODT), archives, and other binaries are not, and return a clear "could not read" signal. - Bounded download. The document body is capped at 20 MB and fetched through the same SSRF guard (see step 4) with a fetch deadline. Larger files are refused rather than read.
- Scanned PDFs are read via OCR, and labelled low-confidence. A PDF with no embedded text layer (a scan or an image-only export) is transcribed page-by-page by an image-capable vision model, which reads the full page in one pass — the model is instructed to transcribe every table row verbatim rather than summarize or omit. Because OCR can still misread a figure or a date, OCR-derived text reaches the model labelled ("Read via OCR — may contain transcription errors; verify specific figures/dates against the source"), and the model is told to qualify figures it quotes from it rather than present them as authoritative. If a page was too dense to fully transcribe within the output budget, the label also says so.
- Long documents are read up to 200 pages, and truncation is disclosed. A fetched PDF is read up to a 200-page bound (raised from a previous silent 20-page limit); if the document has more pages than were read, the model is told explicitly ("only the first N of M pages were extracted; content on the remaining pages is missing") so it never confidently denies content that lies past the cut. The real ceiling on very large text is a byte cap on the extracted text: the per-call text budget of 10240 bytes (about 10 KB), the same for
fetch_url,agentic_fetchand a document auto-fetched after a web search. When it cuts a document, a gateway line says so — the first line inside thefetch_urlframe, above the answer foragentic_fetch, and the first line of that document's section (after its### Source (page tag <tag>):header) in a web-search result ("document text truncated – the extracted text exceeded the read limit on page K of Z; content after the cut is missing"; the page is named for a PDF only, when the extractor's page index locates it, and never in web-search auto-fetched results, which are shortened again as a whole; otherwise a PDF's line gives its page count). Foragentic_fetchthis line, and any page-cap note, appears in the answer the model receives, not only in what the inner model read. After a byte cut the line replaces the "only the first N of M pages" note, because the cut can fall inside the last page counted. Through thefetch_urlandagentic_fetchtool descriptions, the model is told to say that the answer covers only part of the document, and for a PDF to read further with apagesrange starting at the named page. Gateway-style lines inside a document's own text are neutralised, so a document cannot fake or contradict this notice. Page truncation and byte truncation are both reported. - Query-directed page range (
pages). When the answer lies on a later page of a long PDF (past the truncation cut), the model can callfetch_url/agentic_fetchagain with the same URL and apagesargument — a 1-based range"START-END"(e.g."110-125") or a single page"117"— to read only that window instead of always the first pages. The model picks the range from the document's table of contents (which is usually within the first pages it already read). The honored range is disclosed factually ("pages X–Y of Z shown", no "missing" clause).pagesapplies to PDFs only (DOCX/XLSX/web pages ignore it). A range that starts beyond the document, or contains no readable text, returns a served notice ("Requested pages start beyond … the N-page document") — not an error.pagesis untrusted model input: a non-string, reversed, zero, or malformed value is refused with an error the model can read and correct, instead of silently reading the first pages; an absent ornullpagesreads the first pages (see the API reference). - Each page is cleaned and capped at about 10 KB. Before a page reaches the model it is cleaned to plain text: menus (
nav,aside), the page-level header and footer, forms and buttons,svg,iframeand templates are dropped, character entities are decoded, control bytes are removed and runs of repeated lines are collapsed. The text served per page is then capped at 10240 bytes (about 10 KB) in total across all chunks — one shared budget, not 10 KB per chunk. The same budget applies to documents (PDF, DOCX, XLSX): the extracted text of a call, including apagesrange, is cut to it. It also covers theagentic_fetchinner-model input (formerly up to about 200 KB), the web-search auto-fetched pages (formerly 64 KB) and plaintext/plainfiles. The cut is disclosed like any other truncation, and a page longer than the budget has nonext_offsetat the budget: the last window ends "(end of the served page text)" and anoffsetat or past the served end returns the past-end line. The per-turn fetch count (below) is unchanged — only the text each page contributes shrinks. - Long web pages are paged, and truncation is disclosed. A web page or text file (HTML, a
text/*content type, or XML such as asitemap.xmlserved astext/xml,application/xmlorapplication/*+xml) is returned to the model in chunks of about 6000 bytes of the cleaned, budget-capped text (see the next item). When a page is longer, the result says so explicitly ("page text truncated – bytes 0–6000 of T shown; next_offset=N") instead of ending in a bare "…", and the model can callfetch_urlagain withoffset=Nto read the next chunk until "(end of the served page text)", which comes at the latest at the 10 KB page budget. On a gateway with agentic fetch enabled,agentic_fetchpages the same way: the inner model reads one chunk at a time (for a list it is asked to return every item of that chunk verbatim), the result carries the same notice withnext_offset, and the model pages on only when the request needs the whole page (lists, all items, counts). Each chunk then costs one fetch plus one inner-model call, and an inner answer cut at its output limit is disclosed rather than presented as complete. Chunks overlap by at least 256 bytes and end just after a space when one is within 512 bytes of the cut, so a space-separated list (e.g. sitemap URLs) is not split mid-item; text without spaces is cut mid-token (never mid-character). PII masking analyses each chunk together with about 256 bytes of the page text around it, so an identifier cut by a chunk edge is masked rather than shown as a fragment, whatever offset the model asks for. If the PII engine is unavailable while such a chunk is masked, the chunk (or an auto-fetched page longer than one chunk) is withheld and replaced by a placeholder unless the detector is explicitlyfail_open: trueand no PII mandate is in force (on a wholly-local model leg the normal tool-result outage rules apply). Limits: identifiers longer than 256 bytes, afail_open: trueforward during a PII-engine outage (recorded as a gap), and detectors that do not mask (see PII Protector). Each chunk counts toward the per-turn fetch limit below. A malformedoffsetis refused with a clear error before anything is fetched (see the API reference). An HTML page whose text is only script or style code (no prose, no<pre>/<code>/<textarea>) is refused rather than served, and an auto-fetched page like that is left out of the search result. The check judges the first 512 KiB of the page text: a page whose head is only code is refused even if prose follows later, and code that starts only after that head is not detected. - Per-turn limit. To bound extraction cost (a scanned PDF is OCR'd), the number of documents extracted in a single turn is capped (default 8, tenant-overridable via the gateway config
url_fetch.max_doc_fetches_per_turn— API-managed, no UI control; an invalid or non-positive value falls back to the default). On reaching the cap the model receives a short notice and answers from what it has, or asks the user to narrow the request — never a silent truncation. Note that a document-heavy turn is additionally bounded by the tool loop's own wall-clock budget: each document costs a fetch plus an extraction (up to minutes for a scanned PDF), so raising this cap far above the default mostly moves the bound to the wall clock. - Personal-data handling. Extracted document text is treated as untrusted bulk content and passes the same masking/injection-scan boundary as every other tool result before it reaches the model. The
agentic_fetchinner-model leg has no such central scrub, so it is guarded explicitly: under a PII mandate (apii_mandatoryproject, a forced agent invoke, or a tenant that enforces masking) on a gateway with no reversible masker configured, the fetched document is withheld from the inner model (fail-closed) — unless the inner model is a first-party local model, where nothing leaves the estate and the leg is not a mandate case (inside an agent-shaped run the inner leg is never local); otherwise the extracted text is masked/scanned before the inner model sees it. If that scan cannot run (PII engine outage) the document is withheld under a PII mandate — except when the inner model is a first-party local model, where the leg is not a mandate case — and otherwise the detector'sfail_opendecides; the inner leg's own request phase then scans the document again with its own locality and records any outage on the request — for every detector that phase runs (an enabled request-phase masker, an enabled injection classifier); a disabled or response-only one is re-run by nobody, so its fail-open forward at this seam is recorded as the gap it is.
Opening links found in the search results
The top-two auto-fetch inside a web search opens only the two highest-ranked result URLs (now including a PDF/DOCX/XLSX there, text-layer only); when the answer sits behind a link on one of those pages — a sub-page, a deeper document, or a scanned PDF that needs OCR — the model needs to fetch that link itself. To make that possible within the same turn, whenever the gateway web search tool is offered, the gateway also offers fetch_url / agentic_fetch — even when no URL was present in the conversation. The fetch tool is therefore already armed when the search results land, and the model can open a link it found in them.
- Only for the gateway search path. The co-arm keys off the gateway's own
web_searchtool being offered — the case where results come back as a tool result the model can read a URL from. It does not arm fetch for providers that run search server-side and fetch their own pages (Groqcompoundmodels, or a native-search provider such as Anthropic that is not forced onto the gateway two-leg). Under the EU residency floor those native providers are forced onto the gateway two-leg, so there fetch is co-armed. - Per-turn fetch limit. To bound fan-out, the total number of URL fetches in a single turn (web pages and documents combined) is capped (default 24, raised from 8 so a multi-source research turn — e.g. 14-20 pasted source URLs — completes without punting mid-task); the document-extraction sub-cap (default 8, above) still applies within that budget. Both caps are tenant-overridable via the gateway config
url_fetchsection (max_fetches_per_turn/max_doc_fetches_per_turn— API-managed, no UI control; invalid, zero, negative, or non-finite values fall back to the defaults, so a config typo can never uncap or brick the tool). On reaching either cap the model receives a short notice naming the effective limit and answers from what it has — the two caps produce distinct messages so a page fetch tripping the total limit never misreports a document limit. - Guards unchanged. Every co-armed fetch still passes the full execution boundary per hop: the SSRF/redirect guard, the outbound personal-data/secret exfiltration check (fail-closed), the residency re-check, and the untrusted-framing + injection scan on the fetched content. A
local_only(no-egress) workspace still blocksfetch_urlentirely, even with web search on.
Search-first behavior
When web search is enabled for a turn, the assistant is instructed to run the search directly rather than asking the user for permission first — enabling the feature is itself the go-ahead. The model still uses judgement: it skips the search for requests that plainly need no external information (greetings, rewriting or translating text you provided, or a follow-up answerable from the conversation so far). The tool is only offered (never forced), so a turn that genuinely needs no search is never made to run one.
The instruction also guards against a smaller-model failure mode where the assistant announces a search ("Let me look that up…") and then stops without actually calling the tool, or claims it checked a source and invents the result. When external information is needed, the model is told to emit the search call itself on the same turn rather than describe the search it would run; and it must not present anything as looked-up, checked, or verified unless a tool actually returned it (that turn or earlier in the same conversation). Answering from the model's own stable knowledge — without dressing it up as a lookup — remains allowed.
Query length
A search query longer than 2,048 bytes is rejected: it is never shortened, and nothing is sent to the search provider. The limit counts bytes, not characters, so multibyte characters (umlauts, euro signs, emoji) use it up faster. It applies to both search paths.
- Gateway two-leg search. One over-long query withholds every search in that reply. The model gets a tool error that names the byte count of the over-long query and the limit, is told that no search in the reply was sent, and is asked to search again with shorter queries.
- Client-tools / tool-loop search. The model gets a tool error that names the byte count and the limit and asks for a shorter query; other searches in the same turn are not affected. A rejected over-long query does not count towards
max_searches_per_turn.
Personal data in the search query
The model-generated search query is scrubbed before it egresses to the search provider. Redaction placeholders the model wrote into the query are removed on every gateway. Protected terms are removed wherever the tool-result scrub applies a Custom PII detector (or your personal keywords); detected personal data is removed only on a gateway with a pii_protector detector. In detail, every detected personal-data entity, every protected term (your personal keywords and the keywords of the Custom PII detectors that apply) and every redaction placeholder the model wrote into the query — bracketed or bare, in any letter case — is removed from the query, and the rest of the query is tidied up. After removal, leftover words that contain no letter or number (punctuation, lone combining marks, symbols, emoji) are dropped; if nothing with a letter or number remains, no search is sent and the tool reports that it was skipped. The search backend (Brave or linkup) — and the X-Web-Search-Query response header, the logs, and the trace — only ever see this cleaned query: no personal data and no placeholder. The final answer is restored to the real values before it reaches the user.
If nothing meaningful is left after the removal — the query consisted only of protected terms or placeholders — no search is sent at all. The model receives a short "search skipped" result that says the query contained only protected terms, and the skipped query does not use up the turn's search allowance. If the check of the query itself fails, the search is withheld rather than sent.
This applies to the gateway two-leg flow. Provider-native search (Anthropic, Gemini, and others that run the search on their own server) is covered by this scrub only when it is forced onto the gateway two-leg under the EU residency floor (see EU data residency); otherwise the query reaches the provider search backend without the gateway scrub.
Placeholder removal needs no detector. Protected-term removal needs a Custom PII detector or personal keywords that apply to the gateway; detection of personal data (names, addresses, identifiers) needs a pii_protector detector. A gateway with none of these has nothing to remove except placeholders.
Under a PII mandate (a pii_mandatory project, or a tenant with masking enforced) the query scrub applies the German PERSON / LOCATION floor whatever the detector's language says — including on a gateway whose every model is first-party (local-only), where the model leg itself is exempt from the mandate: the query's bytes leave for the search provider, so the exemption stops at the model leg. Such a request records the pii_egress_floor_forced_by_mandate marker in its log (unless the detector's language already keeps the floor — anything but explicit English — where it was already on); the cost is that a place name in an English query is removed from the query sent to the search provider.
⚠️ Caution: Under a PII mandate — a
pii_mandatoryproject, a forced agent invoke, or a tenant that enforces masking (an unresolvable project tier blocks every egress tool outright, one step earlier) — a gateway that cannot tokenise the query (nopii_protector) withholds the search rather than sending it, and the model is told the workspace requires personal-data masking (the same wording on both search engines — the older engine used to claim a "PII scan failed"). When the PII scan is unavailable, the outcome depends on whether a PII mandate is in force: under a mandate (apii_mandatoryproject, or a tenant with masking enforced — including a local-only gateway, whose model leg is exempt but whose query still leaves) the search is withheld whatever the detector'sfail_opensays, and the request recordspii_mandate_masker_unavailable. Outside a mandate the detector'sfail_opendecides:false(the seam's default) withholds the search and the reply reports that web search is unavailable;trueforwards the query with at most the offline structured-ID masking applied (German IDs and, where enabled, Danish identifiers) — and that forward is recorded on the request as a guardrail gap (guardrail_degraded,pii_scan_degraded,guardrail_error) once the search actually leaves: on a multi-query turn where a later query is withheld, every query is withheld and nothing is recorded as a gap.
Supported providers
The web search mechanism depends on the provider.
Native search:
- Anthropic (native endpoint) — the provider runs the search server-side. It starts on the
X-AIG-Web-Search: 1header, or on every request when the gateway's search mode isalways. - Google Gemini — native grounding, a single leg with no tool injection.
- Google Vertex AI — native grounding, the same single-leg mechanism as Google Gemini (Vertex hosts the same Gemini models).
Gateway tool loop — web search next to the other tools:
On every turn the gateway's tool loop runs — a chat in the web app (inside or outside a project), an agent run, an API request that brings no tools of its own — the OpenAI-style providers listed below and Mistral get the gateway's own web_search tool next to the turn's other tools (files, the code interpreter, image generation, connectors). One turn can therefore search and then act on the results, for example research a topic and turn it into a PowerPoint file. The model decides whether to search. Myra models always use this path (see below).
Two-leg agentic loop (tool injection) — only for a request the tool loop does not handle: one that brings its own tools, one whose model cannot use function tools, or a call that is not a chat completion. Leg 1 offers the model only the web_search tool and the turn ends after the search:
- OpenAI
- DeepSeek
- Cerebras
- Together AI
- Fireworks
- xAI
- HuggingFace
- SambaNova
- NVIDIA
- IONOS AI Model Hub
- Azure OpenAI
- Cloudflare Workers AI
Mistral Agents path:
- Mistral — a request that brings its own function
toolsruns the gateway two-leg on chat/completions, whether or not search is forced, so those tools stay available (see Your own tools on a web-search turn). Only a request without client tools that the tool loop does not handle (the same cases as the two-leg loop above) is routed to the Mistral Agents endpoint (/v1/conversations), which carries no function tools. Every other Mistral turn uses the gateway tool loop above.
Server-side plugin:
- OpenRouter — web search runs server-side via OpenRouter's default web plugin. OpenRouter uses the underlying model's native search when it is available and otherwise falls back to its own web search, so every routed model gets working web search without a gateway two-leg loop. It starts on the
X-AIG-Web-Search: 1header, or on every request when the gateway's search mode isalways.
Model-driven streaming:
- Myra (vLLM-backed) — Qwen3 and Gemma models get web search through the gateway's streaming tool loop (see Model-driven streaming (Myra / vLLM) above).
Not supported:
- AWS Bedrock, Cohere, and Groq models.
💡 Note: For Cohere and Groq, a request with web search enabled returns the
web_search_not_supportederror. For AWS Bedrock, the request proceeds without web search.On the two-leg loop,
web_search_not_supportedis returned only when the selected model itself refuses the search tool. Any other failure of the first leg (a rejected API key, a rate limit, a provider outage, an oversized context) is handled like the same failure without web search: the request continues on the normal path with its retries and fallback models, and the client receives the matching error. A refusal from a fallback model does not count as a refusal of the selected model.
Model searches on its own:
- Perplexity (direct) — the gateway adds no web search tool of its own and the web search setting has no effect. Perplexity Sonar models search the web on their own, so the answer can still contain live results; the request never fails with
web_search_not_supported. This is the "Perplexity Sonar: built-in" hint on the Playground web search toggle. On a run that has processed outside content, the gateway changes this: it switches the model's search off, or forsonar-deep-research, which has no such switch, holds the call for approval on an agent run and otherwise refuses it withinherent_search_blocked(403). See Models that always search the web. Perplexity models routed through OpenRouter use the server-side plugin above.
💡 Note: The search backend for the two-leg and streaming flows above is pluggable via
web_search.provider: Brave Search (the default) or linkup.so (EU-based; SOC 2 II, Art. 28 DPA, zero-retention — the EU-sovereign option for a residency-enforced gateway). Only linkup queries are metered into the tenant's spend and budget cap (each successfully-answered query draws down the same allowance as model usage); Brave queries are not currently metered. The linkup per-query price is amodel_pricecatalog row (provider='linkup', model='web_search',input_per_1k = 10.0=$0.01/query), editable on the Model prices page (Platform › Models & providers); a deployment default applies as the fallback when that row is absent. See web-search cost.
Result language
The gateway detects the language of the user's own words in the latest message server-side (the same detector that pins the reply language — text attached or pasted into the turn is set aside first, so an English question about a German document searches in English; when the user regenerates an answer with a reason, the message that answer replied to, not the reason; when that message is too short or technical to judge, the language of the conversation so far) and, for Brave searches, sends Brave's language/region targeting so results come back in the asked language rather than the language of the ambient context:
search_lang— the content language (ISO 639-1:de,en,fr,nl,da).ui_lang— the response-metadata language (de-DE,en-US,fr-FR,nl-NL,da-DK).country— a 2-char region, sent only where it is derivable from the language (DE/FR/NL/DK). English is left without acountry(it spans many regions; Brave defaults toUS) —search_lang=enalready pins the result language.
Detection is precision-biased and fails open: if the message language is ambiguous or unsupported, no language parameter is sent and Brave uses its default behaviour (exactly as before this feature). Only the five supported languages (German, English, French, Dutch, Danish) steer the search; Norwegian and Swedish messages are not steered (see Reply language).
linkup has no request-level language or country parameter, so its results cannot be pinned this way; the lever for linkup is the reply-language directive, which makes the model answer in the question's language regardless of the source language of the results.
Requests without external egress
A request that is not allowed to reach external services never uses a provider's native web search either. That covers a local-only (Tier 1) project, the public documentation chat, and a direct agent invocation sent with the x-aig-no-egress: 1 header. On such a request the gateway removes every provider-native search element before the call leaves, whatever the client sent: Anthropic's server-side search tool and its beta flags, remote MCP servers on an Anthropic call, the OpenRouter web plugin and :online model suffix, OpenAI-style web_search_options and search_parameters, Groq's browser search tool, and Gemini and Vertex grounding. The model answers without live web results. On Anthropic, a native search block replayed from an earlier turn is folded into plain text instead of being sent back as a search call.
When the client had asked for native search and the gateway removed it, the request log entry carries aig_native_search_refused with the value egress_blocked, and the response carries the X-AIG-Web-Search-Notice: not_run header with the reason egress_blocked (see When a requested search cannot run). Which tools survive depends on the provider. On OpenAI-compatible providers the gateway keeps tools of type function or custom, and an entry without a type that carries a function definition; every other entry is removed, including provider-hosted tools such as Groq's browser_search and unknown types. On Anthropic it keeps client tools (no type, custom, or function) and the client-executed and sandbox tools (bash, text editor, computer, memory and code execution); every other server tool is removed, which covers search, fetch, the MCP toolset, tool search and unknown or future types. On Anthropic the top-level MCP connector servers and the web-search, web-fetch and mcp-client beta flags (matched case-insensitively) are removed as well. A tool_choice that names or restricts removed tools is dropped with them, and when no tool is left, tool_choice and parallel_tool_calls are dropped too so the provider does not reject the request. Search that is built into the model itself (Groq compound* models, Perplexity sonar* models and *-search-preview models) is not a request element; it is handled separately, as described below.
Models that always search the web
Some models search the web on every call and cannot be told not to: OpenAI gpt-4o-search-preview, gpt-4o-mini-search-preview and gpt-5-search-api, the Perplexity Sonar models, and the Groq compound models. Such a model cannot honour the no-egress rule by dropping a tool, so on a request without external egress the gateway handles it in this order:
- Switch to the sibling. Where the model has a non-searching sibling (
gpt-4o-search-previewusesgpt-4o), the call goes to the sibling. - Switch search off. Where the provider offers a switch (Perplexity direct, except
sonar-deep-research), the call is sent with search disabled. - Refuse. Otherwise the call is refused with
inherent_search_egress_blocked(403) and nothing is sent to the provider. No approval can lift this refusal. An unlisted model id that names a known searching family (search-preview,sonar,deep-research, Groqcompound, including fine-tunes of them) is refused as well.
The request log entry carries aig_native_search_refused with the value egress_blocked, as for removed search tools.
EU data residency — forced gateway search
The gateway's own web search (the two-leg agentic loop) can run against an EU-sovereign search provider — linkup.so (France; DPA, zero-retention). Provider-native search (Anthropic's server-side search, OpenRouter's web plugin, Gemini/Vertex grounding, Mistral Agents) instead egresses the model-generated search query to the provider's own (non-EU) search backend, which breaks an EU-residency commitment. On a non-enforced gateway this native egress is not blocked but it is no longer invisible: it records a non_eu residency-evidence leg for the data-localization report — see EU data residency — search-egress jurisdiction.
To keep the query inside the EU, the gateway forces gateway search — it disables provider-native search tools and knobs and routes web search through the gateway's own (linkup) two-leg — when either:
- the gateway's EU residency floor is armed (
eu_region_routing, or the inherited tenant floor / deployment default); or - the gateway is configured with an EU search provider (
web_search.provider: "linkup").
A gateway configured with a non-EU provider (brave) and not enforced keeps provider-native search unchanged — forced gateway search has zero effect on non-sovereign deployments.
Under forced gateway search:
- Anthropic, OpenRouter, and Mistral models run web search through the gateway's linkup two-leg (they support the gateway tool loop). Any client-supplied native search tool (
web_search_20250305, the OpenRouterwebplugin or:onlinemodel suffix, OpenAI-styleweb_search_optionsandsearch_parameters(xAI live search)) is stripped from the outbound request. - Gemini / Vertex and a raw
/v1/messages(native Anthropic SDK / Claude Code) client have no gateway two-leg path, so web search fails closed — it is disabled rather than egressing to a non-EU backend. No search runs; the answer is produced without live web results.
The stripped native paths are the per-request search tools and knobs: Anthropic's web_search_20250305, the OpenRouter web plugin and :online model suffix, OpenAI-style web_search_options and search_parameters (xAI live search), and Gemini/Vertex grounding. Search that is intrinsic to a model slug (for example gpt-*-search-preview, Groq compound, Perplexity sonar) runs on the model's own server regardless of tools — such a model is guaranteed off only under the enforced residency floor, where the model itself is dispatch-blocked as a non-EU provider. On a gateway that only configures an EU search provider without arming the floor, those models still reach their (non-EU) backend for the whole request, so pair the EU search provider with the residency floor for full sovereignty.
Configuration
Web search is configured at the gateway level under config.web_search.
The Web Search section of the gateway settings page
{
"config": {
"web_search": {
"enabled": true,
"api_key": "BSA...",
"max_results": 5,
"mode": "opt-in",
"default_freshness": "pw"
}
}
}
| Field | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | false |
Enables web search on this gateway. Only the JSON boolean true switches it on. Absent, null and false leave it off; any other value (a string such as "1" or "true", a number, an object or an array) is refused with 400 invalid_web_search when you save the gateway. A gateway that nevertheless carries such a value (saved earlier) is treated as disabled (fail-closed) and the gateway logs a warning. |
provider |
string | "brave" |
Gateway search backend: "brave" (US) or "linkup" (EU-sovereign). Configuring "linkup" forces gateway search over provider-native search (see EU data residency). Omit it (or send JSON null) to inherit the tenant default (web_search_provider); see below. Any other value, including a non-string such as a number, boolean, object or array (which is invalid, never treated as Brave), is rejected with 400 web_search_provider_unknown when you save the gateway; a gateway that nevertheless carries an unsupported provider (saved earlier) has web search disabled — the tool is not offered and the gateway's web_search_provider_invalid flag is true (exception: on a tenant with EU data residency armed, an unsupported stored provider is replaced by the tenant's EU default, "linkup", so search stays enabled). |
api_key |
string | — | Search provider API key (Brave or linkup). Required for Brave. Optional for Linkup when a platform Linkup key is configured (see Default on every new gateway); an explicit key always takes precedence. Not used for Google Gemini. |
max_results |
integer | 5 |
Maximum number of search results to retrieve per query. Applies to Brave only; Linkup ignores it. The gateway settings accept 1 to 20. |
max_searches_per_turn |
integer | 8 |
Maximum number of distinct web searches the model may run in ONE turn of the gateway tool loop. Repeated/near-identical queries within a turn are de-duplicated (served from the first result, not re-fetched). On reaching the cap the model receives a notice and answers from the results already gathered. Raise it for research-heavy workloads. It also caps the web_search calls taken from ONE model reply on every two-leg turn (extras dropped, logged once; never more than 999). |
mode |
string | "opt-in" |
Controls when web search is triggered: exactly "opt-in" or "always" (case-sensitive). Omit it or send null for "opt-in". Any other value ("ALWAYS", a number, an object …) is refused with 400 invalid_web_search; a stored unrecognised value behaves as "opt-in" and the gateway logs a warning. See Modes. |
default_freshness |
string | — (unset → unfiltered) | Default recency window applied server-side when a request sends no x-aig-web-search-freshness header. Accepts the same values as that header: pd / pw / pm / py (past day/week/month/year) or an explicit inclusive range YYYY-MM-DDtoYYYY-MM-DD. Any other value is ignored (fail-closed → no narrowing from this source). Unset by default, so older/historical results are never silently excluded; set it only for a gateway whose queries are predominantly time-sensitive. A valid per-request header always overrides it. Brave only — the linkup adapter does not apply a recency window. |
Tenant provider default
A tenant carries a web_search_provider default (brave | linkup, set via
PATCH /admin/v1/tenants/{id} — see Tenants API).
A gateway that has a web_search block but sets no provider of its own inherits that
tenant default; a per-gateway provider overrides it. Under an armed EU residency floor
(eu_region_routing), a non-EU per-gateway provider is clamped up to an EU tenant
default (so a sovereign tenant's gateways cannot silently sit on Brave), while a gateway may
still choose another EU provider. The tenant default never enables web search on a gateway
that has no web_search block, and the gateway's api_key must match the effective provider.
Default on every new gateway (platform Linkup key)
Every new production gateway — created at self-service signup (trial or paid) or by an
administrator — starts with web search enabled via Linkup and no key of its own. You do
not need to supply an api_key: when a platform admin has configured the shared platform key
(the setting trial_linkup_api_key — the name is historical, it applies to every plan), the
gateway serves web search through the EU-sovereign Linkup backend. The key is injected into the
gateway's web_search config at read time, is never stored on the gateway, and is
never returned to any client. A gateway that already carries its own web_search block when it
is created (your own Linkup or Brave key, another provider, or an explicit enabled: false) keeps
it exactly as supplied — the default is never forced over a deliberate choice.
If the platform key is unset, such gateways show web search as set up but not available (the composer shows a notice), the Health dashboard flags Platform web-search key: MISSING, and the platform is alerted — nothing is silently off. Setting the key from the admin console takes effect within about a minute for every affected gateway, with no redeploy and no backfill. It was formerly a deployment setting and formerly applied to trials only.
A trial that converts to a paid plan keeps its web search unchanged. To use your own
Linkup or Brave account instead of the platform key, set the gateway's web_search.api_key (and
provider) — an explicit key always takes precedence.
In the gateway settings (Organisation › AI setup › Gateways › ‹gateway› › Settings › Search & tools), the key field says whether a key is needed for the provider you chose:
- No key needed — the provider resolves to Linkup (you chose Linkup, or Organisation default and the organisation's default is Linkup) and the platform Linkup key is set. Leave the key empty; enter one only to use your own Linkup account.
- Organisation default, but none set — the gateway would use Brave, which needs your own key. Choose Linkup, enter a Brave key, or have a platform administrator set the organisation's default under Organisation settings › Routing (the form links there for a platform administrator).
- Platform key not set — the provider resolves to Linkup but the platform Linkup key is not configured, so enter your own Linkup key.
When a key is needed and the field is empty, saving is refused with "An API key for the selected search provider is required to enable web search." The check only applies when you change the checkbox, the key or the provider in that edit, so an unrelated edit never trips it.
Modes
| Mode | Behaviour |
|---|---|
"opt-in" |
Web search triggers only when the client includes the X-AIG-Web-Search: 1 request header. Only 1, true, yes and on enable it; any other spelling or casing (for example TRUE), 0, no, off, an empty value, garbage, or a repeated header leaves search off. The same reading applies to the response-cache key and to every provider path, so a malformed value can never send a query out. |
"always" |
Web search is attempted on every request through this gateway, regardless of client headers. On Anthropic the gateway adds the provider's own web search tool and on OpenRouter the web plugin, with no X-AIG-Web-Search header needed; Myra and vLLM models search through the gateway tool loop. A request that sends X-AIG-Web-Search: 0 still searches. A request that declines all tools (tool_choice none) does not. |
Getting a Brave Search API key
Obtain a Brave Search API key from the Brave Search API developer portal. For the current plans and query limits, refer to that portal.
💡 Note: For Google Gemini, web search uses the built-in
googleSearchgrounding feature of Gemini rather than Brave Search. Theapi_keyin the gateway config is not used for Gemini requests. The gateway automatically converts theweb_searchtool to the Gemini grounding format.
Request and response headers
Client opt-in header (required when mode is "opt-in"):
Client recency header (optional):
Narrows results to a recency window: pd / pw / pm / py (past day/week/month/year) or an explicit inclusive range YYYY-MM-DDtoYYYY-MM-DD. Any other value — including an empty string — is ignored (fail-closed → unfiltered). When the header is absent or invalid, the gateway falls back to the per-gateway default_freshness knob (itself unset by default → unfiltered). A valid header always wins over the gateway default. Brave only — the linkup adapter does not apply a recency window.
Response header (always set when a search is performed):
When a requested search cannot run
In the cases listed in the table below, a request that asks for a web search either gets one or is told plainly that none ran.
A request asks for a web search through the X-AIG-Web-Search: 1 header, or because the gateway's search mode is always. When the search did not run, the gateway says so. In some cases it hands the search over to its own tool loop, which then offers the model a web_search tool. The loop does not run for every request. It is skipped when the request brings its own tools (the gateway passes those requests through), when the call is not a chat call the loop handles (for example a native /v1/messages call on a Myra model), when the provider has no tool loop (Gemini, Vertex), or when the model cannot use tools. When one of the hand-overs in the table lands on a request the loop will not take, no search runs and the gateway says so. A notice is only ever sent when the search really did not run for that request.
A provider whose own search runs (Anthropic, OpenRouter, Gemini or Vertex grounding, or a model with built-in search) sends no notice, because the search did run.
The notice is a response header:
The same turn's request log carries aig_web_search_not_run in its metadata, with the reason the search did not run. If more than one applies, the first reason wins:
| Reason | When the search did not run |
|---|---|
forced_native |
Anthropic, on a gateway that forces its own search provider (the native Anthropic search is removed). Typical case: the request brings its own tools, or it is a native /v1/messages call with stream: true. |
forced_plugin |
OpenRouter, on a gateway that forces its own search provider (the OpenRouter web plugin is removed), on a request that cannot take the two-leg flow (for example a request with its own tools on a path other than chat completions). |
forced_grounding |
Gemini or Vertex, on a gateway that forces its own search provider (Google Search grounding is removed). These providers have no tool loop, so no search runs. |
forced_agents |
Mistral, on a gateway that forces its own search provider, on a request the tool loop does not take. |
legacy_functions |
The request brings its own tools through the legacy OpenAI functions array. The client owns the tool loop, so the gateway adds no search tool next to functions. This blocks the gateway's own two-leg search, the gateway tool loop (vLLM / Myra models), Mistral agents search and the forced OpenRouter plugin. On Anthropic models (and the Mistral Agents leg) the request is refused with 400 invalid_request before any search runs, because those providers cannot carry functions (see Inference API). The unforced OpenRouter plugin is not blocked: it adds no tool to tools (OpenRouter receives the client's functions unchanged and runs its web plugin server-side). Use tools instead of functions for a request that should get a gateway search. |
client_tools |
The request brings client tools (or legacy functions) and the model's provider (Gemini, Vertex, Bedrock, Cohere) cannot carry them. The request is refused with 400 invalid_request (see Inference API), so no search runs. A web-search marker alone (an entry with name: "web_search", no function or parameters key, and type absent or starting with web_search) is not a client tool on Gemini and Vertex, where grounding consumes it and serves the request; on Bedrock and Cohere it is refused too. |
gateway_tool |
A Myra / vLLM model (its search always runs in the tool loop), on a request without its own tools that the loop does not take (for example a native /v1/messages call, or a model without tool support). |
not_chat_completions |
A Myra / vLLM model, on a request that brings its own tools on a path other than chat completions (for example /v1/messages), where the two-leg flow is not used. |
tainted |
The run was started by untrusted content, so the gateway does not run its own search for it. The search is left to the tool loop, which holds each call, and the loop does not take this request. |
project |
The turn belongs to a project and brings no tools of its own, and the tool loop does not take the request (for example on Gemini or Vertex, or a native /v1/messages call on a Myra model). |
egress_blocked |
The request is not allowed to reach external services (a local-only project, the public documentation chat, or x-aig-no-egress: 1), so no search of any kind ran. |
not_configured |
The request asked for a search, but the gateway has no search provider configured (no API key). |
native_unsupported |
The request asked for a search, the model is outside the provider's native-search matrix and the gateway does not force its own search. |
no_mechanism |
The request asked for a search, but no search mechanism exists for this provider. |
probe_failed |
The first model call of the two-leg flow failed (not a refusal of the search tool), so the turn went on without it, on a request the tool loop does not take. |
The header and the metadata are the signal on every path; when the response headers have already been sent (a streamed agent run), the request log metadata is the signal. The in-band frame {"aig_status":"web_search_notice","reason":"not_run","cause":"<reason>"} appears in addition for a client that opted into the aig_* side channel (send X-AIG-Extensions: 1; the web app does). It is sent once per response, on a streamed answer at the end of the stream, and on a buffered answer that is re-emitted as a stream. cause is one of the reasons in the table above. A JSON response, a streaming passthrough that carries no aig_* frames, and a native /v1/messages stream carry the header only. The notice is not an error: the turn proceeds and the answer is delivered, it just carries no fresh search. A browser client reads the header through CORS, since it is in the exposed headers list.
The web app shows a chip under the answer for the live session only (it is not kept when the conversation is reloaded). The chip text depends on the cause: no access to external services, no search provider set up for the gateway (a gateway admin can add one), not available with this model in a project, the selected model cannot search the web here, or a general "Web search did not run for this answer." for every other reason and for any value the app does not know.
| Transport | Header | Request log metadata | In-band frame |
|---|---|---|---|
| JSON response | yes | yes | no |
Native /v1/messages or passthrough stream |
yes | yes | no |
Streamed answer, client opted into aig_* |
yes | yes | one web_search_notice frame with cause |
Buffered answer re-emitted as a stream, client opted into aig_* |
yes | yes | one web_search_notice frame with cause |
| Streamed or re-emitted answer, plain client | yes | yes | no |
The header is present whenever the response headers have not yet been sent.
Response cache: a request that is blocked from external egress is never answered from the response cache, and a turn on a gateway in mode always that has no search key is no longer cached, so a cached answer never stands in for a search that did not run.
Result dates
When the search backend reports a result's publication / last-seen date (Brave's page_age / age), the gateway surfaces it to the model on an as of <date> line in the search-results listing, and labels the corresponding fetched page in the ## Page Content section as ### Source (page tag <tag>): <url> (as of <date>). The <tag> is a random value drawn for each block of appended pages, and the result names it, so a fetched page's own ### Source: lines are recognisable as page text rather than another source. This lets the model judge how current each source is instead of guessing. The date string is third-party content, so it is treated as untrusted: any markup, newlines, and control characters are stripped and the value is length-clamped before it reaches the model. linkup results carry no per-result date, so no as of line is shown for them.
SSE status event
For streaming requests from a client that opted into the gateway's aig_* side channel
(x-aig-turn-id, as the chat UI always sends, or x-aig-extensions: 1), the gateway emits an
aig_status server-sent event (SSE) before fetching URL content. Clients use this to display a
loading indicator. A plain OpenAI-compatible client receives a pure OpenAI stream and none of
these events — see
Inference — what a plain client receives.
The count field indicates the number of URLs being fetched.
Live search results (web_search_results)
For streaming requests from a client that opted into the aig_* side channel, the gateway emits a web_search_results event immediately after each
successful web_search — both on the tool-loop path (Myra-hosted models) and on the
Anthropic-native path (Claude models run the search server-side and stream a
web_search_tool_result block) — so the client can render the live "Searched the web" card
(query line + a source list) identically on either provider:
data: {"aig_status": "web_search_results", "query": "bitcoin price today USD", "count": 3, "results": [
{"title": "CoinMarketCap", "url": "https://coinmarketcap.com/"},
{"title": "Coinbase", "url": "https://www.coinbase.com/"},
{"title": "Yahoo Finance", "url": "https://finance.yahoo.com/"}
]}
queryis the original search query (the card headline).resultsis capped at 10 entries; each carries a length-clampedtitleand anhttp(s)url(the client derives the display domain from the URL). Consumers must treat every field as untrusted input and ignore or clamp malformed entries. Length clamping is UTF-8-aware — atitleorquerythat exceeds its byte budget is truncated on a character boundary, never mid-codepoint, so the persistedutf8mb4blob is always valid (a byte-split multibyte character would otherwise reject the whole turn's write).- The event is emitted only on streaming turns to a client that opted into the
aig_*side channel; a buffered turn (agent invoke, playground preview) omits it, and so does a plain OpenAI-compatible client's stream. A search that returned no results emits no event. - The per-query steps are also persisted on the assistant message, so the collapsed "Searched the web" disclosure rehydrates identically on conversation reload.
Enabling web search on a gateway
Proceed as follows to enable web search on a gateway:
-
Send a
PATCHrequest to/admin/v1/gateways/{id}with theweb_searchconfiguration block.curl -X PATCH "https://<your-gateway-host>/admin/v1/gateways/{id}" \ -H "Cookie: aig_admin=<SESSION>" \ -H "Content-Type: application/json" \ -d '{ "config": { "web_search": { "enabled": true, "api_key": "BSA_your_brave_key", "max_results": 5, "mode": "opt-in" } } }'- The gateway configuration is updated immediately.
-> Web search is active for all subsequent requests through this gateway.
Making a search-augmented request in opt-in mode
Proceed as follows to send a search-augmented request when mode is "opt-in":
-
Include the
X-AIG-Web-Search: 1header in the client request.curl -X POST "https://<your-gateway-host>/v1/myapp/prod/openai/chat/completions" \ -H "x-aig-token: <token>" \ -H "X-AIG-Web-Search: 1" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "What is the latest news about AI?"}], "stream": true }'- The gateway runs the two-leg agentic flow and injects search results before the final model call.
-> The model response includes context from live web search results.
⚠️ Caution: Not all models support tool use. Web search requires the model to support tool/function calling. If the model does not call the tool, the Leg 1 response is returned directly and no search is performed.
Runs that handle untrusted content
An agent run started from content an outsider controls (an inbound email, a webhook payload or a form submission) carries an untrusted-content mark. On such a run web_search, fetch_url and agentic_fetch are not executed on the model's say-so: each call is held for the credential holder's approval, and nothing is searched or fetched until it is approved, unless the agent is grandfathered and the mark is not strict (see Untrusted content holds). The search the gateway would run before the model answers is skipped. Google Gemini and Vertex have their search built into the model call (native grounding), so on an agent run that call is held for approval before anything is sent: the approval reads "The model chooses its own search queries. They are sent to Google's search backend and are not shown to you in advance." Approval covers one grounded call; rejecting it or letting it expire ends the run with native_grounding_rejected and nothing is sent to Google. Where no run can hold the call, grounding is simply switched off for that call: the call itself still goes out, without search, and nothing is recorded. If a hold was attempted but could not be created or saved, or the client had already disconnected, the call is refused and recorded as native_grounding_blocked. A gateway set to an EU search provider, or one that enforces EU residency, does not use Google's grounding at all: it runs the gateway's own two-leg search and nothing is held. A Gemini or Vertex search the model ran on its own marks the run only when the response shows grounding; a complete response that finished normally (STOP) with no grounding metadata does not. Routes without a response check (the OpenRouter web plugin, OpenAI web_search_options, the Mistral agents search and the Anthropic raw /v1/messages streaming relay) are always marked. A non-streaming /v1/messages response is read like any other Anthropic response: a web_search block, or anything unreadable or unknown, marks the run; a complete text-only answer records no search. Approval covers one call; paging through a document with pages or fetching another URL needs a new approval. See Untrusted content holds.