Claude Code Token Usage Introspection in 2026: Reading the `usage` Field and Building Your Own Cost Dashboard A developer documented how to instrument Anthropic's Messages API `usage` field—input_tokens, output_tokens, and cache_read_input_tokens—to build a per-developer, per-project Claude Code cost dashboard, since no first-party tooling aggregates token counts into spend or burn rate. The writeup parses the usage object in TypeScript, appends request metadata, logs to a time-series store, and computes pricing, noting cached tokens cost 10% of input price ($0.03 vs $0.30 per million on Sonnet 4). usage Field and Building Your Own Cost Dashboard This article was written with the assistance of AI, under human supervision and review. Engineering teams that shipped Claude Code to production in early 2026 discovered the same problem within their first billing cycle: the bill arrived before the tooling did. Anthropic's API returns structured token counts in every response, but no first-party dashboard aggregates those counts into per-developer spend, per-project burn rate, or cost-per-commit. The usage field holds the raw data. The rest is an infrastructure problem. The default experience looks like this: developers commit code, Claude Code processes pull requests and generates diffs, and at month-end the finance team receives an invoice with a single line item. No breakdown by user, no attribution to specific repositories, no way to correlate a $4,000 spike with the three-day refactoring sprint that triggered it. The correct approach instruments the usage field at every API call, logs structured token counts to a time-series store, and builds aggregation queries that surface cost metrics in real time. Organizations that shipped this pipeline before enabling Claude Code for the full engineering team avoided the budget overrun cycle entirely. This post walks through the structure of Anthropic's usage response, shows how to parse it in TypeScript, compares first-party and third-party dashboards, and demonstrates a production-ready cost monitoring pipeline with per-user caps and budget alerts. Every response from the Messages API includes a usage object with three fields: input tokens , output tokens , and cache read input tokens . The structure is consistent across all models and tool use patterns. A typical response looks like this: { "id": "msg 01XYZ...", "type": "message", "role": "assistant", "content": { "type": "text", "text": "Here is the refactored function..." } , "model": "claude-sonnet-4-20250514", "stop reason": "end turn", "usage": { "input tokens": 2048, "output tokens": 512, "cache read input tokens": 1024 } } The input tokens count includes the system prompt, user message, and any context from prior turns in the conversation. The output tokens count measures the assistant's response. The cache read input tokens field introduced with prompt caching in late 2024 counts tokens served from the five-minute cache instead of being reprocessed. Cache reads cost 10% of the input token price. A cached token on Claude Sonnet 4 costs $0.03 per million tokens instead of $0.30 per million. The savings compound when developers iterate on the same file across multiple API calls within the cache TTL window. The usage field does not include session metadata user ID, repository name, timestamp . That attribution logic sits in the application layer. A cost monitoring pipeline parses the usage object, appends metadata from the request context, and writes a structured log entry. Token usage breakdown in API response The pricing calculation multiplies token counts by the model's per-million-token rate. Claude Sonnet 4 charges $0.30 per million input tokens and $1.50 per million output tokens. A single API call with 2,048 input tokens, 512 output tokens, and 1,024 cached tokens costs: 2048 0.30 / 1 000 000 + 512 1.50 / 1 000 000 + 1024 0.03 / 1 000 000 = 0.0006144 + 0.000768 + 0.00003072 = $0.00141312 At 500 API calls per day, the monthly cost for that pattern reaches $21.20 per developer. The difference between $20 and $200 per developer per month comes down to output token volume and cache hit rate. A production parser extracts the usage object, appends request metadata, and writes structured logs to a time-series database. The minimal implementation fits in 50 lines. python import Anthropic from '@anthropic-ai/sdk'; import { Pool } from 'pg'; interface UsageLog { timestamp: Date; userId: string; repository: string; model: string; inputTokens: number; outputTokens: number; cacheReadTokens: number; cost: number; } const anthropic = new Anthropic { apiKey: process.env.ANTHROPIC API KEY, } ; const db = new Pool { connectionString: process.env.DATABASE URL, } ; const PRICING = { 'claude-sonnet-4-20250514': { input: 0.30 / 1 000 000, output: 1.50 / 1 000 000, cacheRead: 0.03 / 1 000 000, }, }; async function logUsage log: UsageLog : Promise