Skip to main content
Beta APIThis API is in beta stage and may have breaking changes.
The Responses API Beta supports web search integration, allowing models to access real-time information from the internet and provide responses with proper citations and annotations.
Deprecated Plugin ApproachThe web search plugin (plugins: [{ id: "web" }]) shown below is deprecated. Use the openrouter:web_search server tool instead, which works with both the Chat Completions and Responses APIs via the tools array.

Web Search Plugin

Enable web search using the plugins parameter:

Plugin Configuration

Configure web search behavior:
ParameterTypeDescription
idstringRequired. Must be “web”
enginestringSearch engine: "native", "exa", "firecrawl", "parallel", or omit for auto
max_resultsintegerMaximum search results to retrieve (1–25; 1–20 for Perplexity; default 5)
include_domainsstring[]Restrict results to these domains (supports wildcards like *.substack.com)
exclude_domainsstring[]Exclude results from these domains
See the Web Search plugin docs for full details on engine selection, domain filter compatibility, and pricing.

X Search Filters (xAI only)

When using xAI models (e.g. x-ai/grok-4.1-fast), you can pass x_search_filter as a top-level request parameter to filter X/Twitter search results:
ParameterTypeDescription
allowed_x_handlesstring[]Only include posts from these handles (max 20)
excluded_x_handlesstring[]Exclude posts from these handles (max 20)
from_datestringStart date (ISO 8601, e.g. "2025-01-01")
to_datestringEnd date (ISO 8601, e.g. "2025-12-31")
enable_image_understandingbooleanAnalyze images in posts
enable_video_understandingbooleanAnalyze videos in posts
allowed_x_handles and excluded_x_handles are mutually exclusive. See the Web Search plugin docs for full details.
Use structured messages for more complex queries:

Online Model Variants

DeprecatedThe :online variant is deprecated. Use the openrouter:web_search server tool instead.
Some models have built-in web search capabilities using the :online variant:

Response with Annotations

Web search responses include citation annotations:

Annotation Types

Web search responses can include different annotation types:

URL Citation

Complex Search Queries

Handle multi-part search queries:

Web Search in Conversation

Include web search in multi-turn conversations:
Monitor web search progress with streaming:

Annotation Processing

Extract and process citation information:

Best Practices

  1. Limit results: Use appropriate max_results to balance quality and speed
  2. Handle annotations: Process citation annotations for proper attribution
  3. Query specificity: Make search queries specific for better results
  4. Error handling: Handle cases where web search might fail
  5. Rate limits: Be mindful of search rate limits

Next Steps