Guide

Optimizing Cost and Latency with Amazon Bedrock Prompt Caching

Best practices, pricing, and Converse API implementation patterns to reduce token costs and latency

3 min read
עב
Optimizing Cost and Latency with Amazon Bedrock Prompt Caching
Based on original reporting byAWS Machine Learning ↗Translated and summarized by our AI-assisted news systemHow we work

Executive summary

What to know

  1. Prompt caching in Amazon Bedrock can reduce input token costs by up to 90 percent on cache hits and shorten TTFT.

  2. Anthropic Claude Sonnet 4.5 and 4.6 models require a minimum threshold of 1,024 tokens to activate caching, while Opus models require 4,096 tokens.

  3. The cachePoint syntax in the Converse API is uniform across different model families such as Claude and Amazon Nova.

  4. Tenant isolation in multi-tenant systems is implemented using a SHA-256 hash prefix with an overhead of only approximately 16 tokens.

In a post published by Daniel Abib, Specialist Solutions Architect for Generative AI at AWS, it is explained how using the prompt caching mechanism in Amazon Bedrock can reduce input token costs by up to 90 percent when repeatedly sending the same context to foundation models, as well as shorten time-to-first-token (TTFT). According to the post, without caching, sending a 10,000-token contract alongside 50 different user questions results in billing for 500,000 input tokens at full price for content the model has already processed.

The author notes that alternative approaches for managing costs include shortening prompts (which might compromise context quality), reducing context windows (which degrades the model's ability to reason over complete information), and response caching (which provides no benefit when the same context is paired with different questions). Caching prompts at the infrastructure level enables the model to read cached tokens instead of reprocessing them, without altering the model or prompt quality.

How Prompt Caching Works and Its Pricing

When a request to the Converse API includes a cachePoint marker, Amazon Bedrock evaluates whether the content preceding that marker matches an existing cache entry. In the case of a cache hit, the model skips reprocessing and begins generating output from the cached state. In the event of a cache miss, the model processes the full content and writes the result to the cache for potential future requests.

Four core principles define cache behavior:

  1. Cache scope: Cache entries are scoped strictly to individual AWS accounts and specific AWS Regions.
  2. Minimum token thresholds: Each checkpoint must meet a minimum token threshold to activate caching. For example, Anthropic Claude Sonnet 4.5 and Sonnet 4.6 require at least 1,024 tokens per checkpoint, while Opus models require at least 4,096 tokens.
  3. Time-to-live (TTL): Cache entries expire according to the TTL specified in the request. The default is 5 minutes, with select models supporting up to 1 hour.
  4. Model-agnostic syntax: The cachePoint syntax in the Converse API is identical across supported model families, including Anthropic Claude and Amazon Nova.

In terms of pricing, two new token categories are introduced:

  • cacheWriteInputTokens: Tokens written to the cache on the first request, billed at a cost 25 percent higher than standard input. When utilizing a 1-hour TTL, the cost is 100 percent higher (2x) than standard input.
  • cacheReadInputTokens: Tokens read from the cache on subsequent requests, billed at a cost 90 percent lower than standard input.

For workloads with repeated context, total savings on input token costs reach approximately 75 percent (for instance, a 10,000-token document queried with 10 different questions within the TTL window).

Converse API Use Cases

The post outlines six practical implementation scenarios in Python code using the Converse API:

  1. Message content and long document caching: Placing a cachePoint marker after static document content and before the dynamic user question. In RAG or codebase analysis workflows, Amazon Bedrock caches the document on the first call and might reuse it on subsequent calls. For Claude models, simplified cache management is supported, where a single checkpoint checks for matches across up to approximately 20 preceding content blocks.
  2. System prompt caching: Persona definitions, detailed instructions, and embedded knowledge bases within the system prompt are preserved by placing a cachePoint inside the system parameter, separate from user messages.
  3. Tool definition caching: In agentic workflows, numerous JSON tool schemas can comprise thousands of tokens. Appending a cachePoint at the end of the tool array within toolConfig enables reuse without reprocessing schemas on every conversation turn.
  4. Mixed TTL caching: Assigning different expiration times to different content tiers within the same request—such as 1 hour for reference materials and tool definitions, and 5 minutes for momentary conversation context. The API enforces an ordering constraint where longer TTL checkpoints must appear before shorter TTL checkpoints.
  5. Tenant isolation in multi-tenant systems: To prevent cross-tenant cache access within the same AWS account and Region, a SHA-256 hash prefix of the tenant ID is prepended to the cached content. This creates an independent cache entry for each tenant with an overhead of only approximately 16 tokens (64 characters).
  6. LangChain integration: Utilizing the ChatBedrockConverse class and the create_cache_point function to generate cache checkpoints directly within message arrays or within ChatPromptTemplate structures and LCEL chains.

Comparing the Converse API and InvokeModel API and Best Practices

The author compares the interfaces and highlights that while the Converse API offers uniform syntax across all supported models, places cache markers as standalone blocks, and provides a cacheDetails breakdown in responses, the InvokeModel API uses differing syntax for Anthropic models (utilizing ephemeral cache_control inside content blocks without cacheDetails response data). Therefore, the Converse API is recommended for new applications.

In conclusion, best practices include profiling prompts to identify static components, ensuring requests satisfy the required token threshold for each model, selecting suitable TTLs, monitoring cache metrics in application logs, incorporating control mechanisms such as Amazon Bedrock Guardrails, and combining simultaneous caching of messages, system prompts, and tool definitions within the same request.

Was this useful for your business?

Questions & Answers

FAQ

This article was produced by our AI-assisted system through translation, summarization, and automated quality controls based on original reporting by AWS Machine Learning. Read about our editorial process. Link to the original source.

Get useful AI updates by email

A concise digest from our news desk.

More from AWS Machine Learning

All articles from AWS Machine Learning
אימון סוכנים ב-Multi-Turn Reinforcement Learning ב-SageMaker AI
מדריך
5 דקות
מ־AWS Machine Learning

אימון סוכנים ב-Multi-Turn Reinforcement Learning ב-SageMaker AI

מדריך טכני של מהנדסי AWS מציג את השימוש ב-Multi-Turn Reinforcement Learning (MTRL) על גבי Amazon SageMaker AI לאימון סוכני בינה מלאכותית על רצפי פעולות מרובי שלבים. באמצעות הדגמה על משחק Wordle, המאמר מפרט כיצד אימון מודל GPT-OSS-20B בעזרת סביבת Amazon Bedrock AgentCore ואלגוריתם GRPO העלה את שיעור הפתרון מ-61% ל-84% בהגדרות הגשה, בעלות של כ-339 דולר בטוקנים. המדריך כולל פירוט על ארכיטקטורת המערכת, הכנת מערך הנתונים ללא תוויות, נוסחת פונקציית התגמול המפרידה בין תוצאה לעיצוב התנהגות, והתמודדות עם תקלות תשתית ואימות במהלך האימון.

קרא עוד
תשלום לפי קריאה עבור סוכני AI: שילוב AgentCore payments ב-AWS
מוצר חדש
4 דקות
מ־AWS Machine Learning

תשלום לפי קריאה עבור סוכני AI: שילוב AgentCore payments ב-AWS

בפוסט שפרסמו מהנדסי AWS הוצגה היכולת המנוהלת AgentCore payments ב-Amazon Bedrock, המאפשרת לסוכני בינה מלאכותית לשלם לפי דרישה עבור שירותים דוגמת הסקת מודלים. השירות מנהל ארנקים, מטפל בפרוטוקול התשלום x402 ואוכף מגבלות הוצאה ברמת התשתית במקום ברמת המודל. הפוסט מפרט כיצד חברת Incarna שילבה את המערכת כדי לאפשר לסוכנים לשלם לנתב ההסקה BlockRun עבור כל קריאה בנפרד ברשת Base ב-USDC. האינטגרציה הושלמה בשלושה ימים ובכ-200 שורות קוד, ובשלב הבטא עובדו מעל 1,000 תשלומים בסכומים של 0.001 עד 0.05 דולר לקריאה. היכולת זמינה כעת באופן כללי.

קרא עוד
Claude Haiku 5.5 זמין כעת ב-Amazon Bedrock וב-AWS
מוצר חדש
4 דקות
מ־AWS Machine Learning

Claude Haiku 5.5 זמין כעת ב-Amazon Bedrock וב-AWS

חברת AWS הודיעה על זמינות המודל Claude Haiku 5.5 ב-Amazon Bedrock וב-Claude Platform on AWS. לפי Anthropic, המודל הוא המהיר והיעיל ביותר במשפחת Claude 5.5, נבנה עבור תתי-סוכנים ומשימות בנפח גבוה, ועולה כ-75 אחוז פחות מ-Claude Haiku 4.5 במרבית המשימות. השירות ב-Bedrock שומר על תושבות נתונים אזורית ומשתלב עם מנגנוני IAM, CloudTrail, CloudWatch ו-Guardrails. המודל כולל בקרות מאמץ לכוונון עלות מול תבונה, ומיועד להשתלב לצד Claude Opus 5.5 שמבצע את התכנון והשיפוט המורכב. המודל זמין בפרופילי הסקה גלובליים ואזוריים וב-AWS GovCloud.

קרא עוד
בניית סוכן נסיעות קולי עם Bedrock AgentCore ו-Nova Sonic
מדריך
4 דקות
מ־AWS Machine Learning

בניית סוכן נסיעות קולי עם Bedrock AgentCore ו-Nova Sonic

בפוסט טכני של AWS הציגו מומחי החברה ארכיטקטורה לפריסת סוכן נסיעות קולי לחברות תעופה. הפתרון משלב את Amazon Bedrock AgentCore לניהול והרצת סוכנים, מודל הדיבור Amazon Nova 2.5 Sonic לקול בזמן אמת, ו-Amazon Bedrock Knowledge Bases למענה על שאלות מדיניות מתוך מסמכים. המערכת מקשרת בין הסוכן לשירותי ה-backend באמצעות פרוטוקול Model Context Protocol (MCP) ומאפשרת טיפול בהזמנות, החלפת מושבים והסלמה לנציג אנושי.

קרא עוד

More articles you might like

All articles
אימון סוכנים ב-Multi-Turn Reinforcement Learning ב-SageMaker AI
מדריך
5 דקות
מ־AWS Machine Learning

אימון סוכנים ב-Multi-Turn Reinforcement Learning ב-SageMaker AI

מדריך טכני של מהנדסי AWS מציג את השימוש ב-Multi-Turn Reinforcement Learning (MTRL) על גבי Amazon SageMaker AI לאימון סוכני בינה מלאכותית על רצפי פעולות מרובי שלבים. באמצעות הדגמה על משחק Wordle, המאמר מפרט כיצד אימון מודל GPT-OSS-20B בעזרת סביבת Amazon Bedrock AgentCore ואלגוריתם GRPO העלה את שיעור הפתרון מ-61% ל-84% בהגדרות הגשה, בעלות של כ-339 דולר בטוקנים. המדריך כולל פירוט על ארכיטקטורת המערכת, הכנת מערך הנתונים ללא תוויות, נוסחת פונקציית התגמול המפרידה בין תוצאה לעיצוב התנהגות, והתמודדות עם תקלות תשתית ואימות במהלך האימון.

קרא עוד
ניהול מצב בסוכני AI: הבדלים בין ארכיטקטורה בעלת מצב לחסרת מצב
מדריך
4 דקות
מ־n8n

ניהול מצב בסוכני AI: הבדלים בין ארכיטקטורה בעלת מצב לחסרת מצב

בפוסט של n8n מוסבר כי state הוא המידע שסוכן AI נושא בין משימות, החל מהיסטוריית שיחה ועד לזיכרון לטווח ארוך ולפרופילי משתמשים. ההבדל בין ארכיטקטורה בעלת מצב (stateful) לארכיטקטורה חסרת מצב (stateless) מתמקד בשאלה האם המערכת משמרת נתונים מאינטראקציות קודמות או מתחילה כל בקשה כדף חלק. יישומים בעלי מצב מעניקים המשכיות אך דורשים תשתית לאחסון ולניהול מצב, בעוד יישומים חסרי מצב מפשטים חלוקת עומסים ועמידות לתקלות. מודלי LLM אינם שומרים שיחות באופן אוטומטי, ולכן סוכני AI מתנהגים באופן בעל מצב באמצעות שמירה ושליפה של נתונים מחוץ למודל. ב-n8n מוצע לשמור על הרצה חסרת מצב כברירת מחדל, ולהוסיף צומתי זיכרון לסשנים ומאגרי מצב משותפים רק היכן שנדרשת המשכיות.

קרא עוד
כיצד להמשיך הפעלת אפליקציית GitHub Copilot ב-VS Code
מדריך
4 דקות
מ־GitHub AI and ML

כיצד להמשיך הפעלת אפליקציית GitHub Copilot ב-VS Code

מדריך שפורסם בבלוג של GitHub מסביר כיצד להמשיך הפעלת עבודה של אפליקציית GitHub Copilot ישירות בתוך עורך הקוד Visual Studio Code. המעבר מאפשר להעביר את שינויי הקוד, עץ העבודה המבודד והיסטוריית השיחה המלאה אל העורך מבלי להתחיל מחדש או להעתיק קבצים. לפי המדריך, סוכן התוכנה יכול לבצע עבודה חזרתית או מורכבת, ולאחר מכן המפתח יכול לפתוח את ההפעלה ב-VS Code לצורך סקירת שינויים שורה אחר שורה, עריכה ידנית, הרצת בדיקות מקומיות במסוף המשולב, ודחיפת השינויים ישירות לבקשת המשיכה המשויכת למאגר.

קרא עוד
בניית סוכן נסיעות קולי עם Bedrock AgentCore ו-Nova Sonic
מדריך
4 דקות
מ־AWS Machine Learning

בניית סוכן נסיעות קולי עם Bedrock AgentCore ו-Nova Sonic

בפוסט טכני של AWS הציגו מומחי החברה ארכיטקטורה לפריסת סוכן נסיעות קולי לחברות תעופה. הפתרון משלב את Amazon Bedrock AgentCore לניהול והרצת סוכנים, מודל הדיבור Amazon Nova 2.5 Sonic לקול בזמן אמת, ו-Amazon Bedrock Knowledge Bases למענה על שאלות מדיניות מתוך מסמכים. המערכת מקשרת בין הסוכן לשירותי ה-backend באמצעות פרוטוקול Model Context Protocol (MCP) ומאפשרת טיפול בהזמנות, החלפת מושבים והסלמה לנציג אנושי.

קרא עוד