Perimattic
Free Tool

LLM cost calculator

Estimate monthly API spend across major LLM providers by modelling token volumes, prompt lengths, and caching strategies.

LLM costs are driven by token consumption — the number of input and output tokens processed per API call, multiplied by the provider's per-token price. Prices vary dramatically: frontier models like GPT-4o and Claude Opus charge $2–15 per million input tokens, while smaller models (Haiku, GPT-4o mini, Gemini Flash) cost 10–50x less. Total monthly spend depends on request volume, average prompt length, output length, and whether you leverage cost-saving techniques such as prompt caching, batching, or model routing. For most production workloads, 60–80% of costs come from a small number of high-volume endpoints.

Calculator

LLM Cost Calculator

Pricing reference (per 1M tokens)

ModelInputOutput
OpenAI GPT-4o$2.50$10.00
OpenAI GPT-4o-mini$0.15$0.60
Anthropic Claude Sonnet$3.00$15.00
Anthropic Claude Haiku$0.25$1.25
Google Gemini Pro$1.25$5.00
AWS Bedrock Claude$3.00$15.00

Results

Select a model and enter your usage parameters, then click “Calculate Results” to see your LLM costs.

Frequently Asked Questions

How do LLM pricing models work?+

Most LLM providers charge per token — a token is roughly 4 characters or 0.75 words in English. Pricing is split into input tokens (your prompt) and output tokens (the model's response), with output tokens typically costing 2–5x more. Some providers also offer batch pricing at a discount, cached-prompt pricing for repeated prefixes, and fine-tuning surcharges. Enterprise agreements may include committed-use discounts or volume tiers.

How can I reduce LLM token costs in production?+

The most effective strategies are: (1) prompt caching — reuse static system prompts to avoid re-processing them on every call, (2) model routing — send simple queries to cheaper models and reserve frontier models for complex tasks, (3) prompt engineering — shorten prompts without losing quality, (4) output-length limits — set max_tokens to prevent runaway completions, (5) batching — group requests to take advantage of batch-pricing discounts, and (6) response caching — store and reuse outputs for identical or near-identical inputs.

How do I choose between LLM models for my use case?+

Match model capability to task complexity. Use small, fast models (GPT-4o mini, Haiku, Gemini Flash) for classification, extraction, and simple Q&A — they handle 80% of production tasks at a fraction of the cost. Use mid-tier models (Sonnet, GPT-4o) for summarisation, code generation, and multi-step reasoning. Reserve frontier models (Opus, o1) for tasks requiring deep analysis, complex tool use, or domain-expert-level accuracy. Run A/B evaluations on your own data before committing.

What hidden costs should I watch for with LLM APIs?+

Beyond per-token pricing, watch for: (1) embedding costs — vector-search pipelines may process millions of tokens daily, (2) fine-tuning training costs — charged per token in the training set, often per epoch, (3) storage fees for fine-tuned model weights, (4) rate-limit-driven over-provisioning — paying for higher tiers to avoid throttling, (5) egress and data-transfer fees in multi-cloud setups, and (6) prompt-engineering iteration costs during development, which can exceed production spend in early phases.

What are the best practices for LLM cost optimisation?+

Best practices include: (1) instrument every API call with token counts and latency to build a cost baseline, (2) implement a model-routing layer that selects the cheapest capable model per request, (3) cache system prompts and frequent queries, (4) set budget alerts at the API-key level, (5) compress context windows by summarising long documents before injection, (6) use streaming only when the UX requires it (non-streaming batch calls are cheaper with some providers), and (7) review usage dashboards weekly to catch cost anomalies early.