Artificial Intelligence1 min read

Use prompt caching with open-weight models on Amazon Bedrock

By · Published by Everything Blog

In short

The new prompt caching capability on Amazon Bedrock operates through the Bedrock Runtime endpoint using short-term API keys to process reusable context efficiently. Developers can choose between automatic implicit caching for ongoing conversational flows or manual explicit caching through the Chat Completions API. Explicit caching allows engineers to set specific breakpoints for fixed shared prefixes, avoiding unnecessary cache write charges on models where writes exceed standard input pricing. System configurations like minimum prefix lengths and time-to-live settings vary depending on the chosen model.

Key points

  • Implicit caching functions automatically on a best-effort basis for agent loops and multi…: Implicit caching functions automatically on a best-effort basis for agent loops and multi-turn conversations.
  • Setting explicit breakpoints prevents costly cache writes when pairing static documentati…: Setting explicit breakpoints prevents costly cache writes when pairing static documentation with varying user questions.
  • Both caching modes run via the Amazon Bedrock Runtime endpoint using short-term Bedrock A…: Both caching modes run via the Amazon Bedrock Runtime endpoint using short-term Bedrock API keys.

Sources checked by our analysis pipeline: 1

Artificial Intelligence

Use prompt caching with open-weight models on Amazon Bedrock

Many generative AI applications send the same long context with every request, and prompt caching avoids processing it again each time. That context can be a system prompt, reference documents, tool definitions, or the conversation so far. Open-weight models on Amazon Bedrock can reuse it across requests, which helps reduce input costs and response latency.

Prompt caching reuses the computed state of a matching prompt prefix, so repeated context is read from cache instead of being processed again. Amazon Bedrock manages the cache for you. Depending on the model, you can use implicit caching, which works automatically, explicit caching, where you mark the reusable prefix, or both. The more context you reuse, and the more often you reuse it, the more you can save.

As with other models on Amazon Bedrock, your prompts and outputs aren’t shared with the model provider or used to train models. For more information, see Data protection in the Amazon Bedrock User Guide.

Open-weight models on Amazon Bedrock now support explicit prompt caching. In…

Artificial Intelligence