Skip to content
Claude Certified Developer – Foundations (CCDV-F) Exam Prep

Lesson 9 of 25 · 7 min

x
9/25

Cost and Token Management

Video lesson: CCDV-F 09/25: Cost and Token Management (Domain 5, 2.8%)

Official scope (Exam Guide v1.0): token usage tracking, cost modelling, caching (prompt caching, cache check-pointing).

The cost formula (verified pricing structure)

Cost = input tokens × input price + output tokens × output price, summed over calls. Output costs about 5x input per token on current models (for example Claude Opus 5.5: $4 input / $20 output per million). Thinking is billed as output.

Input is everything you resend: system prompt, full history, tool definitions (plus a tool-use system prompt of a few hundred tokens), tool results, images, documents. Per-turn cost rises through a conversation because history grows.

Tracking usage

  • Every response: usage.input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens (total input = the three input fields summed), plus speed and thinking-token detail.
  • Console Usage and Cost pages; Export gives CSV by API key and model.
  • Usage and Cost Admin API (needs an Admin API key or another admin credential, not a workspace key): usage by model, workspace, API key, service tier, speed, in 1m/1h/1d buckets; cost in USD, daily. Data usually appears within 5 minutes.
  • Claude Code per-user costs: the Claude Code Analytics API.

Levers, in a sensible order (design guidance, verified facts)

  1. Measure a baseline (cost and quality).
  2. Send less: trim history, shorten the system prompt, return only high-signal tool results, compact or clear old turns.
  3. Cache the stable prefix (below).
  4. Right-size the model: route easy work to a smaller tier; check quality on evals.
  5. Batch what can wait: 50% off.
  6. Cap output: ask for brevity, set max_tokens sensibly (too low truncates), use a lower effort.

Never optimise without before/after numbers on cost and quality.

Prompt caching and check-pointing

  • Explicit breakpoints: cache_control on up to 4 blocks at stable points (end of tools, end of system, end of a long document).
  • Automatic caching: one top-level cache_control; the breakpoint moves forward as the conversation grows (uses one of the 4 slots).
  • Lookback: 20 blocks per breakpoint; place breakpoints so a hit is found.
  • Writes cost 1.25x (5-minute TTL) or 2x (1-hour TTL) base input; reads 0.1x by default (0.05x on Opus 5.5 and Sonnet 5.5, 0.025x on Fable 5.1). Break-even depends on how many reads follow each write.
  • Minimum prefix 512 tokens on current models; below it, silently uncached. Exact-prefix match required; tool, tool_choice, image, thinking, effort or speed changes invalidate part or all of it.
  • Caching also raises throughput: on most models cache reads do not count toward ITPM.

Cost modelling (design guidance)

Monthly cost ≈ requests × (uncached input × price + cache writes × write price + cache reads × read price + output × output price), with the batch share at 50%. Inputs: request volume, average input and output tokens, cache hit rate, batch share, fast-mode share.

Exam traps

  • Ignoring output price (it dominates for long answers and thinking).
  • Caching enabled but nothing cached (below minimum, prefix changes each call, timestamp before the breakpoint).
  • Reading only input_tokens and missing cached tokens.
  • Downsizing the model with no quality check.
  • Workspace key on the Usage and Cost API.

References

  1. Prompt caching — checked Oct 16, 2026
  2. Usage and Cost API — checked Oct 16, 2026
  3. Rate limits — checked Oct 16, 2026
  4. Models overview (pricing) — checked Oct 16, 2026
  5. Tool use overview (pricing) — checked Oct 16, 2026
  6. Batch processing — checked Oct 16, 2026

Check your understanding

  • Per-turn cost climbs through a chat. Cause and two fixes?Show answer

    Answer

    Growing resent history; trim or compact, and cache the stable prefix.
  • Caching enabled, bill unchanged. Two things to check?Show answer

    Answer

    Prefix below minimum or not identical; cache counters in usage.
  • Nightly report job. Lever?Show answer

    Answer

    Batch API, 50% off.
  • Which key reads the Usage and Cost API?Show answer

    Answer

    An Admin API key (or other admin credential).
Previous

Progress is saved in this browser.

Next Lesson