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

# Anthropic

> Use Anthropic Claude models through the ngrok AI Gateway.

This guide walks through using [Anthropic](https://anthropic.com) Claude models with the AI Gateway. Anthropic is a **built-in provider**, so ngrok.ai offers managed inference for it—you can use Claude models without an Anthropic account of your own, or bring your own key.

## Use ngrok.ai inference (no Anthropic account)

You can use Claude models without your own Anthropic account—ngrok.ai inference supplies the upstream credentials and bills the model cost through credits.

<Steps>
  <Step title="Create an access key and add credits">
    Follow the [quickstart](/ai-gateway/quickstart) to create an [access key](/ai-gateway/concepts/access-keys) and purchase [credits](/ai-gateway/concepts/credits) in [app.ngrok.ai](https://app.ngrok.ai).
  </Step>

  <Step title="Send requests">
    Point your SDK at the gateway with your access key:

    <CodeGroup>
      ```python Python theme={null}
      import anthropic

      client = anthropic.Anthropic(
          base_url="https://gateway.ngrok.ai",
          api_key="ng-xxxxx-g1-xxxxx",  # Access key
      )

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

      ```bash cURL theme={null}
      curl https://gateway.ngrok.ai/v1/messages \
        -H "Content-Type: application/json" \
        -H "x-api-key: ng-xxxxx-g1-xxxxx" \
        -H "anthropic-version: 2023-06-01" \
        -d '{"model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}]}'
      ```
    </CodeGroup>
  </Step>
</Steps>

<Note>
  The gateway supports both the Anthropic Messages API (`/v1/messages`) and OpenAI-compatible Chat Completions.
</Note>

## Bring your own Anthropic key

Want requests billed to your own Anthropic account instead of through credits? Store your Anthropic key once—the gateway attaches it for you on every request.

<Steps>
  <Step title="Create an access key">
    Follow the [quickstart](/ai-gateway/quickstart) to create an [access key](/ai-gateway/concepts/access-keys) in [app.ngrok.ai](https://app.ngrok.ai) if you don't have one yet.
  </Step>

  <Step title="Add your Anthropic key">
    [Add a provider key](/ai-gateway/guides/attaching-provider-keys#add-a-provider-key) for Anthropic. ngrok stores it encrypted, so it never has to live in your application or get shared around—and you can reuse it across as many access keys as you need.
  </Step>

  <Step title="Route to it with a configuration">
    [Create an access key configuration](/ai-gateway/guides/access-key-configurations#create-a-configuration) with an Anthropic routing rule set to **Bring your own API key**, then assign it to your access key.
  </Step>

  <Step title="Keep sending your access key">
    Your code doesn't change. Send the same access key as before—the gateway swaps in your Anthropic key before the request leaves for Anthropic.
  </Step>
</Steps>

## Explicit provider routing

```python theme={null}
message = client.messages.create(
    model="anthropic:claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}]
)
```

## Available models

Browse the [model catalog](/ai-gateway/reference/model-catalog#anthropic) for the full list of Claude models you can call through the gateway.

## Next steps

* [Access Keys](/ai-gateway/concepts/access-keys)
* [Access Key Configurations](/ai-gateway/guides/access-key-configurations)
* [Provider Keys](/ai-gateway/guides/attaching-provider-keys)
