How do I access Anthropic Claude models on Amazon Bedrock?

2 minute read
0

I want to access Anthropic Claude models on Amazon Bedrock, but I don’t know how to.

Short description

Because the process to request access is different from other foundation models, you might not be able to access Anthropic Claude models on Amazon Bedrock. To get access to Anthropic Claude models, submit a use case details form. After you're granted access, save your changes.

Resolution

Request access to Anthropic Claude models on Amazon Bedrock

To access Anthropic Claude models on Amazon Bedrock, complete the following steps:

  1. Open the Amazon Bedrock console.
  2. In the navigation pane, choose Model access.
  3. Choose Submit use case details, and then enter the information. Then, choose Submit.
  4. Wait for the Submit use case details button to become grayed out.
  5. Select Anthropic, and then choose Save changes.

Test your access to Anthropic

To test if you can access the Anthropic Claude models, use the Text or Chat feature on the Amazon Bedrock console. Or, you can use the API call.

In the following example, an Amazon SageMaker role is configured for Amazon Bedrock. To test the Amazon Bedrock runtime setup, run the following 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-v2'
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-v2')
AWS OFFICIAL
AWS OFFICIALUpdated 3 months ago
3 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

Jody
replied a month ago

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

profile pictureAWS
MODERATOR
replied a month 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.

nmudkey
replied 25 days ago