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

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Anthropic

> Add an Anthropic API key under Settings, Model Providers and call Claude models through the LangWatch AI Gateway with the Anthropic or the OpenAI SDK.

## Add the credential

Open **Settings > Model Providers**, click **Add Model Provider** and select **Anthropic**. Give the row a name, pick the organization, team or project it belongs to, and fill in:

| Field | Value |
| - | - |
| `ANTHROPIC_API_KEY` | Your Anthropic API key. Required unless you set a base URL. |
| `ANTHROPIC_BASE_URL` | Optional. An Anthropic-compatible endpoint to call instead of `api.anthropic.com`. |

Save the row. Every virtual key whose scope can see the row can now dispatch to it, unless the key restricts its providers. See [Virtual keys](https://langwatch.ai/docs/ai-gateway/virtual-keys.md#create-a-virtual-key).

![The Anthropic model provider drawer with ANTHROPIC\_API\_KEY filled in, ANTHROPIC\_BASE\_URL empty and the routing handle anthropic](https://mintcdn.com/langwatch/6EHh-4eZyYKZhosJ/images/ai-gateway/model-provider-anthropic-form.png?fit=max\&auto=format\&n=6EHh-4eZyYKZhosJ\&q=85\&s=fc2548184f767f7761f04a2161db57d7)

The Anthropic row: name, scope, ANTHROPIC\_API\_KEY, the optional base URL and the routing handle.

## Model names

Write `anthropic/<model>`, for example `anthropic/claude-sonnet-4-5` or `anthropic/claude-haiku-4-5`. A bare name that starts with `claude-` resolves to Anthropic when the key reaches an Anthropic row.

## Send a request

The Anthropic SDK sends the virtual key in the `X-Api-Key` header. Set the base URL to `https://gateway.langwatch.ai` without `/v1`; the SDK adds `/v1/messages`.

```bash theme={null}
curl https://gateway.langwatch.ai/v1/messages \
  -H "Authorization: Bearer $LANGWATCH_VIRTUAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4-5",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Say hi in one word"}]
  }'
```

```python Python theme={null}
import anthropic

client = anthropic.Anthropic(
    base_url="https://gateway.langwatch.ai",
    api_key="vk-lw-...",
)
message = client.messages.create(
    model="anthropic/claude-haiku-4-5",
    max_tokens=64,
    messages=[{"role": "user", "content": "Say hi in one word"}],
)
print(message.content[0].text)
```

An OpenAI SDK call to `/v1/chat/completions` with an Anthropic model also works: the gateway translates the request to the Messages API and the answer back to a chat completion.

## Endpoints

| Endpoint | Served |
| - | - |
| `POST /v1/messages` | Yes, forwarded as is |
| `POST /v1/chat/completions` | Yes, translated to Messages |
| `POST /v1/embeddings` | No. Anthropic has no embeddings API; the gateway returns Anthropic's rejection |
| `GET /v1/models` | Yes, from the Anthropic catalog |

`cache_control` blocks pass through unchanged and the cache read and write token counts come back in `usage`. See [Cache control](https://langwatch.ai/docs/ai-gateway/cache-control.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.