How to Calculate LLM API Cost per Request: 2026 Token Math
Pricing · 2026-12-01 · 7 min read
All blog posts · Model pricing · API docs
The formula
Cost = (input tokens ÷ 1,000,000 × input rate) + (output tokens ÷ 1,000,000 × output rate). Both rates are published in USD per 1M tokens. The response usage object gives the token counts; do not estimate them from prompt length alone, because tokenization varies by model and content.
def request_cost(input_tokens, output_tokens, input_rate, output_rate):
return (input_tokens / 1_000_000) * input_rate + (
output_tokens / 1_000_000
) * output_rate
# Example: 100k input, 20k output at DeepSeek-V4.1-Flash rates
print(round(request_cost(100_000, 20_000, 0.18, 0.36), 4)) # 0.0252Worked example: one request
Take a request with 100,000 input tokens and 20,000 output tokens. At the published rates:
| Alias | Input $ / 1M | Output $ / 1M | Cost per request |
|---|---|---|---|
| MiniMax-M3.1-Flash | 0.10 | 0.40 | ≈ $0.018 |
| DeepSeek-V4.1-Flash | 0.18 | 0.36 | ≈ $0.025 |
| hy4 | 0.23 | 0.90 | ≈ $0.041 |
| Qwen3.5-397B-A17B | 0.36 | 2.14 | ≈ $0.079 |
| DeepSeek-V4-Pro | 0.67 | 1.34 | ≈ $0.094 |
| Kimi-K2.6 | 0.65 | 2.68 | ≈ $0.119 |
| GLM-5.3 | 1.16 | 4.06 | ≈ $0.197 |
| Kimi-K2.7-Code | 1.16 | 4.81 | ≈ $0.212 |
Rates from the catalog published on 2026-12-01; the live pricing page is the source of truth.
Worked example: a month of traffic
Assume 1M input and 200k output tokens per day for 30 days — 30M input and 6M output tokens in total.
| Alias | Monthly cost |
|---|---|
| MiniMax-M3.1-Flash | ≈ $5.40 |
| DeepSeek-V4.1-Flash | ≈ $7.56 |
| Qwen3.5-397B-A17B | ≈ $23.64 |
| DeepSeek-V4-Pro | ≈ $28.14 |
| Kimi-K2.6 | ≈ $35.58 |
| GLM-5.3 | ≈ $59.16 |
Multiply by your real daily volume; a team at 10× this shape pays 10× the token line, not 10× a plan price.
Why output tokens can dominate the bill
Every alias charges more for output than input — from 2× on DeepSeek-V4-Pro and GLM-5.3 to 4× or more on the flash tiers. A model that rambles can cost more than a stronger model that answers tersely. Set max_tokens for routine calls, ask for structured short answers, and measure output length as a first-class metric.
A small estimator you can run
Read the usage object from each response and accumulate cost. This keeps the estimate honest when prompts, retries and output lengths change.
# After a chat completion, use the returned usage fields
usage = response.usage
cost = (usage.prompt_tokens / 1_000_000) * 0.18 + (
usage.completion_tokens / 1_000_000
) * 0.36
print(f"request cost: ${cost:.4f}")Budgeting checklist
1. Measure a week of real traffic before forecasting. 2. Track cost per task, not only cost per token. 3. Set a per-request output cap. 4. Keep a lower-cost alias for retries and background work. 5. Re-check the catalog after upstream price changes. 6. Alert on spend, not only on errors.
Prepaid billing makes the ceiling explicit: requests that exceed the balance are rejected until you top up, and nothing bills beyond the balance.
Questions
- How many tokens are in a word?
- Roughly 1.3 tokens per English word on common tokenizers, with wide variation for code, numbers and non-English text. Use the usage object rather than a word-count estimate.
- Do cached input tokens cost less?
- The published API Volta rates are flat per token with no cached-input discount. Some other providers discount cached input; check the terms of the provider you use.
- Is there a minimum charge per request?
- Billing is by measured token usage at the published rates; top-up minimums are $5 by card or $3 in USDT.
- Which alias has the lowest input rate?
- MiniMax-M3.1-Flash publishes $0.10 per 1M input tokens in the current catalog. Remember that output rate and output length also shape the final cost.
- Do prices change?
- Yes, prices can change with upstream costs. The model pricing page and each model page show the current rate; older blog tables are snapshots.
Prices reflect the catalog published on 2026-12-01 and may vary by provider, region and account. The live list is on model pricing.
Create an account · Full price table · Day Pass · support@apivolta.com
Keep reading
- OpenAI API Alternative: How to Migrate Without Rewriting Your Code
- AI API Without a Credit Card: How Prepaid Access Works
- Free LLM API Credits in 2026: What You Actually Get
- Cline With an OpenAI-Compatible API: 2026 Setup and Cost Guide
- OpenRouter Alternatives in 2026: How to Compare AI API Gateways
- OpenCode With an OpenAI-Compatible API: 2026 Setup Guide
- Best LLM for Coding Agents in 2026: Price, Context and Tool Use
- New in the API Volta Catalog: DeepSeek V4.1, GLM-5.3, Kimi K2.6 and More
- DeepSeek API Pricing (2026): Flash and Pro Compared
- Kimi API Pricing (2026): K2.5, K2.6, K2.7-Code and K3
- GLM API Pricing (2026): GLM-5.2, GLM-5.3 and GLM-5.3-flash
- MiniMax API Pricing (2026): M2.5, M2.7 and M3.1-Flash
- Qwen API Pricing (2026): Qwen3.5, qwen3.6-plus, qwen3.7-max and qwen3-vl-plus
- DeepSeek vs GLM vs Kimi: Price, Context and Use Cases Compared
- How to Pay for an AI API with USDT: Six Networks From $3
- AI API Without a Subscription: How Pay-As-You-Go Works