Skip to main content

Three different search integrations

Responses represents native tools / tool_choice. The upstream must support the selected tool and model; the gateway does not implement search for arbitrary models. Chat’s conditional web_search_options uses a different structure. OpenRouter’s :online suffix, plugins search fallback, and server-tool catalog are not gateway-wide contracts here.

Tool selection and results

The example requires explicit API_SEARCH_TOOL. The command uses web_search_preview, for which the project has dedicated handling. Select current upstream web_search only after confirming deployment support. Their parameters and capabilities differ; the script does not downgrade or retry. Native forwarding alone does not establish complete call accounting or billing semantics for a new tool name across channels; the deployment must verify those. This guide makes no price or free-quota promises. tool_choice: required requests tool use. The example additionally requires at least one completed web_search_call and URL citation. This is an example acceptance condition, not a claim that all uncited Responses results violate the protocol. Prefer a verified native Responses path; conversion does not guarantee preservation of built-in search or citations. Each message’s output_text.annotations can contain url_citation with url, title, start_index, and end_index. The script retains offsets beside their original text block instead of applying them after merging text. Interfaces should preserve clickable sources and follow the upstream’s Unicode indexing convention rather than assume JavaScript slicing. The script does not visit links; escape externally supplied URLs and titles when rendering. The script accepts HTTP(S) citations without credentials and checks basic index types and ordering. It does not verify that cited pages support the answer, or print private reasoning. Output is answer-and-citation JSON and may contain public webpage text. One request, no automatic retry; local fixtures check parsing, not live search quality. Implementation sources: relaykit/dto/openai_request.go, relay/channel/openai/adaptor.go, and relay/common/relay_info.go. See upstream search documentation.

Run the example

Run from the documentation directory with approved inputs and a capable model; first read the REST runtime. Keep the script and http-client.mjs together.
阅读中文

Native Gemini search and URL context

Gemini uses tools[].googleSearch and candidate grounding metadata, rather than Responses web_search events. To read a supplied URL use the separate urlContext tool. See the native built-in guide and runnable modes.