Skip to content

How do I enable access to Anthropic Claude models on Amazon Bedrock?

3 minute read
0

I want to enable access to Anthropic Claude models on Amazon Bedrock.

Resolution

Request access to Anthropic Claude models on Amazon Bedrock

Note: You must use the Amazon Bedrock console to manage model access.

Supported Regions

To access Anthropic Claude models on Amazon Bedrock, in supported AWS Regions, complete the following steps:

  1. Open the Amazon Bedrock console.
  2. In the navigation pane, under Bedrock configurations, choose Model access.
  3. Choose Modify model access.
  4. Choose Submit use case details.
  5. Fill out the form, and then choose Submit form. If your request is successful, then the Access status changes to Access granted or to Available to request.

AWS GovCloud Regions

To access Anthropic Claude models on Amazon Bedrock in AWS GovCloud Regions, complete the following steps:

  1. Find your standard AWS account ID that's associated with your AWS GovCloud (US) account ID.
  2. Use your standard AWS account ID to turn on model access.
  3. Sign in to your AWS GovCloud (US) account and navigate to the Amazon Bedrock required Region. Then, follow the model access sign-up steps provided in the preceding section for access in supported AWS Regions. This grants you a Regional entitlement to access the models in that Region.

The model is accessible to the linked AWS GovCloud (US) account.

Test your access to Anthropic

To test whether you can access the Anthropic Claude models, use the Text or Chat playgrounds feature on the Amazon Bedrock console. Or, you can use the AWS SDK for Python (Boto3) to make an API call to Bedrock runtime.

Example command:

import boto3
import json
bedrock = boto3.client(service_name='bedrock-runtime')

body = json.dumps({
    "prompt": "\n\n
Human:explain black holes to 8th graders\n\n
Assistant:",
    "max_tokens_to_sample": 300,
    "temperature": 0.1,
    "top_p": 0.9,
})

modelId = 'anthropic.claude-3-sonnet-20240229-v1:0'
accept = 'application/json'
contentType = 'application/json'

response = bedrock.invoke_model(body=body, modelId=modelId, accept=accept, contentType=contentType)

response_body = json.loads(response.get('body').read())
# text
print(response_body.get('completion'))

To test the Amazon Bedrock setup, run the following command:

import boto3
bedrock = boto3.client(service_name='bedrock')
bedrock.get_foundation_model(modelIdentifier='anthropic.claude-3-sonnet-20240229-v1:0')

Note: To make API calls to Amazon Bedrock models, add permissions to the AWS Identity and Access Management (IAM) role or user entity.

You can only access Anthropic models from supported countries, regions, or territories. When you try to access Anthropic models from unsupported countries, regions, or territories, you might receive the following error:

"Claude 3.x Sonnet - Access to Anthropic models is not allowed from unsupported countries, regions, or territories."

Note: Your AWS account and billing address must also be in a supported country, region, or territory for Anthropic models. For more information, see Supported Countries for Anthropic Models on the Anthropic website.

Related information

How do I resolve the "Unauthorized to perform action due to private marketplace eligibility" error I receive when I access models on Amazon Bedrock?

4 Comments

How long is this model access approval process supposed to take? I submitted my use case for the Claude models 2 weeks ago. I'm trying to use Amazon Bedrock, so Knowledge Base + RAG + Foundation Model. I'd happily test with another FM, but ONLY the Anthropic Claude models can be used as the FM at the moment. And to do that you need the model access approved. Dead in the water, please help! :) Thank you

replied 2 years ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

AWS
MODERATOR
replied 2 years ago

You must save changes to enable model access for Anthropic. If you are unable to gain access by saving changes even after the "Submit use case details" is grayed out, please raise a ticket with AWS Support.

replied 2 years ago

If you encounter a "ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: "claude-3-sonnet-20240229" is not supported on this API. Please use the Messages API instead.", please see the following sample code:

import boto3
import json

bedrock = boto3.client(service_name='bedrock-runtime')

body = json.dumps({
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 300,
    "temperature": 0.1,
    "top_p": 0.9,
    "messages": [
        {
            "role": "user",
            "content": "explain black holes to 8th graders"
        }
    ]
})

modelId = 'anthropic.claude-3-sonnet-20240229-v1:0'
accept = 'application/json'
contentType = 'application/json'

response = bedrock.invoke_model(body=body, modelId=modelId, accept=accept, contentType=contentType)

response_body = json.loads(response.get('body').read())
print(response_body['content'][0]['text'])
AWS
SUPPORT ENGINEER
replied 5 months ago