Skip to content

[AWS Bedrock]: Max tokens for Claude models are much lower when using on-demand throughput

0

The max token quotas for Claude on-demand throughput models are much lower than what the underlying models can support. For instance, Anthropic Claude Sonnet 4 in Amazon Bedrock has a max context window of 200k tokens (https://aws.amazon.com/bedrock/anthropic). However, invoking Claude 4 Sonnet with on-demand throughput (us.anthropic.claude-sonnet-4-20250514-v1:0) and setting the max token limit to 200k tokens results in the following error:

An error occurred (ValidationException) when calling the InvokeModelWithResponseStream operation: 
The maximum tokens you requested exceeds the model limit of 65536

Similarly, Claude 3.7 Sonnet in Amazon Bedrock has a max context window of 200k tokens. Surprisingly, invoking Claude Sonnet 3.7 with on-demand throughput (us.anthropic.claude-3-7-sonnet-20250219-v1:0) results in a similar error, but with a much higher max token limit:

 An error occurred (ValidationException) when calling the InvokeModelWithResponseStream operation: 
The maximum tokens you requested exceeds the model limit of 131072

Where can I find documentation for the max token limits for Claude models when used with on-demand throughput? And what explains these different max token limits? My use-case requires the 200k token limit.

Thank you for your help.

P.S: Both of these tests were performed using the Python langchain_aws (https://github.com/langchain-ai/langchain-aws) package.

3 Answers
1

Adding clarification as the one from AWS Generative AI is not entirely correct and can be misleading.

As per the error, this is a limitation/constraint on the model itself. It has nothing to do with on-demand usage. The error states: The maximum tokens you requested exceeds the model limit of 131072 for Sonnet 3.7. This is inline with Max output setting on that model (128K). Similarly for Sonnet 4, the max output limit communicated by Anthropic is 64K (which equivalent to 65536. You will only get this error if you configure max_tokens (which represent number of tokens to be generated, i.e output) to a value higher than Max output tokens. max_tokens take the number of input tokens you are sending.

On the AWS console and using API, you can send input of nearly 200k token to Sonnet 3.7 and 4 without encountering this issue. See screenshot for 4.5 (from https://docs.claude.com/en/docs/about-claude/models/overview, reference might change in the future).

Specifically for strands sdk, max_tokens is described as Maximum number of tokens to generate

Enter image description here

answered a year ago

0

When using Claude models with on-demand throughput in Amazon Bedrock, there are indeed differences between the advertised context window sizes and the actual token limits you can use in practice.

For Claude models on Amazon Bedrock, there are two important considerations:

  1. Token Limits vs. Context Window: While the models have a 200K token context window capability, the actual token limits for on-demand usage are lower. Claude Sonnet 4 appears to have a 65,536 token limit for on-demand usage, while Claude 3.7 Sonnet has a higher limit of 131,072 tokens.

  2. Prompt + Response Tokens: It's important to note that the max_tokens parameter represents the combined total of your prompt tokens plus the maximum number of tokens you want in the response. With newer Claude models (3.7 and 4), if the sum of prompt tokens and max_tokens exceeds the model's context window, the system will return a validation error rather than automatically adjusting the max_tokens value.

When using extended thinking features with Claude models, additional considerations apply. For example, the thinking budget (if enabled) must be set to a value less than max_tokens, except when using Interleaved thinking with tools, where the token limit becomes your entire context window (200K tokens).

If you need higher token limits or throughput for your application, you have a few options:

  1. Contact AWS Support directly to request quota increases for specific models. This requires creating a support case and explaining your use case in detail.

  2. Consider using Provisioned Throughput instead of on-demand if you need consistent access to higher token limits, though this comes with additional costs.

  3. Implement retry logic with exponential backoff in your application to handle any throttling exceptions that might occur.

Unfortunately, detailed documentation specifically about the max token limits for on-demand throughput with Claude models can be hard to find. The behavior you're experiencing suggests that while the models technically support 200K tokens, the on-demand service has different limits applied.
Sources
Extended thinking - Amazon Bedrock
Why cant i invoke claude 3.5 more than one per minute ? | AWS re:Post
Building Agentic AI app with Strands Agents & MCP | AWS re:Post
Can not increate invokeModel request to Claude 3.5 Sonnet v2 | AWS re:Post

answered a year ago

EXPERT

reviewed a year ago

-1

Here you can find the token limits for all the Anthropic models: https://docs.anthropic.com/en/docs/about-claude/models/overview

I would recommend setting the max token to 131000 for Sonnet 3.7 and 65000 for Sonnet 4. It worked for me and might as well work for you.

answered a year ago

  • The link you provided states that each model has a context window of 200000. The link doesn't explain the limits I am encountering when using on-demand throughput, of 65536 for Claude Sonnet 4, or 131072 for Claude 3.7 Sonnet

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.