Skip to content
Webliska TechnologiesFlaxxa is a registered product of Webliska Technologies, Faridabad, HaryanaGSTIN: 06ATYPG3011E1ZX
Flaxxa AI is now in open beta.
Flaxxa
Start Free
← All posts
AI· 3 min read

Controlling LLM costs in production without making the product worse

Most LLM bills are dominated by a handful of avoidable patterns. Here is where the money goes and which cuts are invisible to users.

An LLM feature that costs almost nothing in testing can become a serious line item at volume. The spend is rarely spread evenly — it concentrates in a few patterns, and most of them can be removed without users noticing.

Model names tell you nothing about price

Assuming a model called "mini" or "fast" is cheap is a reliable way to be surprised. On one gateway, an image model named mini cost 83 times more per image than the cheapest available, and the one named fast was the joint most expensive on the roster. Pull the actual per-unit price for every model you call and put it somewhere your team reads. Names are marketing.

Match the model to the job, per call

Most products use one model for everything because it is simpler. It is also where most of the waste is. Classification, extraction and short rewrites run acceptably on small models at a fraction of the cost; reasoning and long-form generation need the large one. Routing per call type, rather than per product, commonly removes the majority of spend with no quality change a user would detect.

Cache the prompt, not just the answer

Two different caches matter and teams usually implement only the first:

  • Response caching — identical input returns the stored output. Effective for classification and lookups, useless for anything personalised.
  • Prompt caching — the provider caches the static prefix of your prompt (system instructions, examples, retrieved documents) across calls. If you send a long system prompt on every request, this is usually the single largest available saving, and it changes nothing about the output.

Prompt caching only works if the static part comes first and is byte-identical. Interpolating a timestamp or a user name into the top of your system prompt silently defeats it.

Cap output tokens deliberately

Output tokens typically cost several times more than input. A feature that wants three sentences and sets no limit will periodically produce six paragraphs, and you pay for all of it. Set max_tokens to slightly above what the feature actually needs and instruct the model on length in the prompt as well — the two together are more reliable than either.

Retries are a cost multiplier

A naive retry loop on a timeout can triple the cost of every slow request, and slow requests are usually the long ones. Retry on genuine failures, never on a timeout you set too low, and cap attempts. Log retry counts: a quiet rise in retries is often the first sign of a provider issue, and it shows up on the bill before it shows up in error rates.

Attribute spend per feature from day one

A single total bill tells you nothing actionable. Tag every call with the feature that made it and the workspace it belongs to, so the monthly question is "which feature costs what" rather than "why is this number large". Adding attribution after the fact means reconstructing it from logs that were not designed for it.

Fall back deliberately, and say so

When the primary model is unavailable, falling back to a cheaper one is usually right. Returning a degraded answer without recording that it was degraded is not — the quality drop then appears as a mysterious user complaint weeks later. Record the fallback, and where it matters to the user, tell them.

Built on Flaxxa

Run your business on one platform.

Free plan. No credit card.

Start Free