NewDeploy your app free on Nyas · Start free, pay as you go, recharge any timeDeploy your app free on Nyas→

Blog · AI engineering

How we cut a chatbot’s LLM bill by 75% in six weeks, without hurting its answers

Formulate AI · 5 December 2026 · 10 min read

−75%monthly LLM billin 6 weeksBeforeAfter
−75%
monthly LLM bill
6 weeks
from first look to live
97% parity
on 500 real questions

A customer came to us with a problem many teams have now. Their high-traffic, customer-facing AI chatbot handles about 12,000 messages a day and works well, but its LLM bill had become one of their largest monthly costs, and it grew with every new user. They asked us one thing: bring it down, without making the answers worse.

Six weeks later, the same chatbot runs at about 25% of the original cost, answers faster, and scores the same on quality. This is the full story: the problem, the goal, the architecture before and after, how we rolled it out safely, and the numbers.

The problem

The bot was built the way most first versions are: simple, reliable, and expensive at scale.

Customerweb + app chatChat APIapp serverPrompt buildersystem + full historyLarge LLM100% of requestsKnowledge basetop 8 docs, untrimmed~6k tokensanswer, 2.4 s median
Before. Every message, simple or not, went to the large model with the whole conversation and eight retrieved documents attached: about 6,000 input tokens per call.

The goal

We agreed the target with the customer before touching anything, written so that either side could check it:

Specific
Cut the chatbot’s LLM spend without changing the product, the main model or the answers customers get.
Measurable
At least 60% lower monthly spend on the provider invoice. At least 95% answer parity on a 500-question test set, handoffs to humans no higher than 4.1%, and p95 response time no slower than today’s 4.8 s.
Achievable
Four weeks of logs showed heavy repetition and long prompts. Both are fixable with known techniques, with no retraining and no product change.
Relevant
LLM spend was growing faster than revenue: every new customer made the bot more expensive to run.
Time-bound
Live within 8 weeks, with a full week in shadow mode before switching over.

What the data showed

Week one was measurement only. Four weeks of real conversations, anonymised, gave three findings:

The new architecture

We didn’t replace the bot. We put five components in front of the model call:

CustomerChat APICheckpersonal? topic?Semantic cachesimilarity ≥ 0.92Cached~150 msRoutersmall classifierCompressorsummary + top turnsKnowledge basereranked, top 3Small LLM~1 in 3 missesLarge LLMhard + sensitiveEvery request logged: tokens · cost · model · cache hit · latency, plus a daily quality sample12345hitmisspersonal: never cachedsimplecomplexanswers go back through theChat API; general ones arestored in the cache with a TTL
After. Numbers match the steps below. Over half of all requests now end at the cache; most of the rest go to the small model with a compressed prompt.

1. Check: is this personal, and what is it about?

Every message is first tagged. If it’s about one customer’s own account or order (order numbers, “my plan”, “my refund”), it is marked personal and never touches the cache. Rules catch the obvious cases and a small classifier catches the rest; when in doubt, it’s treated as personal. The topic (how-to, policy, pricing, account) sets how long an answer may be cached.

2. Semantic cache, with expiry

General questions are turned into embeddings and matched against answers already given. An answer is reused only if the meaning is close enough (similarity 0.92 or higher), the topic matches, and it hasn’t expired. We tuned that threshold on 3,000 labelled question pairs; at 0.92, reviewers found wrong matches in 0.4% of a sample, and those were near-identical answers.

3. Router: the big model only when needed

Cache misses go to a small classifier trained on 6,000 labelled real messages. It decides whether the small model is enough and how sure it is. Below 80% confidence, the message goes to the large model. Complaints, refunds and anything legal always do. In practice about one in three cache misses goes to the small model, at roughly an eighth of the price.

4. Context compression: send only what matters

Instead of the whole conversation, the model gets a short running summary, the last two turns word for word, and any older turn that’s relevant to the current question. Retrieved documents are re-ranked and trimmed to the three most relevant passages. Average input fell from 6,100 to 3,700 tokens, with the same answers on the test set.

5. Logging and quality checks on every request

Every request records its tokens, cost, model, cache hit and response time. Every day, 200 answers are scored automatically against the test set’s standard and 30 are checked by a person. Alerts fire if quality dips or cost per conversation jumps, and each component sits behind a feature flag, so any one of them can be switched off in seconds.

How we rolled it out

Nothing reached customers until its numbers were proven in shadow mode first.

  1. Week 1
    Measure

    Exported four weeks of anonymised logs, priced every conversation, and built a 500-question test set from real traffic with answers the support team signed off.

  2. Week 2
    Cache in shadow

    The cache ran beside the live bot, logging what it would have answered. We tuned the similarity threshold and expiry times on this data. No customer saw it.

  3. Week 3
    Cache live

    10% of traffic, then 50%, then 100%. By the end of the week, the biggest saving was already in.

  4. Week 4
    Router trained

    Labelled 6,000 real messages as “small model is enough” or “needs the large model”, trained the classifier, and ran it in shadow.

  5. Week 5
    Router and compressor live

    Both behind feature flags at 10%, then 50%. Quality checks ran on every step-up.

  6. Week 6
    Full stack, then switch

    The full new path answered in shadow for a week. Parity held at 97%, so we moved 100% over and kept the old path as a one-click fallback.

Where the savings came from

The order matters: the cache took most of the easy questions, so the router had less left to save than we first estimated.

StepImpactWhy
Semantic cacheBiggest savingover half of all messages no longer reach a model
RouterMediumabout one in three remaining calls moves to the small model
Context compressionMediumevery remaining call sends ~40% fewer tokens
New parts (embeddings, vector store, router)Small added costall run on Nyas next to the app

Results against the goal

MeasureGoalResult
Monthly LLM bill≥ 60% lower75% lower
Answer parity, 500 questions≥ 95%97%
Handoffs to a human≤ 4.1%4.0%
p95 response time≤ 4.8 s3.1 s (cache hits ~150 ms)
Time to live≤ 8 weeks6 weeks

Three-quarters of the bill, saved every month from here on, and the bot got faster.

Why we could do it in six weeks

We didn’t learn this on the client’s money. We run the same pattern on our own platform, where we pay our own LLM bill every day.

What we learned

Is this you?

This fits best if LLM calls are a noticeable line in your monthly costs and your bot answers a lot of similar questions: support, sales, onboarding or internal help desks.

← All posts

Your AI team, ready today.

No card · 500 free credits · First results in minutes

Book a demo →