> ## 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.

# Amazon Bedrock

> Route Amazon Bedrock model calls through Inference Catalyst for full observability.

Route Amazon Bedrock requests through the Inference Catalyst gateway to get cost tracking, latency monitoring, and analytics. Amazon Bedrock exposes OpenAI-compatible Chat Completions endpoints and Anthropic Messages endpoints on Bedrock Mantle, so you can keep using the OpenAI or Anthropic SDKs with the `x-inference-provider-url` header.

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

<Note>
  This guide covers Bedrock Mantle with a Bedrock bearer/API key. Bedrock Runtime
  `Converse`, `InvokeModel`, and SigV4-only calls use different request formats
  and are not covered by this Gateway setup.
</Note>

## OpenAI-compatible Chat Completions

Use this path for Bedrock models that support the OpenAI-compatible Chat Completions API.

<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**
    * **Amazon Bedrock API key** — from your AWS account. Bedrock also recognizes this as `AWS_BEARER_TOKEN_BEDROCK`.
  </Step>

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

    ```bash theme={"system"}
    export INFERENCE_API_KEY=<your-project-api-key>
    export AWS_BEARER_TOKEN_BEDROCK=<your-bedrock-api-key>
    export AWS_REGION=us-east-1
    export BEDROCK_BASE_URL=https://bedrock-mantle.${AWS_REGION}.api.aws/v1
    export BEDROCK_MODEL=openai.gpt-oss-120b
    export BEDROCK_ANTHROPIC_BASE_URL=https://bedrock-mantle.${AWS_REGION}.api.aws/anthropic
    export BEDROCK_ANTHROPIC_MODEL=anthropic.claude-sonnet-4-6-v1
    ```
  </Step>

  <Step title="Update your code">
    Point the SDK at the gateway. Your project API key goes in `apiKey`, and the `x-inference-provider-url` header tells the gateway to forward requests to Amazon Bedrock.

    <CodeGroup>
      <Metadata text="integrations/amazon-bedrock/setup" />

      ```typescript TypeScript theme={"system"}
      import OpenAI from "openai";

      const bedrockApiKey = process.env.AWS_BEARER_TOKEN_BEDROCK;
      const bedrockBaseUrl =
        process.env.BEDROCK_BASE_URL ?? "https://bedrock-mantle.us-east-1.api.aws/v1";

      if (!bedrockApiKey) {
        console.log("Set AWS_BEARER_TOKEN_BEDROCK to run this example.");
        process.exit(0);
      }

      const client = new OpenAI({
        baseURL: "https://api.inference.net/v1",
        apiKey: process.env.INFERENCE_API_KEY,
        defaultHeaders: {
          "x-inference-provider-api-key": bedrockApiKey,
          "x-inference-provider-url": bedrockBaseUrl,
          "x-inference-environment": process.env.NODE_ENV,
        },
      });

      const response = await client.chat.completions.create({
        model: process.env.BEDROCK_MODEL ?? "openai.gpt-oss-120b",
        messages: [{ role: "user", content: "Reply with exactly OK." }],
        max_tokens: 32,
      }, {
        headers: { "x-inference-task-id": "default" },
      });
      ```

      <Metadata text="integrations/amazon-bedrock/setup" />

      ```python Python theme={"system"}
      import os

      bedrock_api_key = os.getenv("AWS_BEARER_TOKEN_BEDROCK")
      bedrock_base_url = os.getenv(
          "BEDROCK_BASE_URL", "https://bedrock-mantle.us-east-1.api.aws/v1"
      )

      if not bedrock_api_key:
          print("Set AWS_BEARER_TOKEN_BEDROCK to run this example.")
          raise SystemExit(0)

      from openai import OpenAI

      client = OpenAI(
          base_url="https://api.inference.net/v1",
          api_key=os.environ["INFERENCE_API_KEY"],
          default_headers={
              "x-inference-provider-api-key": bedrock_api_key,
              "x-inference-provider-url": bedrock_base_url,
              "x-inference-environment": os.getenv("APP_ENV", "development"),
          },
      )

      response = client.chat.completions.create(
          model=os.getenv("BEDROCK_MODEL", "openai.gpt-oss-120b"),
          messages=[{"role": "user", "content": "Reply with exactly OK."}],
          max_tokens=32,
          extra_headers={"x-inference-task-id": "default"},
      )
      ```

      <Metadata text="integrations/amazon-bedrock/setup-curl" />

      ```bash cURL theme={"system"}
      if [ -z "$AWS_BEARER_TOKEN_BEDROCK" ]; then
        echo "Set AWS_BEARER_TOKEN_BEDROCK to run this example."
        exit 0
      fi

      BEDROCK_BASE_URL=${BEDROCK_BASE_URL:-https://bedrock-mantle.us-east-1.api.aws/v1}
      BEDROCK_MODEL=${BEDROCK_MODEL:-openai.gpt-oss-120b}

      curl https://api.inference.net/v1/chat/completions \
        -H "Authorization: Bearer $INFERENCE_API_KEY" \
        -H "x-inference-provider-api-key: $AWS_BEARER_TOKEN_BEDROCK" \
        -H "x-inference-provider-url: $BEDROCK_BASE_URL" \
        -H "Content-Type: application/json" \
        -H "x-inference-environment: production" \
        -H "x-inference-task-id: default" \
        -d '{
          "model": "'"${BEDROCK_MODEL}"'",
          "max_tokens": 32,
          "messages": [{"role": "user", "content": "Reply with exactly OK."}]
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>

For the Bedrock Runtime OpenAI-compatible endpoint, set `BEDROCK_BASE_URL` to `https://bedrock-runtime.${AWS_REGION}.amazonaws.com/v1`.

## Anthropic Messages on Bedrock

Use this path for Claude models on Bedrock that support the Anthropic Messages API. The key detail is `x-inference-provider: anthropic`: it tells Catalyst to use Anthropic Messages extraction and forward your Bedrock API key as downstream `x-api-key`.

<Steps>
  <Step title="Set environment variables">
    Reuse the same Catalyst and Bedrock keys from above, then set the Bedrock Anthropic endpoint and model:

    <Metadata text="integrations/amazon-bedrock/anthropic-env-vars" />

    ```bash theme={"system"}
    export INFERENCE_API_KEY=<your-project-api-key>
    export AWS_BEARER_TOKEN_BEDROCK=<your-bedrock-api-key>
    export AWS_REGION=us-east-1
    export BEDROCK_ANTHROPIC_BASE_URL=https://bedrock-mantle.${AWS_REGION}.api.aws/anthropic
    export BEDROCK_ANTHROPIC_MODEL=anthropic.claude-sonnet-4-6-v1
    ```
  </Step>

  <Step title="Update your code">
    Point the Anthropic SDK at the Catalyst gateway. Keep the Bedrock key in the SDK `apiKey` for SDK compatibility, and also pass it as `x-inference-provider-api-key` so Catalyst can forward it to Bedrock as downstream `x-api-key`.

    <CodeGroup>
      <Metadata text="integrations/amazon-bedrock/anthropic-setup" />

      ```typescript TypeScript theme={"system"}
      const bedrockApiKey = process.env.AWS_BEARER_TOKEN_BEDROCK;
      const bedrockAnthropicBaseUrl =
        process.env.BEDROCK_ANTHROPIC_BASE_URL ??
        "https://bedrock-mantle.us-east-1.api.aws/anthropic";

      if (!bedrockApiKey) {
        console.log("Set AWS_BEARER_TOKEN_BEDROCK to run this example.");
        process.exit(0);
      }

      const { default: Anthropic } = await import("@anthropic-ai/sdk");

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

      const response = await client.messages.create({
        model: process.env.BEDROCK_ANTHROPIC_MODEL ?? "anthropic.claude-sonnet-4-6-v1",
        max_tokens: 1024,
        messages: [{ role: "user", content: "Reply with exactly OK." }],
      }, {
        headers: { "x-inference-task-id": "default" },
      });
      ```

      <Metadata text="integrations/amazon-bedrock/anthropic-setup" />

      ```python Python theme={"system"}
      import os

      bedrock_api_key = os.getenv("AWS_BEARER_TOKEN_BEDROCK")
      bedrock_anthropic_base_url = os.getenv(
          "BEDROCK_ANTHROPIC_BASE_URL",
          "https://bedrock-mantle.us-east-1.api.aws/anthropic",
      )

      if not bedrock_api_key:
          print("Set AWS_BEARER_TOKEN_BEDROCK to run this example.")
          raise SystemExit(0)

      from anthropic import Anthropic

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

      response = client.messages.create(
          model=os.getenv("BEDROCK_ANTHROPIC_MODEL", "anthropic.claude-sonnet-4-6-v1"),
          max_tokens=1024,
          messages=[{"role": "user", "content": "Reply with exactly OK."}],
          extra_headers={"x-inference-task-id": "default"},
      )
      ```

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

      ```bash cURL theme={"system"}
      if [ -z "$AWS_BEARER_TOKEN_BEDROCK" ]; then
        echo "Set AWS_BEARER_TOKEN_BEDROCK to run this example."
        exit 0
      fi

      BEDROCK_ANTHROPIC_BASE_URL=${BEDROCK_ANTHROPIC_BASE_URL:-https://bedrock-mantle.us-east-1.api.aws/anthropic}
      BEDROCK_ANTHROPIC_MODEL=${BEDROCK_ANTHROPIC_MODEL:-anthropic.claude-sonnet-4-6-v1}

      curl https://api.inference.net/v1/messages \
        -H "Authorization: Bearer $INFERENCE_API_KEY" \
        -H "x-inference-provider: anthropic" \
        -H "x-inference-provider-url: $BEDROCK_ANTHROPIC_BASE_URL" \
        -H "x-inference-provider-api-key: $AWS_BEARER_TOKEN_BEDROCK" \
        -H "anthropic-version: 2023-06-01" \
        -H "content-type: application/json" \
        -H "x-inference-environment: production" \
        -H "x-inference-task-id: default" \
        -d '{
          "model": "'"${BEDROCK_ANTHROPIC_MODEL}"'",
          "max_tokens": 1024,
          "messages": [{"role": "user", "content": "Reply with exactly OK."}]
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>
