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

# Anthropic

> Route Anthropic requests through Inference Catalyst for full observability.

Route your Anthropic requests through the Inference Catalyst gateway to get cost tracking, latency monitoring, and analytics. Anthropic uses its native SDK and the `/v1/messages` endpoint, not the OpenAI-compatible path.

<Info>Prefer automatic setup? Run `inf instrument` to instrument your codebase in seconds. [Learn more](/integrations/install-with-ai)</Info>

## Setup

<Steps>
  <Step title="Get your API keys">
    You need two keys:

    * **Inference Catalyst project API key** — from your [dashboard](https://inference.net/dashboard) under **API Keys**
    * **Anthropic API key** — from your [Anthropic console](https://console.anthropic.com/settings/keys)
  </Step>

  <Step title="Set environment variables">
    <Metadata text="integrations/anthropic/env-vars" />

    ```bash theme={"system"}
    export INFERENCE_API_KEY=<your-project-api-key>
    export ANTHROPIC_API_KEY=<your-anthropic-api-key>
    ```
  </Step>

  <Step title="Update your code">
    Point the SDK at the gateway. Because the Anthropic SDK sends `apiKey` as the `x-api-key` header, you pass your Anthropic key there and add the Inference project key as an `Authorization` header.

    <CodeGroup>
      <Metadata text="integrations/anthropic/setup" />

      ```typescript TypeScript theme={"system"}
      import Anthropic from "@anthropic-ai/sdk";

      const client = new Anthropic({
        baseURL: "https://api.inference.net",
        apiKey: process.env.ANTHROPIC_API_KEY,
        defaultHeaders: {
          "Authorization": `Bearer ${process.env.INFERENCE_API_KEY}`,
          "x-inference-provider": "anthropic",
          "x-inference-environment": process.env.NODE_ENV,
        },
      });

      const response = await client.messages.create({
        model: "claude-opus-4-6",
        max_tokens: 1024,
        messages: [{ role: "user", content: "Hello" }],
      }, {
        headers: { "x-inference-task-id": "default" },
      });
      ```

      <Metadata text="integrations/anthropic/setup" />

      ```python Python theme={"system"}
      import os
      from anthropic import Anthropic

      client = Anthropic(
          base_url="https://api.inference.net",
          api_key=os.environ["ANTHROPIC_API_KEY"],
          default_headers={
              "Authorization": f"Bearer {os.environ['INFERENCE_API_KEY']}",
              "x-inference-provider": "anthropic",
              "x-inference-environment": env = os.getenv("APP_ENV", "development"),
          },
      )

      response = client.messages.create(
          model="claude-opus-4-6",
          max_tokens=1024,
          messages=[{"role": "user", "content": "Hello"}],
          extra_headers={"x-inference-task-id": "default"},
      )
      ```

      <Metadata text="integrations/anthropic/setup-curl" />

      ```bash cURL theme={"system"}
      curl https://api.inference.net/v1/messages \
        -H "Authorization: Bearer $INFERENCE_API_KEY" \
        -H "x-api-key: $ANTHROPIC_API_KEY" \
        -H "anthropic-version: 2023-06-01" \
        -H "content-type: application/json" \
        -H "x-inference-provider: anthropic" \
        -H "x-inference-environment: production" \
        -H "x-inference-task-id: default" \
        -d '{
          "model": "claude-opus-4-6",
          "max_tokens": 1024,
          "messages": [{"role": "user", "content": "Hello"}]
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>
