Cloud bills report Claude spend at the account or project level, but product decisions happen at the feature level. This pattern builds attribution from the one data source that exists on every platform: the usage object returned with every API response. Log it, tag it, multiply by list prices, and your FinOps dashboard stops being an argument.
Capture the usage object on every call
Each Messages response reports token consumption in distinct fields, and the distinctions are where attribution accuracy lives:
| Field | Meaning | Billing note |
|---|---|---|
input_tokens | Input after the last cache breakpoint | Full input price |
cache_creation_input_tokens | Tokens written to the prompt cache | 1.25x (5m TTL) or 2x (1h TTL) |
cache_read_input_tokens | Tokens served from cache | 0.1x input price |
output_tokens | All generated tokens (authoritative total) | Output price |
output_tokens_details.thinking_tokens | Reasoning tokens within output | Subset of output_tokens |
Total input is the sum of the first three — a pipeline that logs only input_tokens will dramatically under-report any feature that uses caching. Logging thinking_tokens separately lets you see when a feature's cost is driven by reasoning depth rather than answer length. If you use server-side compaction, note that top-level counts exclude compaction iterations; sum usage.iterations for the true billed total.
Tag at the choke point
Attribution requires every request to carry feature, team, and environment tags. The reliable place to attach them is a thin internal gateway or SDK wrapper that all teams call — this glue is recommended practice, not an API feature, and it beats hoping every codebase remembers a logging call. Write one record per request: tags, model ID, the full usage object, and a computed cost using list prices (for example Opus 4.8 at $5 input / $25 output per million tokens, Haiku 4.5 at $1/$5; apply your negotiated committed-use rates in the dashboard layer, since those are set with your cloud provider, not Anthropic).
Two platform-native tagging hooks help. In Anthropic's Message Batches API, every request carries a required custom_id (1–64 chars) — encode feature and job identifiers in it, and remember batch usage bills at 50% of standard prices, so cost computation needs a "batch" flag. On the first-party Claude API, workspaces add structure: batches are scoped to a workspace, and workspaces can carry their own spend and rate limits below the organization's, so one-workspace-per-product-area gives you a coarse, enforcement-backed split on top of fine-grained tags. Per FACTS-level caveats, spend limits and the Usage/Cost API are among the documented exceptions on Claude Platform on AWS — there, and on Bedrock, Vertex AI, and Foundry, your own usage log plus the cloud provider's billing tools carry the load.
Aggregate and reconcile
The pipeline itself is ordinary data engineering: request records flow to your warehouse, a scheduled job rolls them up by tag, day, model, and platform, and the dashboard shows cost per feature with cache-hit-rate and thinking-token trendlines beside it. Two practices keep it trustworthy:
Reconcile monthly against the invoice. Your computed spend and the cloud bill will differ (discounts, rounding, non-Messages charges such as server-tool usage fees). Track the gap; investigate when it moves.
Forecast with the free token counter. The count_tokens endpoint is free (with its own rate limits) and accepts the same inputs as message creation — use it to price prompt changes per feature before shipping them. One warning from the docs: newer models (Opus 4.7+, Sonnet 5, Fable 5) use a tokenizer producing roughly 30% more tokens than earlier models for the same text, so recount when a feature changes models.
Where to go next
See cost tagging strategy, logging for FinOps, and FinOps for LLMs for the organizational side.