
Reducing Amazon Bedrock costs with prompt caching
A practical guide to reducing repeated input costs while keeping the model and context fixed. Includes a Python lab, synthetic investigation cases, a worked investigation, cache timing experiments and checks for cost, latency and answer quality.
In Evidence In, Findings Out , I described a small investigation service for an operations team. Each request carried a domain glossary, rules for interpreting evidence, and a fresh bundle of observations. The glossary was about 8,000 to 12,000 tokens and stayed the same across calls. The evidence changed.
That repeated glossary is a useful place to look for savings. It contains information that helps the model do its job, so deleting it merely to reduce token counts would change the task. Prompt caching gives us another option: keep the context and reuse the work of processing its unchanged prefix.
This article walks through the economics and provides a small benchmark you can run against Amazon Bedrock. The target is a lower cost per useful investigation while preserving the checks that make the answer useful. We will measure that target instead of assuming that a cheaper response is equally good.
The companion GitHub repository contains the Python lab, 50 synthetic cases, automated checks, a manual review sheet generator and a renderer that turns a run's raw files into the results section of this article. The local tests and SDK request-shape checks have been run. The only measured Bedrock results in this article are in the section "What one bounded run reports". Its tables are generated from the run's files rather than typed in, and the paragraphs after them only read those tables. Every other dollar figure is a calculated example with stated rates.
What prompt caching changes
A model processes its input before it generates an answer. When requests share an eligible prefix, prompt caching can reuse the internal state from processing that prefix. Each request still supplies its complete content and generates an answer for its own question. This mechanism makes repeated reference material a reasonable caching candidate. AWS explains the processing stages and prefix reuse here .
For this lab, the prefix contains the system rules, domain reference and response contract. The evidence and question follow it. Caching does not remove any reference material or change the chosen model.

Figure 1. Keep reusable instructions and reference material together before the changing evidence.
Four limits that apply to every number below
Caching experiments invite the same misreadings again and again. Each is stated once here, so later sections can refer back briefly instead of repeating the warning.
- Unmarked is not off. Bedrock supports implicit caching, where eligible prefixes may be reused automatically, and explicit caching, where a request control marks the reusable content. Both depend on the model and the API. Sending a request without a checkpoint therefore does not necessarily switch caching off. The benchmark calls that arm unmarked, never uncached, and records what the response actually reports. Prompt caching documentation
- Eligible is not hit. A valid checkpoint makes content eligible for reuse; it does not guarantee a hit. A changed prefix or an expired entry prevents reuse. The token counters in the response are the only evidence that reuse happened. The intended scenario, the preflight token count and the diagrams in this article are not evidence.
- The example rates are illustrative. The cost tables and the cost chart use a stated set of example prices to show the arithmetic. They are not a current AWS quote and not measured results. Current prices for your model, geography, service tier and cache TTL belong in your own price record, checked on the Bedrock pricing page before a live run.
- The spending estimate is not a billing cap. The runner refuses to start when its own estimate of token cost exceeds a limit you set. That is an application check, not an AWS-enforced limit. It excludes taxes and unrelated services, and a failed request can incur charges without returning usage. Reconcile with billing before reporting a final total.
Choose a model deliberately
The reference lab targets Claude Sonnet 4.6 through the Converse API, using the US inference profile
us.anthropic.claude-sonnet-4-6 from us-east-1 . The current model card lists a 1,024-token minimum per checkpoint, up to four checkpoints and five-minute or one-hour TTLs, and lists Standard as the only pay-per-token service tier for this model. This lab uses one checkpoint with the default five-minute TTL. The model and feature details were checked on 29 October 2026. Model card This is a separate experiment from the Kimi K2.5 implementation in my earlier article. Its current model card does not document prompt-caching support. A caching result on Sonnet would not establish that moving the earlier service to Sonnet is cheaper. That comparison needs its own complete cost and quality evaluation.
The US profile can route requests among its supported US destination Regions; from
us-east-1 , the card lists N. Virginia, Ohio and Oregon. A source endpoint is not a promise that inference stays in that one Region. The pricing page also lists geo profiles such as us. separately from the global profile, and their rates can differ, so the price record must name the profile you actually call. Check the profile, permissions and data-location requirements before adapting the lab. Inference profile prerequisites Start with the whole request cost
A request can contain ordinary input tokens, tokens written to cache, tokens read from cache and output tokens. Use the applicable price for each bucket.
request cost = ( ordinary input tokens * input price + cache write tokens * write price + cache read tokens * read price + output tokens * output price) / 1,000,000The division assumes prices are quoted per million tokens. In the Converse accounting used here, ordinary input, cache reads and cache writes are separate buckets. Do not count a cached token again at the ordinary input price. Preserve the raw counters so another reader can reproduce the calculation. The response also has cache detail fields for distinguishing write TTLs. TokenUsage API reference
The lab deliberately supports only a single five-minute write rate. It rejects reported one-hour writes instead of applying the wrong rate. Model, geography, service tier and cache TTL all belong in the price record described in limit 3.
Consider ten requests. Each contains 10,000 shared tokens, 2,000 changing input tokens and 500 output tokens. Use these example prices per million tokens:
Token category | Example price |
|---|---|
Ordinary input | $3.00 |
Five-minute cache write | $3.75 |
Cache read | $0.30 |
Output | $15.00 |
Without cache reuse, one request costs $0.0435 and ten cost $0.4350. A first request that writes the shared prefix costs $0.0510. Each subsequent request that reads that complete prefix costs $0.0165. One write followed by nine hits costs $0.1995, a 54.1% reduction in token cost.
The first write is more expensive than an uncached request. The repeated requests recover that extra expense. If the context is never reused, the write premium has bought no saving.

Figure 2. Calculated from the example rates, not measured. The assumptions and data are included in the repository.
Requests sharing the prefix | Uncached cost | One write, remaining requests hit | Saving |
|---|---|---|---|
1 | $0.0435 | $0.0510 | -17.2% |
2 | $0.0870 | $0.0675 | 22.4% |
5 | $0.2175 | $0.1170 | 46.2% |
10 | $0.4350 | $0.1995 | 54.1% |
20 | $0.8700 | $0.3645 | 58.1% |
For a fixed prefix, let
I be its ordinary input rate, W its write rate and R its read rate. With one write and n - 1 hits, the prefix becomes cheaper when:W + (n - 1) * R < n * In > (W - R) / (I - R), provided I > RUnder the example rates,
n must exceed 1.278, so the second request crosses the break-even point. This calculation assumes every later request hits and that changing input and output lengths stay fixed. A real result must account for misses, repeated writes and any change in output length.Timing matters as much as prefix length
A large prompt used once a day may have little caching benefit. A smaller shared reference reused across a short investigation session can be a better candidate. Many supported models use a five-minute TTL that refreshes on a successful hit; supported longer TTLs have their own conditions and prices. Caching behavior and limits

Figure 3. A successful hit at minute six can keep a five-minute entry usable until minute eleven. The minute-twelve request comes after that window.
The earlier investigation service had a workload of roughly 660 jobs per month. That total cannot tell us whether caching pays. The useful evidence is the spacing of requests that share exactly the same reference. Several analysts working on one incident may generate a burst. Daily reports may be isolated. Those patterns should be measured separately.
Do not send artificial production traffic just to keep the cache warm without calculating its cost. It can turn an occasional workload into a continuous bill. The lab's delay option exists to study timing, not to recommend keep-alive traffic.
Run the lab without AWS first
You need Python 3.11 or newer and Git. Clone the repository and create a virtual environment. On Windows PowerShell:
git clone https://github.com/Mohammad-Yasfo/bedrock-prompt-caching-lab.gitcd bedrock-prompt-caching-labpython -m venv .venv.\.venv\Scripts\python.exe -m pip install -r requirements.txt.\.venv\Scripts\python.exe -m unittest discover -s tests -v.\.venv\Scripts\python.exe -m lab.benchmark offlineOn macOS or Linux, use
.venv/bin/python in place of the Windows executable path. Activation is optional because the commands address the environment directly.The offline command writes a complete request preview and the calculated economics to
results/offline . It does not create an AWS client or generate model answers. There is no simulated latency or invented quality score. Review the preview to see exactly what would be submitted during a live call.
The dataset contains 50 fictional cases spanning deteriorating approval rates, normal observations, missing data, silent traffic and small samples. Expected answers remain in the local evaluator. Only the question and evidence enter the user message.
These cases are intentionally narrow. They make several failures easy to detect, but ten numeric variations of one pattern are not ten independent business scenarios. Extend the dataset with representative, approved cases before drawing a production conclusion.
Walk through one investigation
The smoke experiment later in this article uses the first five cases:
decline-01 , normal-01 , missing-01 , silent-01 and small_sample-01 . Here is the first one from evidence to verdict. The user message the lab sends is this JSON, shown here with line breaks for reading. The keys are sorted so that both arms send identical bytes:{ "evidence": [ { "attempts": 1000, "id": "E1", "provider": "provider-01", "successes": 400, "type": "current", "window": "matched-hour" }, { "attempts": 1000, "id": "E2", "provider": "provider-01", "successes": 900, "type": "baseline", "window": "matched-hour" } ], "question": "Assess this provider using the reference rules. Return the required JSON record."}The shared prefix in front of it carries the reference rules, and three of them decide this case. Both records cover the same matched-hour window and each has at least 200 attempts, so the sample-size rules do not apply. The current success rate is 400 divided by 1,000, or 0.4000, and the baseline rate is 0.9000. Rule 5 says to return
investigate when the current rate is strictly less than half the baseline rate. Half of 0.9 is 0.45, and 0.4 is below it. The expected record is therefore investigate , with a rate of 0.4 and citations of E1 and E2 . That record stays in cases.json on the workstation and never enters the prompt:{"decision": "investigate", "current_success_rate": 0.4, "required_evidence_ids": ["E1", "E2"]}The automated evaluator accepts a returned answer only when all of the following hold: it is one JSON object with exactly the four required fields; the decision is
investigate ; the rate is within 0.00005 of 0.4; the citations are unique, exist in the bundle and include both E1 and E2 ; and the response stopped with end_turn rather than running out of tokens. It does not read the explanation. An answer could pass every check and still state that issuer declines caused the drop, which this evidence cannot show. That is the sentence the review sheet exists to catch.The other four cases probe the edges of the same rules.
normal-01 has 880 successes, so the rule does not fire and the decision is normal . missing-01 has no baseline record, so the rate is still 0.4 but the decision is insufficient_evidence , citing E1 alone. silent-01 has zero current attempts, so the rate must be the JSON literal null and the decision is investigate . small_sample-01 has 50 attempts, below the lab threshold, so the decision is insufficient_evidence even though its rate is also 0.4. The results section shows the model's returned answers for decline-01 from both arms, re-indented but otherwise as the lab saved them.Prepare a bounded live experiment
Use an existing AWS profile with temporary credentials. For an IAM Identity Center profile, authenticate through the AWS CLI SSO flow :
aws sso login --profile YOUR_AWS_PROFILECopy-Item example-prices.json prices.local.jsonEdit
prices.local.json . Replace all four rates with the applicable current prices, keep the model and source Region consistent with the run, set verified to true , and put the date you checked them in verified_on using YYYY-MM-DD . The runner requires a date within the last seven days. The local price file and results are excluded from Git.Your AWS identity needs
bedrock:InvokeModel for the selected inference profile and its destination foundation-model resources, plus the permissions required for token counting. Use the AWS inference-profile permission guidance and token-counting prerequisites to scope those permissions to your account. The lab does not create IAM roles or enable model access.
Figure 4. The lab runs on a workstation and makes only CountTokens and Converse calls. The prompt cache is managed by Amazon Bedrock. Results stay local.
Before inference, the runner calls CountTokens with the foundation-model ID
anthropic.claude-sonnet-4-6 . It uses the inference profile for the later Converse calls. CountTokens is model-specific and has its own availability constraints. If preflight is unsupported or denied in your environment, the lab stops before paid inference; it does not substitute a character-count estimate. CountTokens API
The cost estimate prices every input token at the higher of the ordinary input and five-minute write rates, reserves the maximum configured output for each call, and adds a 10% allowance. The runner refuses to proceed if that estimate exceeds
--max-usd . Limit 4 describes what that check is not.Run the five-case smoke experiment:
.\.venv\Scripts\python.exe -m lab.benchmark run --profile YOUR_AWS_PROFILE --experiment session-a --mode paired --limit 5 --repeats 2 --max-usd 1 --out results/session-aThis plans 20 model calls: five cases, two arms and two repetitions. The runner disables automatic SDK retries and makes no repair calls. If a request fails, it stops and preserves completed results; limit 4 applies to the failed call.
The request change is small
The explicit arm appends a checkpoint after the shared system text:
system = [ {"text": shared_reference}, {"cachePoint": {"type": "default"}}]
response = client.converse( modelId="us.anthropic.claude-sonnet-4-6", system=system, messages=[{ "role": "user", "content": [{"text": evidence_and_question}] }], inferenceConfig={"maxTokens": 600, "temperature": 0})The unmarked arm uses the same text and generation settings, with the checkpoint omitted. This is the request structure supported by Converse and CachePointBlock . The reference file is substantial enough for the 1,024-token minimum; the preflight count is a coarse sanity check, and limit 2 says where the evidence of reuse comes from.

Figure 5. Both arms send the same prompt to the same model; only the checkpoint differs. Usage, cost and duration are recorded per request, then checked automatically and by a reviewer.
The experiment identifier and reference revision appear at the start of the prefix. Keep them fixed while comparing arms. Use a fresh experiment identifier for a separate experiment. Changing these labels intentionally changes the prefix, so do not compare runs with different labels and describe their prompts as byte-for-byte identical.
Read the actual cache behavior
Open
requests.jsonl and inspect usage for each call. The lab labels the observation as none , write , read or read_and_write . These labels come from the returned token counters, not from the intended scenario.The summary includes total token cost, automated pass rate, cost per passing case, the fraction of input tokens read from cache, and median and p95 request duration. Duration is measured around the synchronous Converse call. It includes the request's wall-clock wait and is not a time-to-first-token measurement.
The report also calculates a priced uncached equivalent by applying ordinary input prices to the same observed input-token total. This isolates the arithmetic effect of cache billing. It is not a separate uncached execution, and it cannot establish uncached latency or answer quality.
If the unmarked arm shows cache reads, that is limit 1 in practice. Report a comparison between unmarked and explicitly marked requests, not between caching on and off. The runner alternates arm order across repetitions, but that does not remove shared cache state or make the experiment independent of infrastructure load.
A summary can be rebuilt locally:
.\.venv\Scripts\python.exe -m lab.benchmark report results/session-aExisting human review entries in
review.csv are preserved. A later report writes a separate blank review-template.csv if the original review file already exists.What one bounded run reports
This section was produced by
tools/render_run.py from the raw files of one run. The run started on 2026-10-31 (UTC) and sent 20 completed requests to us.anthropic.claude-sonnet-4-6 from us-east-1 using boto3 1.43.8. Prices were taken from a local price file verified on 2026-10-29 against the Bedrock pricing page .Setting | Value |
|---|---|
Experiment and reference revision | session-c , revision 1 |
Cases, arms and repeats | 5 cases, 2 arms, 2 repeats: 20 planned calls |
Completed and failed calls | 20 completed, 0 failed |
Generation settings | max 600 output tokens, temperature 0 |
Gap between calls | 15 seconds |
Prefix SHA-256 (first 12 characters) | 7b907cd5420b |
Estimated upper token cost with 10% allowance | $0.3874 |
Rates per million tokens | input $3.30, five-minute write $4.125, cache read $0.33, output $16.50 |
Every request, in the order sent. Token columns are the counters returned by Converse.
Call | Arm | Case | Repeat | Cache state | Input | Cache read | Cache write | Output | Cost | Seconds | Checks |
|---|---|---|---|---|---|---|---|---|---|---|---|
1 | unmarked | decline-01 | 1 | none | 1861 | 0 | 0 | 195 | $0.0094 | 2.96 | passed |
2 | unmarked | normal-01 | 1 | none | 1861 | 0 | 0 | 165 | $0.0089 | 2.96 | passed |
3 | unmarked | missing-01 | 1 | none | 1817 | 0 | 0 | 140 | $0.0083 | 2.26 | passed |
4 | unmarked | silent-01 | 1 | none | 1860 | 0 | 0 | 148 | $0.0086 | 2.58 | passed |
5 | unmarked | small_sample-01 | 1 | none | 1860 | 0 | 0 | 166 | $0.0089 | 2.62 | passed |
6 | explicit | decline-01 | 1 | write | 117 | 0 | 1744 | 160 | $0.0102 | 2.50 | passed |
7 | explicit | normal-01 | 1 | read | 117 | 1744 | 0 | 183 | $0.0040 | 3.10 | passed |
8 | explicit | missing-01 | 1 | read | 73 | 1744 | 0 | 117 | $0.0027 | 2.30 | passed |
9 | explicit | silent-01 | 1 | read | 116 | 1744 | 0 | 148 | $0.0034 | 2.92 | passed |
10 | explicit | small_sample-01 | 1 | read | 116 | 1744 | 0 | 154 | $0.0035 | 2.40 | passed |
11 | explicit | decline-01 | 2 | read | 117 | 1744 | 0 | 182 | $0.0040 | 2.78 | passed |
12 | explicit | normal-01 | 2 | read | 117 | 1744 | 0 | 165 | $0.0037 | 3.01 | passed |
13 | explicit | missing-01 | 2 | read | 73 | 1744 | 0 | 143 | $0.0032 | 2.57 | passed |
14 | explicit | silent-01 | 2 | read | 116 | 1744 | 0 | 148 | $0.0034 | 2.52 | passed |
15 | explicit | small_sample-01 | 2 | read | 116 | 1744 | 0 | 154 | $0.0035 | 2.42 | passed |
16 | unmarked | decline-01 | 2 | none | 1861 | 0 | 0 | 193 | $0.0093 | 3.06 | passed |
17 | unmarked | normal-01 | 2 | none | 1861 | 0 | 0 | 165 | $0.0089 | 3.02 | passed |
18 | unmarked | missing-01 | 2 | none | 1817 | 0 | 0 | 141 | $0.0083 | 2.55 | passed |
19 | unmarked | silent-01 | 2 | none | 1860 | 0 | 0 | 148 | $0.0086 | 2.58 | passed |
20 | unmarked | small_sample-01 | 2 | none | 1860 | 0 | 0 | 158 | $0.0087 | 2.54 | passed |
Per-arm totals from
summary.json :Metric | unmarked | explicit |
|---|---|---|
Completed requests | 10 | 10 |
Passed automated checks | 10 of 10 | 10 of 10 |
Requests with cache reads | 0 | 9 |
Share of input tokens read from cache | 0.0% | 84.8% |
Token cost | $0.0878 | $0.0416 |
Cost per passing case | $0.0088 | $0.0042 |
Priced uncached equivalent | $0.0878 | $0.0868 |
Duration p50 (seconds) | 2.60 | 2.55 |
Duration p95 (seconds) | 3.06 | 3.10 |
Over the same cases, the explicit arm's token cost was 52.7% lower than the unmarked arm's. Automated checks passed on 10 of 10 explicit requests and 10 of 10 unmarked requests.
Returned answers for decline-01
The first
unmarked request for this case (repeat 1) reported cache state none , cost $0.0094, duration 2.96 seconds, stop reason end_turn and automated checks passed. The saved answer, re-indented for reading:{ "decision": "investigate", "current_success_rate": 0.4, "evidence_ids": [ "E1", "E2" ], "explanation": "The current success rate of 0.4000 (400/1000) is strictly less than half the baseline rate of 0.9000 (900/1000), where half the baseline is 0.4500, triggering the investigate threshold. Both windows contain 1000 attempts, satisfying the 200-attempt minimum, and cover matching intervals, so the comparison is valid; the absolute decline is 50 percentage points with a relative decline of approximately 55.56 percent. As a next step, inspect recent error-code distributions for provider-01 over the same matched-hour interval and review provider health indicators to identify whether the decline reflects issuer-side rejections, routing changes, or a collection anomaly."}The first
explicit request for this case (repeat 1) reported cache state write , cost $0.0102, duration 2.50 seconds, stop reason end_turn and automated checks passed. The saved answer, re-indented for reading:{ "decision": "investigate", "current_success_rate": 0.4, "evidence_ids": [ "E1", "E2" ], "explanation": "The current success rate of 0.4000 (400/1000) is strictly less than half the baseline rate of 0.9000 (900/1000), where half the baseline is 0.4500, triggering the investigate threshold. Both windows are matched-hour with 1000 attempts each, satisfying the 200-attempt minimum for a valid comparison. As a next step, inspect recent error-code distributions for provider-01 over this interval and review provider health indicators to identify possible causes of the decline, without assuming a confirmed root cause."}Read these numbers with the four limits in mind. Cache reads in the unmarked arm are implicit reuse, not a flaw in the run, and the priced uncached equivalent is arithmetic on the same observed tokens rather than a separate measurement.
What this one run shows, and what it does not. The shared reference occupied 1,744 tokens of every request; the evidence and question added 73 to 117. The unmarked arm reported no cache activity in any of its ten requests, so in this session it behaved as an uncached baseline, although nothing guarantees that on another day. The explicit arm paid one write, at $0.0102 against $0.0094 for the same case unmarked, and read the prefix back on the next nine requests at $0.0027 to $0.0040 each. Across ten requests the explicit arm cost $0.0416 against $0.0878, 52.7% less, and its priced uncached equivalent of $0.0868 lands within a tenth of a cent of what the unmarked arm actually cost, which is the arithmetic cross-check the report is designed to allow. The break-even arrived on the second request, as the formula predicted.
Duration did not move: medians of 2.55 and 2.60 seconds, and 95th percentiles within a tenth of a second of each other. With a 1,744-token prefix the saving is a cost saving, not a speed saving. All twenty answers passed the automated checks, and the two
decline-01 answers above reach the same decision in different sentences, a reminder that temperature zero narrows variation without removing it.Two cautions specific to this run. Five cases twice over is a smoke test, not a benchmark; the lab exists so that you can run the full set on your own account. And an earlier attempt the same day, stopped by the account's request rate limit after 17 calls, produced one answer that failed the schema check: a JSON object with a duplicated field, a sentence admitting the slip, then a corrected object. The content was right and the contract was not, which is the kind of failure a production path needs a rule for. That attempt is not part of the numbers above.
Check that the useful answer survived
The automated evaluator checks a narrow contract. It requires valid JSON with the expected fields, the correct decision under the lab rules, a correctly calculated current success rate, and relevant evidence identifiers that exist in the bundle. A truncated response fails even if the returned text happens to parse.
Those checks catch concrete regressions. As the walkthrough showed, they do not read the explanation, so an invented cause can pass them.
Use the generated review sheet for a second pass. Score factual correctness, evidence support and the usefulness of the proposed next step from 0 to 2. Mark any unsupported claim. For a stronger comparison, have a colleague hide the arm labels and shuffle answers before review. Inspect disagreements case by case instead of relying only on an average score.
Set acceptance criteria before reading the results. For this small lab, a reasonable starting rule is no loss on the automated checks, no new unsupported claims, and no meaningful decline in human ratings. A zero-temperature setting still does not justify assuming identical text on every run. Repeat the experiment and inspect variation.
The cost denominator deserves the same care. Divide all observed token cost, including failed quality checks, by the number of passing cases. A configuration that produces cheap but unusable responses should look worse. If production adds repair calls, include their tokens and their effect on latency too. This lab leaves repairs out so that the first-response comparison stays easy to inspect.
Try an expiry and a reference change
After the smoke test, run two explicit requests with a gap longer than five minutes:
.\.venv\Scripts\python.exe -m lab.benchmark run --profile YOUR_AWS_PROFILE --experiment expiry-a --mode explicit --limit 2 --repeats 1 --gap-seconds 310 --max-usd 1 --out results/expiry-aUse an experiment label that no other process is sending. Otherwise another request could refresh the entry during the wait. This command waits roughly five minutes between the two calls. Read the second request's counters rather than assuming a pattern.
For invalidation, run a short explicit experiment twice with the same experiment identifier, changing
--revision 1 to --revision 2 and using a different output directory each time. The changed label is at the beginning of the prefix. That makes this a controlled prefix-change probe, not a quality comparison with identical inputs.Finally, expand to the complete case set and repeated runs only after checking the small run's estimate and results. The spending estimate rises with both case count and repetitions. Preserve metadata, prices, raw usage and review decisions alongside any published result so readers can audit the comparison.
Where this belongs in the investigation service
In the earlier architecture, I would start with the shared operational reference and system rules. A reference revision would remain stable across jobs until an intentional update. Each investigation would still include its own fresh evidence. Deterministic incident rules and output validation would stay in place.
I would also keep the performance measurement proportional to the service. If caching saves only a few dollars a month, an elaborate new monitoring stack can consume the saving. The lab records local JSON and CSV files; a production service can add the necessary counters to existing request logs without recording sensitive prompt contents.
Prompt caching is a poor fit when prefixes rarely repeat, when the shared content changes constantly, or when output generation dominates the bill. A longer TTL may be worth evaluating for spaced requests, but it is a different pricing experiment. Batch inference is another option for work that can wait; the current caching guide says prompt caching is not supported with the batch inference API. Caching feature scope
There are no deployed resources to tear down in this lab. It creates local files and makes API calls only when you run the live command. Stop the runner to stop new calls, retain the results you need, and remove local experiment output when finished. Cache entries follow the service's expiry behavior.
The useful outcome is a measured reduction in cost per accepted investigation, with the reference material and evidence checks intact. If the request pattern does not produce enough reuse, the same experiment should make that clear before caching becomes another production assumption.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article