Inference using Anthropic Messages API
The Anthropic Messages API provides native access to Claude models using the Anthropic
request and response format. You can use the Messages API on both the
bedrock-runtime and bedrock-mantle endpoints, giving you
flexibility to choose the authentication and integration style that fits your application.
For new applications, we recommend the bedrock-runtime endpoint.
| Endpoint | Base URL | Use case |
|---|---|---|
bedrock-runtime |
https://bedrock-runtime.{region}.amazonaws.com/anthropic |
Recommended for new applications. Uses 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 (Anthropic-compatible). |
Supported Regions
The Messages API is available on the bedrock-runtime endpoint in all
Regions where Claude models are available. See Regional availability by models for details. On the bedrock-mantle
endpoint, it is available in all Regions that support bedrock-mantle (see
Supported Regions and Endpoints).
Prerequisites
Before using the Messages API, make sure you have the following:
-
Model access – Request access to Claude models in the Amazon Bedrock console. See Request access to models.
-
Authentication – Depends on the endpoint:
-
bedrock-runtime– Use AWS SigV4 credentials through the AWS SDK (boto3, etc.), or use a short-term Bedrock bearer token generated from AWS credentials with the aws-bedrock-token-generatorlibrary when calling the endpoint with the Anthropic SDK. -
bedrock-mantle– Use a Amazon Bedrock API key (see API keys) or AWS SigV4 credentials.
-
-
Anthropic version header – All requests require an API version:
-
bedrock-runtime: Set"anthropic_version": "bedrock-2023-05-31"in the request body when callingInvokeModel. The Anthropic SDK adds the required header automatically when usingbase_url=https://bedrock-runtime.{region}.amazonaws.com/anthropic. -
bedrock-mantle: Setanthropic-version: 2023-06-01as an HTTP header.
-
Basic request
To send a basic message to a Claude model, choose the tab for your preferred method, and then follow the steps:
Stream responses
To receive response tokens incrementally as they are generated, choose the tab for your preferred method, and then follow the steps:
Supported features
In addition to the Extended thinking, Adaptive thinking, Structured outputs, Compaction, Fallback credit for refused requests (beta), and Mid-conversation system messages sections above, the Messages API supports the following features with Claude models:
-
System prompts – Set model behavior with a
systemparameter. -
Multi-turn conversations – Pass alternating
userandassistantmessages. -
Tool use – Define tools the model can call. See Use a tool to complete an Amazon Bedrock model response.
-
Vision – Send images in the
contentarray alongside text. -
Prompt caching – Cache frequently used context to reduce latency and cost.
For the full Messages API request and response field reference, see Request and Response.
Count tokens
To count the number of input tokens that a request would consume before sending it for inference, use the Anthropic count_tokens path on the bedrock-mantle endpoint. This is the only token-counting path supported for Claude models that are not available on bedrock-runtime with a Region-specific endpoint, including Claude models that launch with cross-Region inference (CRIS) only. For details and an example, see Count tokens using the bedrock-mantle endpoint.