> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSearchTool

> A built-in tool that allows models to search the web for information

## Overview

A built-in tool that allows models to search the web for information.

## Usage

```python theme={null}
from upsonic import Agent, Task
from upsonic.tools.builtin_tools import WebSearchTool
from upsonic.models.openai import OpenAIResponsesModel

# Create model with OpenAI Responses API
model = OpenAIResponsesModel(
    model_name="gpt-4o",
    provider="openai"
)

# Basic web search tool
web_search = WebSearchTool()

# Create task
task = Task(
    description="Search for latest AI news and summarize the findings",
    tools=[web_search]
)

# Create agent
agent = Agent(model=model, name="Web Search Agent")

# Execute
result = agent.print_do(task)
print("Result:", result)
```

## Advanced Configuration

```python theme={null}
from upsonic.tools.builtin_tools import WebSearchTool, WebSearchUserLocation
from upsonic import Agent, Task
from upsonic.models.openai import OpenAIResponsesModel

model = OpenAIResponsesModel(
    model_name="gpt-4o",
    provider="openai"
)

# Advanced web search with configuration
advanced_search = WebSearchTool(
    search_context_size="high",  # 'low', 'medium', or 'high'
    user_location=WebSearchUserLocation(
        city="San Francisco",
        country="US",
        region="CA",
        timezone="America/Los_Angeles"
    ),
    blocked_domains=["example.com", "spam-site.com"],
    max_uses=10
)

task = Task(
    description="Search for AI trends with high context and location filtering",
    tools=[advanced_search]
)

agent = Agent(model=model, name="Advanced Search Agent")
result = agent.print_do(task)
print("Result:", result)
```

## Parameters

* `search_context_size` (str): Context amount - 'low', 'medium', or 'high' (default: 'medium')
  * Supported by: OpenAI Responses
* `user_location` (WebSearchUserLocation, optional): Localize search results
  * Supported by: Anthropic, OpenAI Responses
* `blocked_domains` (List\[str], optional): Domains to exclude from results
  * Supported by: Anthropic, Groq
* `allowed_domains` (List\[str], optional): Only include these domains
  * Supported by: Anthropic, Groq
  * Note: Cannot use both blocked\_domains and allowed\_domains with Anthropic
* `max_uses` (int, optional): Maximum number of searches allowed
  * Supported by: Anthropic
