Eight levers that actually cut cost
Most AI bills can be cut 40–80% without hurting quality by pulling a few of these levers. Start with the ones that need no quality trade-off (caching, batching, fixing retry waste), then tune model choice.
1. Cache your system prompt
If you send the same long instructions or context on every call, prompt caching lets the provider store it and charge a fraction (often ~10%) for the cached portion on repeat calls. For high-volume chatbots this alone can halve the bill.
Caching savings →2. Route by difficulty
Send easy calls (classification, formatting) to a cheap model and only escalate hard calls to an expensive one. A router that keeps 80% of traffic on a small model can cut cost dramatically while keeping quality where it matters.
Routing savings →3. Batch non-urgent work
Many providers offer a batch API at ~50% off for jobs you don't need answered instantly (embeddings, bulk classification, offline generation). If latency isn't critical, batching is free money.
Batch savings →4. Use RAG instead of giant context
Rather than pasting a whole knowledge base into context every call, retrieve only the few relevant chunks. RAG turns a huge per-call input cost into a small one. Compare the two approaches for your data size.
RAG cost →5. Cap output length
Output tokens are typically priced 3–5x higher than input tokens across most providers, so a verbose answer costs far more than a terse one carrying the same information. Set a max_tokens limit and instruct the model explicitly to be concise — "answer in 2 sentences" often cuts output tokens by half or more with no loss of correctness.
6. Prompt before you fine-tune
Fine-tuning has real upfront cost (training runs, data prep) plus ongoing hosting for the custom model, and it locks you into one base model version. For most tasks, a well-engineered prompt with a few examples on a cheaper base model reaches similar accuracy for a fraction of the cost. Reserve fine-tuning for cases where prompting genuinely can't hit the quality bar.
Compare →7. Know when to self-host
Self-hosting only wins once volume is high and steady enough that GPU rental amortises below what you'd pay per token on an API. Below that threshold, API pricing is cheaper and you avoid managing infra, scaling and uptime yourself. Run the numbers with your real monthly token volume before switching.
Break-even →8. Stop paying for retries you don't notice
A 429 rate-limit error itself is free — no tokens are billed when a request is rejected before processing starts. The cost comes from what happens next: each retry resends the full input prompt, so 3 retries on 3% of requests quietly add extra input tokens to your bill. Worse are timeout duplicates — your code retries a slow request that actually finished server-side, so you pay for two completions instead of one. High concurrency without backoff or idempotency keys is the usual cause; fixing it needs no model or architecture change, just better retry logic.
Retry cost →Worked example: stacking the levers
Say a team spends $10,000/month on API calls for a support chatbot with a long, repeated system prompt and generous max-token responses. Stacking levers roughly in order of easiest win first:
- Cache the repeated system prompt: −25% → $7,500
- Batch the ~30% of volume that's offline ticket summarization, not live chat: −15% → $6,375
- Route the ~60% of calls that are simple FAQ lookups to a cheaper model: −30% → $4,462
- Cap output length to concise answers: −10% → $4,016
Result: roughly 60% lower ($10,000 → ~$4,000/month) without touching the higher-effort levers — RAG rebuild, fine-tuning, or self-hosting. That's why the order above matters: start with caching and routing before the levers that need real engineering work.
Common mistakes
- Optimizing before measuring — cutting cost without first breaking the bill down by model and endpoint means effort can go into a lever that barely moves the total.
- Caching a prompt that changes every call — prompt caching only helps a stable prefix; if the system prompt embeds per-request data (user IDs, timestamps), the cache never hits.
- Routing on model name alone — routing should follow task difficulty, not just "cheapest model everywhere"; sending hard tasks to weak models causes retries that cost more than the original call would have.
- Ignoring RAG's upfront cost — RAG cuts per-call tokens but adds embedding and vector-DB infrastructure; it only pays off once the knowledge base is large enough that pasting it whole would be expensive.
- Retrying without backoff or idempotency keys — hammering a rate-limited endpoint with immediate retries multiplies failed-then-succeeded calls, and timeout-triggered duplicate requests silently double the completion cost on the slowest, most expensive calls.
Frequently asked questions
How much can I realistically cut my LLM bill?
Many teams cut 40–80% by combining prompt caching, model routing, batching and shorter outputs — often with no noticeable quality loss. The biggest wins usually come from caching repeated context and routing easy calls to cheaper models.
Does prompt caching hurt quality?
No. Caching stores an unchanged portion of your prompt and reuses it, returning identical results — it only changes billing, charging a reduced rate for the cached tokens on repeat calls.
When should I self-host instead of using an API?
Self-hosting tends to win only at high, steady volume where GPU rental amortises well; below that, API per-token pricing is cheaper and far simpler. Use a break-even calculator with your real monthly token volume to decide.
Is fine-tuning a good way to save money?
Sometimes, but it has upfront training cost and ongoing hosting. For many tasks a better prompt on a cheaper base model is more cost-effective. Compare the two for your volume before committing.
Do rate-limit errors cost money?
The 429 error itself is free — no tokens are billed when a request is rejected before processing. The hidden cost is retries: each retry resends the full prompt, and timeout-triggered duplicate requests can bill you for two completions of the same call. Fixing retry logic (backoff, idempotency keys) removes this waste without touching your model or architecture.
Educational reference only — prices are estimates; confirm current rates on each provider's pricing page.