Skip to content
mentoor

Topic 3 of 4 · 5 min read

Estimating batch discounts with caching

Goal: Estimate the cost of a large job under real-time, batch and batch-plus-caching pricing.

The batch discount and prompt caching stack, but caching inside a batch is best effort, so estimate the job at real-time, batch and batch-plus-caching prices and treat the last as a best case. Do the arithmetic before you submit, not after the bill arrives.

Check yourself · 1 of 3

Which part of a request can be cached for a large batch job?

Choose one answer

Why it matters

A large job is a multiplication: requests times tokens times price. A wrong assumption about the shared prefix or the output length changes the total by hundreds of dollars. An estimate also tells you whether the work needs a batch split.

How to estimate

  1. Count tokens per request. Separate the shared prefix (instructions, examples, schema) from the part that changes per item. Count output tokens separately, because they cost more per token.
  2. Price real-time. Requests times input tokens at the input price, plus requests times output tokens at the output price.
  3. Apply the batch discount. The Claude docs list batch tokens at 50% of the standard price, input and output.
  4. Add caching. Per the prompt caching docs, a cache read costs a fraction of normal input (the docs list 0.1 times the base input price), and a cache write costs a premium. Only the shared prefix can be cached, and it must be identical.
  5. Check the limits. A Claude batch takes 100,000 requests or 256 MB. Over that, plan several batches.

Batch requests run concurrently and in any order, so the Claude docs say cache hits are provided on a best-effort basis. For batches that run longer than the default cache lifetime, the docs suggest the 1-hour cache duration for better hit rates. Use the cached figure as the lower bound and the plain batch figure as the safe one.

Worked example (illustrative prices)

The job: 40,000 tickets, each 3,000 input tokens (2,500 of them a shared prompt) and 300 output tokens. Prices used here: $3 per million input tokens, $15 per million output tokens, cache reads at $0.30. These are example prices, not a quote.

Mode Input Output Total
Real-time $360 $180 $540
Batch $180 $90 $270
Batch plus caching, all hits $45 $90 $135

Cache write cost is left out; it is small next to 40,000 reads.

What goes wrong

  • Counting the shared prefix as per-item. That hides the biggest saving and overstates the bill.
  • Promising the cached number. Hits are best effort, so budget between the batch and cached figures.
  • Forgetting output. Long answers dominate cost; capping max_tokens cuts the total more than any discount.

Examples

Spotting the shared prefix

A prompt has 2,200 tokens of instructions and examples, then a 400-token ticket. Cache the 2,200; the 400 is paid in full each time. Over 50,000 tickets that is 110 million cacheable tokens and 20 million fresh ones.

Budget band

Quote the manager two numbers: the plain batch price as the safe figure and the cached price as the best case. If the true cost lands between them, no one is surprised.

Key points

  • Estimate cost as requests times tokens times price, with input and output priced separately.
  • Claude's documentation lists batch tokens at half the standard price, and caching can reduce the shared prefix further.
  • Cache hits inside a batch are best effort, so the cached estimate is a best case.
  • Only an identical shared prefix can be cached; per-item text cannot.
  • Check batch size limits before you submit, and split what exceeds them.

Common mistakes

  • Treating the cached estimate as guaranteed when hits inside a batch are best effort.
  • Leaving output tokens out of the estimate, although they cost more per token.
  • Putting the changing text before the shared instructions, so the prefix is never identical.
  • Assuming the discount applies to every feature; check the docs for what the batch price covers.

Check yourself · 2 of 3

A job costs $400 in real-time input and output. With a 50% batch discount, what is the batch price before any caching?

Choose one answer

Check yourself · 3 of 3

Why should you budget between the batch price and the batch-plus-caching price, not at the cached price?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic