Last reviewed: November 5, 2026 (Asia/Shanghai).

Direct answer

Measure CometAPI response cache savings by separating requests served from model attempts dispatched. A completed-response hit can satisfy a later authorized request without another generation. Record that delivery, but do not add the stored response’s original token usage to upstream spend again. Charge each actual attempt once, then compare total operating cost with a credible baseline for the same workload.

A useful decision measure is estimated net saving: the cost of serving comparable requests without completed-response reuse, minus actual model cost and the added cache operating cost. Keep unresolved upstream charges visible. A high hit rate alone cannot establish a financial saving or an acceptable answer.

This article describes an application-owned cache in front of CometAPI. Cloudflare’s AI Gateway caching guide provides a documented example of completed-response reuse for identical requests. Its settings and headers belong to Cloudflare; they do not establish a CometAPI cache feature or integration guarantee.

Who this is for

This guide is for platform engineers and FinOps owners evaluating repeated, non-streaming text requests whose completed answers may be reused. A suitable first workload is a summary of an immutable, non-sensitive document within one authorized sharing scope.

The ledger design, experiment, formulas, and acceptance checks are recommendations. No authenticated CometAPI call, cache deployment, billing experiment, or production benchmark was performed for this article. All dollar amounts below are hypothetical.

Key takeaways

  • Count user deliveries and upstream attempts in separate records.
  • A replayed usage object describes the original generation; it is not evidence of a new model charge.
  • Compare costs for equivalent traffic and preserve any existing provider prompt-cache discounts in the baseline.
  • Include cache lookups, storage, fills, refreshes, retries, and material operating overhead.
  • Enforce freshness and sharing requirements before seeking a higher hit rate.
  • Budget for cold-cache operation: every miss still passes ordinary financial admission.

Contract details to verify

Define the reuse that the product permits

Write one eligibility rule before enabling storage. Specify the authorized audience, exact request identity, source-data revision, prompt and policy revisions, model contract, response validation, and maximum permitted age. Authorize each lookup independently. A matching prompt or a stored digest does not grant permission to receive the answer.

Exclude independent-sample requests, effectful tool calls, partial responses, and any result the product requires to be newly generated. Begin with exact matching. Similarity-based reuse needs a separate evaluation because similar questions can require different answers.

CometAPI’s chat-completion reference documents messages, model selection, response choices, completion reasons, and usage. Those fields help identify and validate the generated result. They do not define your application’s reuse policy. A response ending because of an output limit needs explicit acceptance; an HTTP success alone is insufficient.

Cloudflare documents an exact-match default identity incorporating provider, endpoint, model, provider authentication header, and full request body. Its custom-key option can replace that default, so a coarse custom label can group requests that should differ. For an application-owned cache, use trusted opaque sharing scopes and a versioned request identity; keep raw credentials out of custom keys and telemetry. Do not assume that a gateway sharing one upstream credential also isolates your application’s users.

Set an absolute reuse deadline tied to the answer’s permitted age. Reads should not silently make an old answer fresh again. Include data and policy revisions in lookup eligibility, and recheck them before a delayed fill becomes reusable. Expiry limits age; it cannot fix a missing tenant or revision boundary.

Keep three records with different meanings

RecordWhat it countsFinancial treatment
Logical deliveryOne user request and its accepted or failed outcomeSupplies the business denominator; links to a hit, fill, or bypass
Upstream attemptOne dispatched model request, including a retry or refreshOwns its usage evidence and one cost settlement
Cache entryA retained, validated answer produced by an attemptCarries origin-attempt ID, contract revision, creation time, and reuse deadline

On a hit, create a new delivery record linked to the existing entry. Do not create a new upstream attempt merely because the stored body contains usage. Retain that original usage as provenance if needed, clearly separated from the delivery’s financial event.

CometAPI’s pre-call cost guide distinguishes an estimate from actual usage and billing records. Apply that distinction to cache savings too. A price-based estimate of an avoided generation is a counterfactual, not an invoice credit. Preserve its assumptions rather than writing a negative charge into actual spend.

Store opaque delivery, entry, and attempt IDs; outcome; eligible-hit or miss reason; contract revision; entry age; settlement state; and pricing revision. Keep prompts, generated text, credentials, and customer identifiers out of routine cost telemetry. Protect the cache content under the workload’s access and retention rules.

Operator workflow

Perform lookup before creating billable work

Use this recommended sequence at the application boundary:

  1. Authenticate and authorize the caller. Construct the exact request and determine whether completed-response reuse is permitted.
  2. Look up the matching entry. Validate its sharing scope, contract, age, and retained result before returning a hit.
  3. On a miss, join or claim an in-flight fill where the sharing policy permits. Recheck the cache after claiming ownership.
  4. Obtain budget admission for each permitted upstream attempt, then dispatch with a recorded attempt identity.
  5. Validate the completed result and settle its usage once. Recheck the current revision before storing it with a bounded lifetime.
  6. Record delivery independently of storage success. A cache-write failure must not cause an already successful generation to run again solely to refill the cache.

The site’s request-coalescing guide covers sharing work while it is running. Keep that stage’s join count separate from completed-response hits. Otherwise one avoided call can receive credit from both optimizations.

Cloudflare explicitly warns that simultaneous identical misses can both reach the provider before either result is cached. Count both dispatched attempts when that happens, even if only one entry survives. A final cache size of one does not establish that only one generation was purchased.

Every miss still needs the workload’s atomic budget admission . If cache loss suddenly turns hits into misses, deny or defer unfunded work through the normal policy. Do not let the cache-outage path bypass the spending limit.

Build a baseline that answers the actual decision

Select one eligible request family and define a successful delivery before measuring. Compare a small, concurrent, randomly assigned cache-enabled cohort with a baseline cohort that bypasses completed-response reuse. Keep model routing, input and output controls, acceptance checks, and other optimizations comparable. Budget the baseline traffic; bypassing the cache can increase paid calls.

Give the enabled cohort its own declared cache namespace and fill policy. Baseline requests must not warm it accidentally. Record cohort sizes and traffic mix. A small cohort can have less reuse than a full deployment, so report the result for the tested traffic share rather than assuming the hit rate will scale unchanged. Include a full cold start or separately disclose any initial warm-up cost.

Retain provider prompt caching in both cohorts when it is part of normal operation. It still creates a new response, while completed-response reuse avoids that generation. The prompt-caching break-even guide explains the input-side calculation. Pricing every baseline request at an uncached input rate can overstate the additional saving from response reuse.

If an experimental bypass is unsuitable, use a historical or modeled baseline and label the weaker comparison. Match request class, model revision, data period, and output policy. Output length varies, so the original fill’s cost is not automatically the cost every later request would have incurred. Do not dispatch a second generation on every hit merely to calculate savings; that measurement can consume the benefit being evaluated.

Calculate net saving and useful unit cost

The FinOps Foundation’s Unit Economics capability recommends distinguishing resource-efficiency metrics from business metrics and documenting their calculations. Apply that principle by reporting cache performance alongside cost per accepted delivery.

For comparable traffic, define:

baseline_unit_cost = baseline_total_operating_cost / baseline_logical_requests
estimated_baseline_cost = baseline_unit_cost * enabled_logical_requests
estimated_net_saving = estimated_baseline_cost - enabled_total_operating_cost

completed_hit_rate = completed_response_hits / eligible_cache_lookups
upstream_attempt_rate = dispatched_attempts / logical_requests
cost_per_accepted_delivery = total_operating_cost / accepted_deliveries

Use a consistent cost boundary in both cohorts. Include upstream charges for fills, retries, background refreshes, and failed attempts where billing evidence establishes a charge. Include material cache and gateway costs. Include warm-up and refresh work even when they have no user delivery of their own. If an accepted-delivery denominator is zero, report it as undefined.

Here is a hypothetical equal-size comparison. Both cohorts handle the same request family and meet the same acceptance policy. Existing prompt-cache effects are already reflected in model cost.

MeasureResponse reuse bypassedResponse reuse enabled
Logical requests10,00010,000
Accepted deliveries10,00010,000
Completed-response hits06,000
Dispatched model attempts, including retries and refreshes10,0004,100
Model cost$50$22
Other operating cost within the chosen boundary$5$8
Total operating cost$55$30
Cost per accepted delivery$0.0055$0.0030

With all 10,000 enabled requests eligible for lookup, the completed hit rate is 60%. Estimated net saving is $55 - $30 = $25, about 45.5% of baseline operating cost. Multiplying 6,000 hits by the baseline’s $0.005 model cost would suggest $30 of avoided model cost. The model-cost difference in the example is $28, and the added operating cost is $3. Neither the hit percentage nor the simple hit-times-price estimate gives the $25 net result.

Report uncertainty around the cohort comparison and sample enough complete reuse periods to cover expiry and normal traffic variation. Separate one-time implementation effort from recurring operating cost, but include it in the payback decision. If enabling the cache changes acceptable-answer rates or freshness, investigate that outcome before approving the financial result.

Reconcile charges before claiming realized savings

Keep actual spend and estimated avoided spend in separate fields. A cached response delivered a hundred times still has one originating generation. A background refresh adds another attempt even when no user sees its result. Use a unique settlement identity so replayed completion events cannot add either charge twice.

When an attempt’s final charge is unknown, retain its outstanding reservation or conservative exposure separately from settled cost. Do not substitute zero. Show that uncertainty beside the savings estimate and resolve it before describing the result as reconciled. Aggregate billing adjustments also need an explicit allocation rule; a cache hit count cannot explain them.

Verification before rollout

Use a counted fake model endpoint, a disposable cache, synthetic usage, and a controllable clock first. These are proposed acceptance checks, not reported test results.

ScenarioRequired observation
One fill followed by nine eligible requestsTen deliveries, one dispatch, nine completed hits, one usage settlement
Hit replays the original response’s usage objectNo additional upstream charge enters the ledger
One usage event arrives twiceSettlement remains unchanged after the duplicate
Two callers miss simultaneouslyActual dispatch count is visible; coalescing joins are not labeled completed hits
Entry expires or data revision changesOld output is ineligible; any new attempt needs admission
A slow fill finishes after the policy changesIts charge remains recorded; its result cannot populate the current contract
Cache write fails after a valid generationDelivery can complete; storage failure alone triggers no new model call
Cache becomes unavailable or loses entriesMisses follow the normal budget and capacity policy
A refresh fails or a caller abandons deliveryAttempt cost remains attached to its existing identity
Caller belongs to a different sharing scopeNo unauthorized hit, regardless of matching request text

Then run the bounded cohort comparison. Monitor accepted deliveries, freshness violations, hit and bypass reasons, upstream attempts, settled cost, pending exposure, and cache overhead. Stop reuse when correctness or sharing rules fail. Falling hit rate should trigger a cost review, while a privacy or freshness violation requires immediate control of the affected reuse path.

Failure modes

Stored token counts become new spend on every hit. Separate replay provenance from newly observed attempt usage. Reconcile against dispatch identities.

The forecast assumes a permanently warm cache. Include cold starts, expiry, deployment changes, and background fills. Preserve admission when reuse disappears.

Savings are credited twice. Count provider prompt-cache discounts within actual attempt prices, and distinguish in-flight joins from completed hits.

More hits conceal worse answers. Keep the same acceptance and freshness requirements in both cohorts. A cheap stale answer does not satisfy a fresh-answer contract.

Retention grows without useful reuse. Bound entry count, bytes, and lifetime. Review one-hit entries and their storage cost before expanding retention.

Sources checked

Four primary public references were fetched successfully on November 5, 2026 UTC and Asia/Shanghai:

These currently served official technical references support an evergreen accounting decision, rather than a new product announcement. Verify the deployed cache behavior and selected CometAPI route before rollout. Public documentation does not establish account-specific charges or measured savings.

FAQ

Does a cache hit guarantee zero cost?

It can avoid a new generation when the application confirms no upstream dispatch. Cache lookup, storage, gateway, and other operating costs can remain. Background refreshes also need their own attempt records.

Can we reuse an answer just because the temperature is low?

Sampling settings do not establish permission to share a result. Require the written audience, request, freshness, and acceptance contract before reuse.

Should the cache entry keep the original usage?

It may retain that evidence as provenance, subject to retention policy. The delivery and financial pipelines must identify it as original-attempt data and avoid creating another charge from it.

Is a hit-times-price estimate ever useful?

It can support a clearly labeled forecast for a homogeneous request class. Reconcile it with measured attempt costs, existing discounts, misses, retries, refreshes, and cache overhead before making a savings claim.

Reader next step

Choose one reusable text task and write its acceptance, sharing, and freshness rules. Prove that one fill plus nine hits produces one settlement, then budget a small baseline cohort and compare total cost per accepted delivery through a complete expiry cycle.

When those local checks pass, Start with CometAPI to verify the selected route with bounded, non-sensitive traffic. Keep any avoided-cost estimate separate from the actual usage and billing evidence.