Optimizing AI infrastructure and token cost

We break down LLM load step by step, find repeated and redundant calls, and add caching, batching, and model routing. The inference bill drops and quality stays put.

We measure where tokens go and cut the bill without losing answer quality.

Pricing

from ₽400,000

per project

This is the lower bound of a project. We scope the exact quote after a brief: it depends on volume and the number of integrations.

What's included

Capabilities

Step-by-step audit

We break down the request chain: where tokens go to a useful answer and where to resending context.

Semantic cache

Repeated questions are answered from memory instead of an external call, with a cache version per document.

Model routing

Simple phrases go to a cheap model, complex requests to a strong one, by rules in the code.

Budget and alerts

A per-project limit and an alert when cost grows the same day, not in the bill at month end.

How we work

From request to result

  1. 1

    Profiling

    We collect calls for a period and break them down: input tokens, output tokens, repeats, and cache share.

  2. 2

    Optimization plan

    We fix where to cut: cache, batching, routing, and prompt compression, with an effect estimate.

  3. 3

    Implementation

    We add cache and routing and move part of the calls to a local model without breaking answers.

  4. 4

    Budget control

    We turn on limits and alerts, compare the bill before and after, and record the saving in numbers.

Who it fits

Check if it fits you

Good fit

  • Call logs exist

    They show per-step spend; without logs we turn on tracing first.

  • Steady load

    Repeated requests get cached and routed; the effect shows in the second week.

Not a fit

  • A one-off experiment

    With dozens of calls a month, optimization does not pay off.

  • No metrics collected

    If cost and latency are not measured, we add observability first.

Track record

What you get

−55%

of the token bill

After caching and routing, external calls dropped while answer quality stayed the same.

Scope of work

What the delivery includes

A call profile report

The output is a per-step call table with tokens, repeats, and cache share. It shows every source of spend without a manual log dig.

A cost map

We count the cost per model and prompt, so you see which part of the bill adds value and which goes to repeats.

A work plan

We fix what changes: cache, batching, routing, and prompt compression. The plan sets the order of work and the expected effect in money.

A saving measurement

We compare the bill before and after on one task set and show the saving in money. The measurement rests on your calls and your rates.

How it works

How the system is built

  1. Call profile

    We break the calls down step by step: input and output tokens, repeats, and cache share. The profile shows exactly where the budget goes.

  2. Routing and cache

    Simple requests go to a cheap model and the semantic cache, while complex ones stay with the strong model. An engineer sets the routing rules.

  3. Measurement before and after

    We measure answer metrics and cost on one task set before and after the change, so the effect shows up in real numbers. The same tasks make the comparison honest.

  4. Budget control

    Budget control goes in with the optimization: limits and cost alerts show growth on the day of a spike. You see the overrun the same day it appears, and the month-end bill confirms it.

Limitations and cost

Where the solution pushes back

  • 01

    Resending context

    The model rereads history and documents on every step, and you pay for it again. Resending context is the main line of the bill.

  • 02

    A strong model on simple phrases

    Greetings, clarifications, and typos are handled by a strong model where a cheap one would do. An oversized model on simple phrases inflates the budget.

  • 03

    An uncompressed prompt

    Fragments spare for the answer land in the context, and every one of them costs tokens. Prompt compression removes that spend and lowers the bill.

  • 04

    A missing cache

    The same policy question goes to the provider again although the answer already existed. A cache answers from memory and removes repeated calls.

  • 05

    A cache needs repeats

    In a product where questions repeat rarely, a cache only adds a vector search. A cache pays off where similar requests come back regularly.

  • 06

    Chunk size to the document

    A chunk that is too small breaks context and one that is too large drags spare tokens. We tune chunk size to the document to keep meaning and cost in balance.

  • 07

    Routing needs labeling

    An engineer sets which requests count as simple, and someone has to maintain those rules. Routing needs labeling and a regular review of the rules.

  • 08

    Saving and quality

    If the task needs the strong model, the cheap one gives a worse answer. Saving and quality are linked, and metrics show the line where cutting stays safe.

Stack

Technologies

The technologies we use in our work and their role in a project.

Metrics, cache, and inference

Per-step cost is collected by Langfuse, the cache lives in Redis, inference is served by vLLM, metrics come from Prometheus, and history is stored in PostgreSQL.

Traces every chain: cost, latency, and token count per step are visible, not just the total.Holds the semantic cache: a repeated question is answered from memory in milliseconds.An inference server with batching and attention caching: it keeps a local model under load.Scrapes cost and latency metrics: growth shows up before the provider invoice.Stores cache versions and call history: the saving before and after is computed from them.
Budget estimate

Cost calculator

This is an indicative range, not a quote. We scope the exact estimate after a brief: it depends on volume and the number of integrations.

Accounts

3

Optimization depth

Reserved and rightsizing

Add-ons

Support

Year one: updates and monitoring, a reply within 2 business days.

Service

Optimizing AI infrastructure and token cost

The estimate covers our team's work. Hardware, third-party service licences and travel are added on request.

Estimated cost

₽640,000

Timeline

3 wk

Questions

Frequently asked questions

Will quality drop?

We measure answer metrics before and after. Cache and routing leave complex requests alone, so any drop shows at once and is rolled back.

How long does the audit take?

Profiling for a period takes two days; the optimization plan takes a week.

Do you need production access?

Call logs and metrics are enough. We touch production only during the rollout.

What if there is no saving?

We show the estimate before the rollout. If there is no effect, we do not start.

How fast does optimization pay off?

We estimate payback on your call profile: cost before and after, works included. Under steady load the effect shows in the first weeks; for a one-off we say honestly that it will not pay off.

What does the audit include?

The audit covers a per-step call profile, a cost map by model and prompt, an optimization plan, and an effect estimate in money. It is a report with numbers you can decide on, not generic advice.

Is a local model required?

No. Local inference matters when volume cost or data confidentiality demands it. If the cloud covers the tasks cheaper, we keep the cloud and optimize the calls.

Ready to discuss your task?

Leave a request – we'll get back with a proposal and a preliminary estimate.

Contact us