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

# Anthropic Messages

> Server-side web search on /v1/messages via the tools array, with native allowed_domains and blocked_domains at the tool's top level.

`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

```python theme={"system"}
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)

```python theme={"system"}
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:

| Field             | Type      | Purpose                                                                                                   |
| ----------------- | --------- | --------------------------------------------------------------------------------------------------------- |
| `max_uses`        | integer   | Cap on how many searches the model may run per request                                                    |
| `allowed_domains` | string\[] | Only include results from these domains                                                                   |
| `blocked_domains` | string\[] | Never include results from these domains                                                                  |
| `user_location`   | object    | Localize 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:

```json theme={"system"}
"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](/policy-gateway/overview) 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.
