SPB Git

Repository Public

claude-in-amazon-bedrock.md 20.2 KB 433 lines markdown

1---2title: Claude in Amazon Bedrock (Opus 4.7 and later)3url: https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock4description: Access Claude models through Amazon Bedrock with AWS-native authentication, billing, and security boundaries.5---67This guide walks you through setting up and making API calls to Claude in Amazon Bedrock. Claude in Amazon Bedrock runs on AWS-managed infrastructure with zero operator access (Anthropic personnel have no access to the inference infrastructure), letting you build sensitive applications entirely inside the AWS security boundary while using the same Messages API shape you use with Anthropic's first-party API.89<Note>10  This page covers Claude in Amazon Bedrock, which serves Claude through the Messages API at `/anthropic/v1/messages` on AWS-managed infrastructure. The previous Amazon Bedrock integration (the `InvokeModel` and `Converse` APIs with ARN-versioned model identifiers) remains available and is documented at [Claude on Amazon Bedrock (Opus 4.6 and earlier)](https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock-legacy). For an Anthropic-operated alternative on AWS with AWS Marketplace billing and typically same-day feature access, see [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws).11</Note>1213## Access1415Amazon Bedrock sets access criteria for each Claude model individually. Claude Fable 5.1, Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5, Claude Opus 4.7, and Claude Haiku 4.5 are open to all Amazon Bedrock customers. For any other model's current criteria, check [Amazon Bedrock model access](https://console.aws.amazon.com/bedrock/home#/modelaccess) in the AWS console. Claude Mythos Preview requires an invitation through [Project Glasswing](https://anthropic.com/glasswing). For region availability, see [Regions](https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock#regions).1617## Prerequisites1819Before you begin, ensure you have:2021* An AWS account with [Amazon Bedrock model access](https://console.aws.amazon.com/bedrock/home#/modelaccess) enabled for the Claude models you intend to use.22* The [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) installed and configured (optional, for credential management).2324Claude Mythos Preview additionally requires a dedicated AWS account that has been allowlisted by the Bedrock Marketplace team. Your Anthropic account executive can submit your account ID for allowlisting (typically processed within 24 hours), and AWS sends a welcome email once it's complete.2526## Authentication2728Claude in Amazon Bedrock supports three authentication paths. Choose the one that best fits your security requirements.2930### Bedrock service role (recommended)3132Use a Bedrock service role with AWS-managed keys for the most secure, long-lived access:3334<Steps>35  <Step title="Admin: provision the service role">36    An AWS administrator provisions a Bedrock service role and grants developers `iam:PassRole` permission on the service role ARN.37  </Step>3839  <Step title="Developer: pass the role">40    When calling the API, Bedrock assumes the service role on your behalf. See the [Amazon Bedrock documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html) for how to associate the role with your requests.41  </Step>42</Steps>4344### IAM assumed roles4546For identity-federated access with a 12-hour maximum session:4748<Steps>49  <Step title="Admin: configure the IAM role">50    Create an IAM role scoped to your Claude models. The trust policy names your identity provider (SAML, OIDC, or AWS Identity Center). The permissions policy grants `bedrock-mantle:CreateInference` only on the allowed model ARNs.51  </Step>5253  <Step title="Developer: authenticate and assume">54    Authenticate through your corporate identity provider, then assume the IAM role. AWS STS issues temporary credentials that the SDK or CLI uses to sign requests.55  </Step>56</Steps>5758### Bearer tokens5960For short-term access without IAM roles (12-hour maximum, least preferred):6162<Steps>63  <Step title="Admin: restrict token types">64    Block long-term keys by attaching a policy that denies `bedrock:CallWithBearerToken` unless the `bedrock:BearerTokenType` condition matches a short-term token.65  </Step>6667  <Step title="Developer: mint a token">68    Use the `aws-bedrock-token-generator` CLI to mint a bearer token. Pass it in the `x-api-key` header on each request.69  </Step>70</Steps>7172## Install an SDK7374Anthropic's [client SDKs](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) support Claude in Amazon Bedrock through a Bedrock-specific package or module.7576<Tabs>77  <Tab title="Python">78    ```bash79    pip install -U "anthropic[bedrock]"80    ```81  </Tab>8283  <Tab title="TypeScript">84    ```bash85    npm install @anthropic-ai/bedrock-sdk86    ```87  </Tab>8889  <Tab title="C#">90    ```bash91    dotnet add package Anthropic.Bedrock92    ```93  </Tab>9495  <Tab title="Go">96    ```bash97    go get github.com/anthropics/anthropic-sdk-go/bedrock98    ```99  </Tab>100101  <Tab title="Java">102    <Tabs>103      <Tab title="Gradle">104        ```kotlin105        implementation("com.anthropic:anthropic-java:2.63.0")106        implementation("com.anthropic:anthropic-java-bedrock:2.63.0")107        ```108      </Tab>109110      <Tab title="Maven">111        ```xml112        <dependency>113            <groupId>com.anthropic</groupId>114            <artifactId>anthropic-java</artifactId>115            <version>2.63.0</version>116        </dependency>117        <dependency>118            <groupId>com.anthropic</groupId>119            <artifactId>anthropic-java-bedrock</artifactId>120            <version>2.63.0</version>121        </dependency>122        ```123      </Tab>124    </Tabs>125  </Tab>126127  <Tab title="PHP">128    ```bash129    composer require anthropic-ai/sdk aws/aws-sdk-php130    ```131  </Tab>132133  <Tab title="Ruby">134    ```bash135    # Gemfile136    gem "anthropic"137    gem "aws-sdk-core"138    ```139  </Tab>140</Tabs>141142## Making your first request143144The endpoint follows the pattern `https://bedrock-mantle.{region}.api.aws/anthropic/v1/messages`. Unlike the `InvokeModel`-based integration, this endpoint uses standard SSE streaming and the same request body shape as Anthropic's first-party API.145146The SDK resolves credentials and region using the standard AWS precedence: constructor arguments, then environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`, `AWS_REGION`), then the AWS config file and credential chain (SSO, assumed roles, ECS task role, IMDS).147148<Tabs>149  <Tab title="cURL">150    ```bash151    curl https://bedrock-mantle.us-east-1.api.aws/anthropic/v1/messages \152      --aws-sigv4 "aws:amz:us-east-1:bedrock-mantle" \153      --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \154      -H "x-amz-security-token: $AWS_SESSION_TOKEN" \155      -H "content-type: application/json" \156      -H "anthropic-version: 2023-06-01" \157      -d '{158        "model": "anthropic.claude-opus-5",159        "max_tokens": 1024,160        "messages": [161          {"role": "user", "content": "Hello, Claude"}162        ]163      }'164    ```165  </Tab>166167  <Tab title="CLI">168    The `ant` CLI does not support Amazon Bedrock. Use either cURL or an SDK.169  </Tab>170171  <Tab title="Python">172    ```python173    from anthropic import AnthropicBedrockMantle174175    client = AnthropicBedrockMantle(aws_region="us-east-1")176177    message = client.messages.create(178        model="anthropic.claude-opus-5",179        max_tokens=1024,180        messages=[{"role": "user", "content": "Hello, Claude"}],181    )182183    print(next(block.text for block in message.content if block.type == "text"))184    ```185  </Tab>186187  <Tab title="TypeScript">188    ```typescript189    import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk";190191    const client = new AnthropicBedrockMantle({192      awsRegion: "us-east-1"193    });194195    const message = await client.messages.create({196      model: "anthropic.claude-opus-5",197      max_tokens: 1024,198      messages: [{ role: "user", content: "Hello, Claude" }]199    });200201    const textBlock = message.content.find((block) => block.type === "text");202    if (textBlock) {203      console.log(textBlock.text);204    }205    ```206  </Tab>207208  <Tab title="C#">209    ```csharp210    using Anthropic.Bedrock;211    using Anthropic.Models.Messages;212213    var client = new AnthropicBedrockMantleClient(new() { AwsRegion = "us-east-1" });214215    var message = await client.Messages.Create(new()216    {217        Model = "anthropic.claude-opus-5",218        MaxTokens = 1024,219        Messages = [new() { Role = Role.User, Content = "Hello, Claude" }],220    });221222    foreach (var item in message.Content)223    {224        if (item.Value is TextBlock block)225        {226            Console.WriteLine(block.Text);227            break;228        }229    }230    ```231  </Tab>232233  <Tab title="Go">234    ```go235    client, err := bedrock.NewMantleClient(context.Background(), bedrock.MantleClientConfig{236    	AWSRegion: "us-east-1",237    })238    if err != nil {239    	panic(err)240    }241242    message, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{243    	Model:     "anthropic.claude-opus-5",244    	MaxTokens: 1024,245    	Messages: []anthropic.MessageParam{246    		anthropic.NewUserMessage(anthropic.NewTextBlock("Hello, Claude")),247    	},248    })249    if err != nil {250    	panic(err)251    }252253    for _, block := range message.Content {254    	if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {255    		fmt.Println(textBlock.Text)256    		break257    	}258    }259    ```260  </Tab>261262  <Tab title="Java">263    ```java264    import com.anthropic.bedrock.backends.BedrockMantleBackend;265    import com.anthropic.client.AnthropicClient;266    import com.anthropic.client.okhttp.AnthropicOkHttpClient;267    import com.anthropic.models.messages.ContentBlock;268    import com.anthropic.models.messages.Message;269    import com.anthropic.models.messages.MessageCreateParams;270271    void main() {272        AnthropicClient client = AnthropicOkHttpClient.builder()273            .backend(BedrockMantleBackend.fromEnv())274            .build();275276        Message message = client.messages().create(277            MessageCreateParams.builder()278                .model("anthropic.claude-opus-5")279                .maxTokens(1024)280                .addUserMessage("Hello, Claude")281                .build()282        );283284        message.content().stream()285                .filter(ContentBlock::isText)286                .findFirst()287                .ifPresent(block -> IO.println(block.asText().text()));288    }289    ```290  </Tab>291292  <Tab title="PHP">293    ```php294    use Anthropic\Bedrock\MantleClient;295296    $client = new MantleClient(awsRegion: 'us-east-1');297298    $message = $client->messages->create(299        model: 'anthropic.claude-opus-5',300        maxTokens: 1024,301        messages: [302            ['role' => 'user', 'content' => 'Hello, Claude'],303        ],304    );305306    echo array_find($message->content, fn ($block) => $block->type === 'text')->text;307    ```308  </Tab>309310  <Tab title="Ruby">311    ```ruby312    require "anthropic"313314    client = Anthropic::BedrockMantleClient.new(aws_region: "us-east-1")315316    message = client.messages.create(317      model: "anthropic.claude-opus-5",318      max_tokens: 1024,319      messages: [{role: "user", content: "Hello, Claude"}]320    )321322    puts message.content.find { it.type == :text }.text323    ```324  </Tab>325</Tabs>326327<Tip>328  You can also use the standard `Anthropic` client: set `base_url` to `https://bedrock-mantle.{region}.api.aws/anthropic` and pass your bearer token as `api_key`. This path supports bearer-token authentication only. SigV4 signing requires the dedicated client.329</Tip>330331## Supported models332333Model IDs in Claude in Amazon Bedrock carry an `anthropic.` provider prefix. Model capabilities and behaviors are documented on the [Models overview](https://platform.claude.com/docs/en/models/overview) page.334335| Model                 | Model ID                        | Access                                                                                              |336| --------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------- |337| Claude Fable 5.1      | anthropic.claude-fable-5-1      | Open                                                                                                |338| Claude Fable 5        | anthropic.claude-fable-5        | Open                                                                                                |339| Claude Opus 5         | anthropic.claude-opus-5         | See [Access](https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock#access) |340| Claude Opus 4.8       | anthropic.claude-opus-4-8       | Open                                                                                                |341| Claude Opus 4.7       | anthropic.claude-opus-4-7       | Open                                                                                                |342| Claude Sonnet 5       | `anthropic.claude-sonnet-5`     | Open                                                                                                |343| Claude Haiku 4.5      | anthropic.claude-haiku-4-5      | Open                                                                                                |344| Claude Mythos Preview | anthropic.claude-mythos-preview | Invitation only ([Project Glasswing](https://anthropic.com/glasswing))                              |345346Use Claude Code 2.1.255 or later with Claude Fable 5.1 on Amazon Bedrock; run `claude update` to upgrade.347348<Tip>349  Upgrading to a newer Claude model? In Claude Code, run `/claude-api migrate` to apply model ID swaps and breaking parameter changes across your codebase. The skill detects which cloud platform your code targets and adjusts model ID formats and feature changes for that platform. See [Migrating to a newer Claude model](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill#migrating-to-a-newer-claude-model).350</Tip>351352## Feature support353354For the full feature list with Amazon Bedrock availability, see [Features overview](https://platform.claude.com/docs/en/build-with-claude/overview).355356### Supported feature highlights357358* [Messages API](https://platform.claude.com/docs/en/api/messages/create) (`/anthropic/v1/messages`)359* [Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)360* [Thinking](https://platform.claude.com/docs/en/build-with-claude/thinking)361* [Tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview), including the [Bash tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/bash-tool), [Computer use tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool), [Memory tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool), and [Text editor tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/text-editor-tool)362* [Citations](https://platform.claude.com/docs/en/build-with-claude/citations)363364### Features not supported365366* [Structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)367* Input sources (URL sources for images and documents, Files API)368* Server-side tools (code execution, web search, web fetch, advisor)369* Agent infrastructure (Agent Skills, MCP connector, programmatic tool calling)370* API endpoints (Message Batches, Models, Admin, Compliance, Usage and Cost)371* Claude Managed Agents372* Server-side fallback (the [`fallbacks` parameter](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#server-side-fallback); use the [client-side fallback pattern](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#client-side-fallback) instead)373* [Computer use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool) and [browser use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/browser-use-tool) toolsets (`computer_toolset_20260801` and `browser_toolset_20260801` are not currently available on Amazon Bedrock; the beta computer use tool versions remain available)374375## Regions376377Claude in Amazon Bedrock is available in the following AWS regions. Amazon Bedrock offers two endpoint types:378379* **Global:** dynamic routing across all available regions for maximum availability. No pricing premium.380* **Regional:** the endpoint resolves to the single AWS region you specify, for data-residency requirements. Regional endpoints carry a 10% pricing premium over global endpoints. To route across multiple regions within a geography, use an [inference profile](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) (US, EU, JP, or AU). Regions marked **In-region only** in the table support direct single-region routing without an inference profile.381382The global endpoint is available for Claude Fable 5.1, Claude Fable 5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, Claude Sonnet 5, and Claude Haiku 4.5. For Claude Fable 5.1, regional endpoints are currently available in `us-east-1` only. Claude Mythos Preview is regional only and is available in `us-east-1`.383384| AWS region       | Location                  | Endpoint types             |385| ---------------- | ------------------------- | -------------------------- |386| `af-south-1`     | Africa (Cape Town)        | Global                     |387| `ap-northeast-1` | Asia Pacific (Tokyo)      | Global, JP, In-region only |388| `ap-northeast-2` | Asia Pacific (Seoul)      | Global                     |389| `ap-northeast-3` | Asia Pacific (Osaka)      | Global, JP                 |390| `ap-south-1`     | Asia Pacific (Mumbai)     | Global                     |391| `ap-south-2`     | Asia Pacific (Hyderabad)  | Global                     |392| `ap-southeast-1` | Asia Pacific (Singapore)  | Global                     |393| `ap-southeast-2` | Asia Pacific (Sydney)     | Global, AU                 |394| `ap-southeast-3` | Asia Pacific (Jakarta)    | Global                     |395| `ap-southeast-4` | Asia Pacific (Melbourne)  | Global, AU, In-region only |396| `ca-central-1`   | Canada (Central)          | Global, US                 |397| `ca-west-1`      | Canada West (Calgary)     | Global                     |398| `eu-central-1`   | Europe (Frankfurt)        | Global, EU                 |399| `eu-central-2`   | Europe (Zurich)           | Global, EU                 |400| `eu-north-1`     | Europe (Stockholm)        | Global, EU, In-region only |401| `eu-south-1`     | Europe (Milan)            | Global, EU                 |402| `eu-south-2`     | Europe (Spain)            | Global, EU                 |403| `eu-west-1`      | Europe (Ireland)          | Global, EU, In-region only |404| `eu-west-2`      | Europe (London)           | Global, EU                 |405| `eu-west-3`      | Europe (Paris)            | Global, EU                 |406| `il-central-1`   | Israel (Tel Aviv)         | Global                     |407| `me-central-1`   | Middle East (UAE)         | Global                     |408| `sa-east-1`      | South America (São Paulo) | Global                     |409| `us-east-1`      | US East (N. Virginia)     | Global, US, In-region only |410| `us-east-2`      | US East (Ohio)            | Global, US, In-region only |411| `us-west-1`      | US West (N. California)   | Global, US                 |412| `us-west-2`      | US West (Oregon)          | Global, US, In-region only |413414## Quotas415416Default quota is 2 million input tokens per minute (TPM). You can request up to 5 million input TPM and 500,000 output TPM without additional Anthropic approval. AWS enforces requests-per-minute (RPM) limits on the Bedrock side; contact AWS support for RPM adjustments.417418## Data retention419420Data handling for this offering is governed by Amazon Bedrock. For details, see [Data protection in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/data-protection.html).421422## Monitoring and logging423424Claude in Amazon Bedrock emits logs to both CloudWatch and CloudTrail. Anthropic recommends retaining activity logs on at least a 30-day rolling basis to understand usage patterns and investigate potential issues.425426## Support427428For support, contact **[bedrock-ant-eap@amazon.com](mailto:bedrock-ant-eap@amazon.com)**. Include your AWS account ID and the `request-id` from any failed API responses.429430<Note>431  **Claude Mythos Preview** is a research preview model available to invited customers on Amazon Bedrock. For more information, see [Project Glasswing](https://anthropic.com/glasswing).432</Note>433
Files main
Menu

Theme