Answer: Track per-step usage by reading each assistant message's nested `BetaMessage` (via `message.message`) with its `id` and `usage` token counts, deduplicating by message ID and reading output tokens from the result message; track per-model usage via the result message's `modelUsage` map of model name to token counts and cost. Status: Confirmed Entry: tool/claude-code/pricing-and-limits/per-step-per-model-usage Revision: 2 Digest: sha256:bbb1db0cd33247dd (changes whenever the content changes) Timeline: Created: 2026-11-13T03:02:40Z Last changed: 2026-11-18T12:12:17Z (costBasis minimum version: — → v2.1.246) Last verified: 2026-11-20T12:16:25Z Next check: 2026-11-21T12:16:25Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Per-step usage fields | AssistantMessage.usage | [1] | 2026-11-20 Per-model breakdown field | ResultMessage.model_usage | [1] | 2026-11-20 Per-model map field | modelUsage | [1] | 2026-11-20 costBasis values | list | [1] | 2026-11-20 costBasis minimum version | v2.1.246 | [1] | 2026-11-20 Sources: [1] Anthropic. "Track cost and usage". https://code.claude.com/docs/en/agent-sdk/cost-tracking.md Role: primary. Accessed: 2026-11-20T12:16:25Z Quote: "the equivalent fields are [`AssistantMessage.usage`](https://code.claude.com/docs/en/agent-sdk/python#assistantmessage) and `AssistantMessage.message_id` for per-step usage" (Supports: Per-step usage fields) Quote: "[`ResultMessage.model_usage`](https://code.claude.com/docs/en/agent-sdk/python#resultmessage) for per-model breakdowns" (Supports: Per-model breakdown field) Quote: "The result message includes [`modelUsage`](https://code.claude.com/docs/en/agent-sdk/typescript#modelusage), a map of model name to per-model token counts and cost." (Supports: Per-model map field) Quote: "`list` for list price, `managed` for a [`modelPricing`](https://code.claude.com/docs/en/settings-reference#modelpricing) table, or `unknown` when neither matched the model ID." (Supports: costBasis values) Quote: "The field requires Claude Code v2.1.246 or later." (Supports: costBasis minimum version) Published: 2026-11-20T02:52:51Z Snapshot SHA-256: 33162fd50e80cef6285d81742eaf4629de96a5a4354ab5f2e147dfb8a83af0d7 (captured 2026-11-17T12:20:22Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-17T12:20:22Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:16:25Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:16:25Z Last attempt: 2026-11-20T12:16:25Z Notes and limitations: Extracted automatically from a single official source (section "Track per-step and per-model usage"). Related: https://latestn.com/tool/claude-code/pricing-and-limits/reduce-token-usage How can I reduce token usage in Claude Code? https://latestn.com/tool/claude-code/pricing-and-limits/request-pricing-long-prompts How are requests priced against Claude apps gateway spend limits, including long-prompt rates? https://latestn.com/tool/claude-code/pricing-and-limits/review-skipped-budget-message Why did Claude Code Review skip my pull request with a budget message? https://latestn.com/tool/claude-code/pricing-and-limits/marketplace-download-limits What download limits apply to files hosted in a Claude Code plugin marketplace? https://latestn.com/tool/claude-code/pricing-and-limits/measure-plugin-token-cost How do I measure the token cost of a Claude Code plugin? https://latestn.com/tool/claude-code/pricing-and-limits/mod-limits What limits apply to Claude Code mods? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-18T12:12:17Z | changed | costBasis minimum version: — → v2.1.246 | [1] 2026-11-18T12:12:17Z | changed | costBasis values: — → list | [1] 2026-11-18T12:12:17Z | changed | Per-model map field: — → modelUsage | [1] 2026-11-18T12:12:17Z | changed | Per-model breakdown field: — → ResultMessage.model_usage | [1] 2026-11-18T12:12:17Z | changed | Per-step usage fields: — → AssistantMessage.usage | [1] 2026-11-18T12:12:17Z | changed | costBasis version requirement: v2.1.246 → — | [1] 2026-11-18T12:12:17Z | changed | per-model map field: modelUsage → — | [1] 2026-11-18T12:12:17Z | changed | per-model breakdown field: ResultMessage.model_usage → — | [1] 2026-11-18T12:12:17Z | changed | per-step message ID field: AssistantMessage.message_id → — | [1] 2026-11-18T12:12:17Z | changed | per-step usage field: AssistantMessage.usage → — | [1] 2026-11-13T03:02:40Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/pricing-and-limits/per-step-per-model-usage/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/pricing-and-limits/per-step-per-model-usage POST: https://latestn.com/dispute/tool/claude-code/pricing-and-limits/per-step-per-model-usage with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/pricing-and-limits/per-step-per-model-usage?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I track per-step and per-model token usage in the Claude Agent SDK? Revision 2, last verified 2026-11-20T12:16:25Z. https://latestn.com/tool/claude-code/pricing-and-limits/per-step-per-model-usage (accessed 2026-11-21T09:57:12Z). @misc{LatestN_tool_claude_code_pricing_and_limits_per_step_per_model_usage_r2, title = {How do I track per-step and per-model token usage in the Claude Agent SDK?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/pricing-and-limits/per-step-per-model-usage}}, note = {Revision 2; digest sha256:bbb1db0cd33247dd; last verified 2026-11-20T12:16:25Z; accessed 2026-11-21T09:57:12Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/pricing-and-limits/per-step-per-model-usage