Fixed Anthropic Messages API code samples and switched model-card OpenAI-SDK samples to bedrock-runtime: Fixed the Anthropic Messages API Python sample on the Overview page, which previously used anthropic.Anthropic() with no base URL and failed with a val

Published
August 19, 2026
https://docs.aws.amazon.com/bedrock/latest/userguide/inference-messages-api.html

Anthropic Messages API for AWS Bedrock

The Anthropic Messages API provides native access to Claude models using the Anthropic request and response format. Use the Messages API on the bedrock-runtime or bedrock-mantle endpoints for flexibility in authentication and integration.

Endpoints

  • bedrock-runtime: https://bedrock-runtime.{region}.amazonaws.com/anthropic - Recommended for new applications with AWS SDK integrations, IAM authentication, and invocation logging.
  • bedrock-mantle: https://bedrock-mantle.{region}.api.aws/anthropic/v1/messages - Supports Amazon Bedrock API key authentication and Workspaces.

Prerequisites

  • Model access: Request access to Claude models in the Amazon Bedrock console.
  • Authentication:
    • bedrock-runtime: Use AWS SigV4 credentials through the AWS SDK or a short-term Bedrock bearer token.
    • bedrock-mantle: Use an Amazon Bedrock API key or AWS SigV4 credentials.

Basic Request

To send a message to a Claude model:

  • Set the API version header:
    • bedrock-runtime: Include "anthropic_version": "bedrock-2023-05-31" in the request body.
    • bedrock-mantle: Include anthropic-version: 2023-06-01 as an HTTP header.
  • Use the appropriate method to send the message:
    • Python (Anthropic SDK): Use the Anthropic SDK with a short-term Bedrock bearer token.
    • Python (boto3): Use the AWS SDK to invoke the model.
    • AWS CLI: Use the invoke-model command with the necessary parameters.
    • curl: Send the request with AWS SigV4 signing.

Stream Responses

To receive response tokens incrementally:

  • Use the streaming methods provided by the Anthropic SDK or boto3.
  • For curl, include the stream: true parameter in the request body.

Supported Features

  • System prompts, multi-turn conversations, tool use, vision, and prompt caching.

Count Tokens

Use the count_tokens path on the bedrock-mantle endpoint to count input tokens before inference.

Source: AWS release notes




If you need further guidance on AWS, our experts are available at AWS@westloop.io. You may also reach us by submitting the Contact Us form.

Follow our blog

Get the latest insights and advice on AWS services from our experts.

By clicking Sign Up you're confirming that you agree with our Terms and Conditions.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.