Skip to main content
Requesty supports native Anthropic web search capabilities, allowing AI models to access real-time information from the internet. This feature is available through the Chat Completions API.

How It Works

Requesty supports two types of web search:
  • Anthropic Web Search: Using the web_search_preview tool for Claude models
  • Google Grounding Search: Using the web_search function for Gemini models
The AI model can search the web and incorporate current information into its responses, automatically determining when to perform web searches based on the user’s query. Add the web_search_preview tool to enable web search for Claude models:
curl https://router.requesty.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4-20250514",
    "messages": [
      {
        "role": "user",
        "content": "What are the news in London today?"
      }
    ],
    "tools": [{"type": "web_search_preview"}]
  }'

Python Example

from openai import OpenAI

requesty_api_key = "YOUR_REQUESTY_API_KEY"

client = OpenAI(
    api_key=requesty_api_key,
    base_url="https://router.requesty.ai/v1",
)

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-20250514",
    messages=[
        {
            "role": "user",
            "content": "What are the latest developments in artificial intelligence?"
        }
    ],
    tools=[{"type": "web_search_preview"}]
)

print(response.choices[0].message.content)

JavaScript/TypeScript Example

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_REQUESTY_API_KEY',
  baseURL: 'https://router.requesty.ai/v1',
});

const response = await client.chat.completions.create({
  model: 'anthropic/claude-sonnet-4-20250514',
  messages: [
    {
      role: 'user',
      content: 'What are the current weather conditions in New York?'
    }
  ],
  tools: [{ type: 'web_search_preview' }]
});

console.log(response.choices[0].message.content);
For Gemini models, use the web_search function to enable Google’s grounding search:
curl https://router.requesty.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
  -d '{
    "model": "vertex/google/gemini-2.5-pro",
    "messages": [
      {
        "role": "user",
        "content": "What are the news in London today?"
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "web_search",
          "parameters": {
            "type": "object"
          }
        }
      }
    ]
  }'

Python Example

from openai import OpenAI

requesty_api_key = "YOUR_REQUESTY_API_KEY"

client = OpenAI(
    api_key=requesty_api_key,
    base_url="https://router.requesty.ai/v1",
)

response = client.chat.completions.create(
    model="vertex/google/gemini-2.5-pro",
    messages=[
        {
            "role": "user",
            "content": "What are the news in London today?"
        }
    ],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "web_search",
                "parameters": {
                    "type": "object"
                }
            }
        }
    ]
)

print(response.choices[0].message.content)

JavaScript/TypeScript Example

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_REQUESTY_API_KEY',
  baseURL: 'https://router.requesty.ai/v1',
});

const response = await client.chat.completions.create({
  model: 'vertex/google/gemini-2.5-pro',
  messages: [
    {
      role: 'user',
      content: 'What are the latest tech news?'
    }
  ],
  tools: [
    {
      type: 'function',
      function: {
        name: 'web_search',
        parameters: {
          type: 'object'
        }
      }
    }
  ]
});

console.log(response.choices[0].message.content);

Response Format

When web search is used, the response includes the AI’s answer along with citations and metadata about the search:
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Based on the search results, here are the key news stories from London today...",
        "role": "assistant",
        "annotations": [
          {
            "type": "url_citations",
            "url_citation": {
              "type": "url_citations",
              "title": "London News - Latest Updates",
              "url": "https://example.com/news",
              "start_index": 0,
              "end_index": 0
            }
          }
        ]
      }
    }
  ]
}
Web search functionality requires models that support tool use. Check the Model Library to confirm web search support for specific models.