The bill is dominated by a handful of levers. Here they are in rough order of impact — pull the top ones first; the lower ones are rounding errors by comparison.
Independent · no vendor money · part of the Awesome AI Gateway benchmark · pricing changes fast — calculate on live data, don't trust static leaderboards.
Biggest lever Pick the right model, not the flagshipThe same task can cost 100×+ more on one model than another. Use the cheapest model that still passes your quality eval — that one decision usually dwarfs everything below. Size it for your workload →
High Cut output tokensOutput (completion) tokens are usually priced several × higher than input. Constrain max_tokens, ask for terse answers, avoid "explain your reasoning" when you don't need it.
High (if you reuse context) Cache & trim inputUse prompt caching for large stable prefixes (system prompts, long context) — many providers discount cached input steeply. Prefer retrieval over stuffing the whole corpus into every call.
Medium Route by task difficultySend easy requests to a cheap model and escalate only hard ones (a cascade / router). A gateway makes this a config change, not a rewrite.
Medium at scale Avoid per-token markupA hosted aggregator's credit fee adds up at volume — a BYOK control plane or self-hosted gateway removes it. (Still smaller than model choice.)
Workload-specific Batch & go asyncFor non-interactive jobs, batch APIs often price at a meaningful discount versus real-time calls.
⚖️ Notice the ordering: which model beats every gateway/infra trick combined. Optimize that first, then operationalize the rest with caching, routing and budgets. Start here → cost calculator.
So what's the "cheapest LLM API"?
There's no durable answer — prices move monthly and the cheapest model that's good enough for your task is what matters, not the absolute floor. That's why this project ships a calculator on the same open pricing data behind the benchmark, instead of a number that's stale by next week. Enter your real input/output token mix and compare.
Where the gateway fits
A gateway is how you operationalize these levers across a team — response caching, model routing, per-key budgets and rate limits in one place. Pick one by need with the gateway picker; just remember the model still dominates the bill.
FAQ
What's the cheapest LLM API?
It changes constantly — trust live pricing. The cheapest model that passes your quality bar (not the absolute cheapest) is the real answer; calculate for your own token mix.
Input or output tokens more expensive?
Output is usually priced higher — often several ×. Trimming output cuts the bill faster than trimming the prompt.
Does prompt caching save money?
Yes when you reuse a large stable prefix — cached input is steeply discounted by many providers.
Does an AI gateway reduce costs?
Indirectly — caching, routing, budgets, and BYOK/self-host avoid markup. But model choice dominates.