estimate_token_cost
Calculate exact token counts and estimated USD costs across LLM providers for text or project directories before sending prompts to commercial APIs.
Instructions
Calculates exact token count and estimated API prompting cost (USD) across major LLM providers (OpenAI GPT-4o, Claude 3.7 Sonnet, Groq, NVIDIA NIM, and Ollama $0) for a given text or directory.
Behavior:
Read-only: Mathematical cost projection; does NOT invoke provider APIs or incur financial billing.
Idempotent: Produces exact calculations for identical token counts.
100% Offline: Uses local pricing tables without external HTTP queries.
Usage Guidelines:
When to use: Estimate prompt token volume and dollar costs before sending large codebase context to commercial LLM APIs.
Sibling Routing: To track team monthly/annual cumulative ROI savings and compression metrics over time, use 'get_token_savings_metrics'.
Returns: Markdown table comparing per-million token rates and total estimated costs across major models.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | Optional raw text to estimate. If empty, analyzes context generated from project_root. | |
| project_root | No | Project directory to scan if text is empty (default: current directory). | . |
| reduction_mode | No | Reduction tier ('ultra', 'balanced', 'none') applied when scanning project_root. | ultra |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |