- Newest
- Most votes
- Most comments
The error you're encountering suggests there's a conflict between the prompt caching configuration in your request header and the message body. Even though you've set explicitPromptCaching: 'enabled' in your request header, it seems that the message body of your request might be contradicting this setting.
To resolve this issue, you should check the following:
-
Ensure that your request body (which is not shown in your provided code snippet) doesn't have any conflicting cache control settings. Look for any
cache_controlproperties in your message body that might be set to disable caching. -
Make sure you're structuring your request body correctly. For the Claude 3.5 Sonnet v2 model, your body should include elements like
anthropic_version,system,messages, and other parameters. Within themessagesarray, you can set cache control for specific parts of your prompt. -
If you're setting cache checkpoints in your request body, ensure they meet the minimum token requirement for the Claude 3.5 Sonnet v2 model.
-
Double-check that you're not accidentally disabling caching in any part of your request, either in the header or the body.
-
Verify that you're using the correct API call. For the InvokeModel API, prompt caching is enabled by default, so you might not need to explicitly enable it unless you're trying to modify its behavior.
If the issue persists after checking these points, you might want to try removing the explicitPromptCaching parameter from your request header altogether, as prompt caching is enabled by default for the InvokeModel API.
Remember, when using prompt caching, you need to structure your request carefully to ensure that the caching behavior aligns across both the header and the body of your request.
Sources
Prompt caching for faster model inference - Amazon Bedrock
Reduce costs and latency with Amazon Bedrock Intelligent Prompt Routing and prompt caching (preview) | AWS News Blog
Prompt Caching - Amazon Bedrock
answered 2 years ago
Relevant content
asked 4 months ago
asked 2 years ago
- AWS OFFICIALUpdated 24 days ago
- AWS OFFICIALUpdated 19 days ago

I removed explicitPromptCaching from my request header, but I get the same issue. My request body contains:
{ role: 'user' content: [{type: 'text', text: <pdf content>, cache_control: {type: 'ephemeral'}}, {type: 'text', text: 'what is this pdf about'}] }
Also to note, the request works without prompt caching