Direct answer
How does LLM API pricing work?
LLM APIs usually multiply measured usage by published rates: input tokens, output tokens, cached input tokens, or a per-request unit such as an image. Total workload cost depends on the exact model, prompt size, generated output, cache behavior, retries, and failed-request billing rules.
Last reviewed 2026-08-15 · Editorial review: KeepRouter Editorial
Token-priced requests
For a text request, a basic calculation is:
cost = input_tokens × input_rate
+ output_tokens × output_rate
+ cached_input_tokens × cached_rateRates may be displayed per one million tokens even though billing uses the measured token count. Do not assume the input and output rates are equal. A long context can make input dominant; an unconstrained generation can make output dominant.
Request-priced operations
Some image or specialized operations publish a per-request unit instead of token rates. The model page should state the unit. Do not force a per-image price into a per-token calculator.
Why a static price table is insufficient
Rates and model availability can change. More importantly, the cheapest listed rate may produce longer output, require retries, or fail the task. Use the live catalog for current customer rates and the request log for actual token and charge evidence.
Compare a workload, not a million-token headline
Fix the input, output cap, tools, cache state, and pass criteria. Record cost per request and cost per successful task. Separate first-turn uncached requests from repeated cached context, and include retries or fallback transitions. Report the sample date and limitations.
Spend controls
A key-level limit bounds aggregate spend but does not make an individual agent loop safe. Add application step limits, output caps, timeouts, and alerting. Keep separate keys for services or environments so usage is attributable and one experiment cannot consume another workload's budget.
Frequently asked questions
Are input and output tokens the same price?
Often not. Read the current rates for the exact model.
What is cached-input pricing?
Some routes charge a different rate when eligible repeated input is served through a model maker's cache behavior.
Are images billed by tokens?
Not always. Many image operations use a published per-image or per-request charge.
What is the best cost metric?
For product decisions, cost per successful representative task is usually more useful than list price alone.