View a markdown version of this page

Quickstart - Amazon Bedrock

Quickstart

Get started with Amazon Bedrock in minutes. The following steps walk you through running your first inference request using the Anthropic-native Messages API, the OpenAI-compatible APIs: Responses API and Chat Completions API, and the Invoke and Converse API. For a complete list of APIs, see Build. After you complete these steps, you can send inference requests to any supported foundation model.

To run your first inference request
  1. Sign up for an AWS account.

    If you already have an AWS account, skip this step.

  2. Generate a short-term API key to authenticate your requests to Amazon Bedrock by opening the Amazon Bedrock service in the AWS Management Console.

    For the complete procedure, see the API keys section.

    For production applications, use IAM roles or temporary credentials.

  3. Install the relevant SDK for the APIs you plan to use. Python must already be installed.

    Messages API
    pip install boto3 anthropic
    Responses/Chat Completions API
    pip install boto3 openai
    Invoke/Converse API
    pip install boto3
  4. Set the following environment variables to use the API key for authentication.

    Messages API
    ANTHROPIC_API_KEY="<provide your Bedrock API key>" ANTHROPIC_BASE_URL="https://bedrock-mantle.<your-region>.api.aws/anthropic"
    Responses/Chat Completions API
    OPENAI_API_KEY="<provide your Bedrock API key>" OPENAI_BASE_URL="https://bedrock-runtime.<your-region>.amazonaws.com/openai/v1"
    Invoke/Converse API
    AWS_BEARER_TOKEN_BEDROCK="<provide your Bedrock API key>"
  5. Choose a model and run your first inference request.

    1. Choose a model. Amazon Bedrock supports 100+ foundation models.

    2. Use the following Python code to run your first inference request.

      Messages API
      import anthropic client = anthropic.Anthropic() response = client.messages.create( model="anthropic.claude-opus-4-7", max_tokens=1024, messages=[{"role": "user", "content": "Can you explain the features of Amazon Bedrock?"}] ) print(response)
      Responses API
      from openai import OpenAI client = OpenAI() response = client.responses.create( model="openai.gpt-oss-120b", input="Can you explain the features of Amazon Bedrock?" ) print(response)
      Chat Completions API
      from openai import OpenAI client = OpenAI() response = client.chat.completions.create( model="openai.gpt-oss-120b", messages=[{"role": "user", "content": "Can you explain the features of Amazon Bedrock?"}] ) print(response)
      Converse API
      import boto3 client = boto3.client('bedrock-runtime', region_name='us-east-1') response = client.converse( modelId='anthropic.claude-opus-4-7', messages=[ { 'role': 'user', 'content': [{'text': 'Can you explain the features of Amazon Bedrock?'}] } ] ) print(response)
      Invoke API
      import json import boto3 client = boto3.client('bedrock-runtime', region_name='us-east-1') response = client.invoke_model( modelId='anthropic.claude-opus-4-7', body=json.dumps({ 'anthropic_version': 'bedrock-2023-05-31', 'messages': [{ 'role': 'user', 'content': 'Can you explain the features of Amazon Bedrock?'}], 'max_tokens': 1024 }) ) print(json.loads(response['body'].read()))
    3. Save the file as bedrock-first-request.py.

    4. Run the code with the following command:

      python3 bedrock-first-request.py

      You should see the output of your inference request.

To learn more about using other APIs and endpoints, see Build.

Next steps

Now that you have run your first request, explore the following resources to build more with Amazon Bedrock: