Skip to main content
POST /v1/messages Web search is a tool entry in the tools array. allowed_domains and blocked_domains live at the top level of the tool definition (not nested under filters).

Request

from anthropic import Anthropic

client = Anthropic(base_url="https://api.abliteration.ai", auth_token=os.environ["ABLIT_KEY"])

resp = client.messages.create(
    model="abliterated-model",
    max_tokens=2048,
    tools=[{
        "type": "web_search_2025_03_05",
        "name": "web_search",
        "max_uses": 5,
    }],
    messages=[{"role": "user", "content": "Latest SEC filings for NVDA"}],
)

With allow and block lists (Anthropic native shape)

tools=[{
    "type": "web_search_2025_03_05",
    "name": "web_search",
    "max_uses": 5,
    "allowed_domains": ["sec.gov", "nvidia.com"],
    "blocked_domains": ["reddit.com"],
    "user_location": {
        "type": "approximate",
        "city": "San Francisco",
        "region": "California",
        "country": "US",
        "timezone": "America/Los_Angeles",
    },
}]

Fields

All optional fields on the tool entry:
FieldTypePurpose
max_usesintegerCap on how many searches the model may run per request
allowed_domainsstring[]Only include results from these domains
blocked_domainsstring[]Never include results from these domains
user_locationobjectLocalize search results. Fields: type (always "approximate"), city, region, country, timezone
Of the three API surfaces, Anthropic Messages is the only one with a native per-request block list.

Response shape

The model’s reply contains server_tool_use and web_search_tool_result blocks alongside the usual text blocks — search-result URLs are returned structurally:
"content": [
  {"type": "server_tool_use", "id": "srvtoolu_...", "name": "web_search", "input": {"query": "..."}},
  {"type": "web_search_tool_result", "tool_use_id": "srvtoolu_...", "content": [
    {"type": "web_search_result", "url": "...", "title": "...", "encrypted_content": "..."}
  ]},
  {"type": "text", "text": "NVDA filed..."}
]

Project-level enforcement

Project-level allow/block lists configured via Policy Gateway cap the request:
  • Allow: request allowed_domains ⊆ project allowed_domains. A request asking for a domain outside the project list returns 400.
  • Block: project blocked_domains ∪ request blocked_domains (union — both apply).
If the project has neither list configured, per-request filters pass through unchanged.

Multi-turn caveat

Replaying assistant messages that contain server_tool_use or web_search_tool_result blocks back into a new request can return 422. Strip those blocks before replaying.