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

# Anthropic

> Scan Claude traffic through the PromptGuard proxy with the Anthropic SDK, or with the SDK auto-instrumentation

Two ways in: point the Anthropic client at the proxy, or call `init()` and keep the client as it is ([auto-instrumentation](/integrations/auto-instrumentation) patches the `anthropic` package in Python and `@anthropic-ai/sdk` in Node).

## Proxy

<Note>
  **Proxy Base URL:** `https://api.promptguard.co/api/v1`

  Point your LLM SDK's `base_url` / `baseURL` to this endpoint. Your existing provider API key goes in the `Authorization` header as usual; add your PromptGuard key via `X-API-Key`.
</Note>

The proxy serves Anthropic's Messages API at `/messages` and its token counter at `/messages/count_tokens`, so the official Anthropic SDK works unchanged. Every model id starting `claude-` goes to Anthropic.

The Anthropic SDK adds `/v1` to its base URL itself, so its base URL is `https://api.promptguard.co/api`, one segment shorter than the proxy URL above.

<Warning>
  The Anthropic SDK sends its `api_key` in the `X-API-Key` header, which is the header PromptGuard reads its own key from. So give the SDK your **PromptGuard** key as `api_key`, and your Anthropic key as `auth_token`, which the SDK sends as `Authorization: Bearer`. PromptGuard forwards that to Anthropic in the `x-api-key` header Anthropic expects.
</Warning>

<CodeGroup>
  ```python Python theme={"system"}
  import os
  import anthropic

  client = anthropic.Anthropic(
      base_url="https://api.promptguard.co/api",
      api_key=os.environ["PROMPTGUARD_API_KEY"],  # authenticates you to PromptGuard
      auth_token=os.environ["ANTHROPIC_API_KEY"],  # forwarded to Anthropic
  )

  message = client.messages.create(
      model="claude-sonnet-4-5",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello!"}],
  )
  print(message.content[0].text)
  ```

  ```typescript Node.js theme={"system"}
  import Anthropic from '@anthropic-ai/sdk';

  const client = new Anthropic({
    baseURL: 'https://api.promptguard.co/api',
    apiKey: process.env.PROMPTGUARD_API_KEY, // authenticates you to PromptGuard
    authToken: process.env.ANTHROPIC_API_KEY, // forwarded to Anthropic
  });

  const message = await client.messages.create({
    model: 'claude-sonnet-4-5',
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'Hello!' }],
  });
  console.log(message.content[0].text);
  ```

  ```bash cURL theme={"system"}
  curl https://api.promptguard.co/api/v1/messages \
    -H "X-API-Key: $PROMPTGUARD_API_KEY" \
    -H "Authorization: Bearer $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "Content-Type: application/json" \
    -d '{"model": "claude-sonnet-4-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}]}'
  ```
</CodeGroup>

To keep the Anthropic key out of your application, [store it as a provider key](/gateway/provider-keys) under `anthropic` and drop `auth_token`. PromptGuard then sends the stored key.

The `anthropic-version` and `anthropic-beta` headers your SDK sends are forwarded as sent. Only when you send no `anthropic-version` does PromptGuard add `2023-06-01`.

<Note>
  Claude model ids are accepted on `/chat/completions` too, but the reply comes back in Anthropic's Messages shape (`content`, `stop_reason`), not OpenAI's (`choices`). An OpenAI client cannot read it, so use the Anthropic SDK or the `/messages` route.
</Note>

## Auto-instrumentation

```python theme={"system"}
import promptguard
promptguard.init()  # reads PROMPTGUARD_API_KEY

import anthropic
client = anthropic.Anthropic()  # talks to Anthropic directly; each messages.create is scanned first
```

## Claude on AWS Bedrock

Claude models served by Bedrock are Bedrock traffic: see [AWS Bedrock](/integrations/providers/bedrock).


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