The /cost Command
The/cost command displays a comprehensive summary of token consumption and estimated costs for the current session:
When the provider returns real token usage data (
Usage.IsReal = true), costs are calculated with precision. For providers that do not return real usage, ChatCLI estimates tokens from text size.Token Tracking by Mode
ChatCLI tracks tokens across all interaction modes:- Chat Mode
- Agent Mode
- Coder Mode
In chat mode, tracking counts:
- System prompt tokens (bootstrap + memory + contexts)
- Tokens for each user message
- Tokens for each assistant response
- Cache savings (when applicable)
Pricing Tables
ChatCLI knows the prices of the most common models for calculating estimates:Anthropic
OpenAI
GPT models surface usage in the chat envelope too, with the same
Nβ Mβ arrows the Claude flow has used since launch. ChatCLI sends stream_options: {include_usage: true} on streaming Chat Completions and parses response.completed on the Responses API, so input/output (and cache-hit) counts appear on the envelope regardless of provider. Cached prompt tokens reported under prompt_tokens_details.cached_tokens (Chat Completions) / input_tokens_details.cached_tokens (Responses) map to CacheReadInputTokens, the same field Anthropic prompt caching feeds. Reasoning tokens (o-series / GPT-5) are surfaced under a separate ReasoningTokens informational field β theyβre already counted in CompletionTokens and billed as output.ZAI (Zhipu AI)
MiniMax
Moonshot (Kimi)
The ChatCLI cost tracker bills the cache-miss price (0.16/M) is an automatic API saving when the same prefix is reused within the providerβs window β not tracked at runtime.
DeepSeek
OpenRouter
Visual Display
ChatCLI uses visual indicators for easy tracking:Token Format
Tokens are displayed with K/M suffixes for readability:Context Progress Bar
When context approaches the model limit, a progress bar indicates utilization:Cache Savings
ChatCLI optimizes costs using prompt caching when the provider supports it:Cache Tokens (Anthropic)
ChatCLI tracks Anthropic-specific cache tokens:
The cache read cost is typically 10% of the normal input cost, resulting in significant savings in long conversations with large system prompts.
Cache savings are calculated based on the difference between the normal input price and the cache read price. See Bootstrap and Memory for details on context optimization.
Real API Data
The CostTracker supports two data sources:
When the provider returns real data (
HasRealData = true), tracking uses exact token counts. This is supported by 13+ providers including Anthropic, OpenAI, ZAI, MiniMax, DeepSeek, and OpenRouter.
Per-Model Cost
In sessions with multiple models (e.g., fallback chain),/cost shows a breakdown by model:
Session Persistence
Cost data is persisted to disk so it can be consulted after the session ends:SessionCostData) with per-model usage, costs, and timestamps.
Session Budget
Configure a spending limit per session to avoid unexpected costs:Budget Levels
Next Steps
Conversation Control
Use /compact to reduce tokens and costs.
One-Shot Mode
Monitor costs in automated pipelines.
Tool Results
Tool result budgets that impact token usage.
Context Recovery
Automatic strategies when context overflows.