How to track and cut LLM and AI API costs

To control LLM costs, first log every model call with its tokens, cost and the feature that made it, then cut spend with the right model per task, shorter prompts and outputs, caching, batching and limits on agent loops, checking quality at each step.

AI requests with token counts and a flattening cost-per-request line, beside a brass valve

Key takeaways

  • Log every call with tokens, cost, feature, team and customer.
  • Measure unit cost, such as cost per resolved ticket.
  • Use the smallest model that meets the quality bar, and route by task.
  • Prompt caching, batch APIs and shorter outputs cut costs further.
  • Re-test quality on an evaluation set after every change.

Why are AI and LLM costs hard to control?

Model APIs charge per token, usually at different prices for input and output tokens, and prices vary widely between models. A single product feature can call a model thousands of times a day, retries and long prompts multiply the bill, and usage grows with customers in ways budgets rarely anticipate. The FinOps Foundation's State of FinOps 2026 found that 98% of FinOps teams now manage AI spend, and that AI cost management is the skill they need most.

How do you track LLM costs?

  • Log every call with the model, input tokens, output tokens, latency and cost, plus the feature, team and customer that triggered it.
  • Use separate API keys or projects per product or environment, so provider dashboards can split spend.
  • Measure unit cost: cost per resolved ticket, per document processed or per active customer, not just total spend.
  • Set budgets and alerts per feature, and rate limits per customer, before usage scales.
  • Track GPUs separately if you self-host models: utilization, idle hours and cost per thousand requests.

What are the biggest levers for cutting LLM costs?

LeverWhat to doWatch out for
Model choiceUse the smallest model that meets your quality bar for each task; route easy requests to cheaper modelsTest quality on a real evaluation set before switching
Prompt and context sizeTrim system prompts, retrieve fewer and better chunks in RAG, summarize long historiesCutting context too far lowers answer quality
Output lengthAsk for concise or structured output and set a maximum output lengthOutput tokens are often priced higher than input tokens
Prompt cachingUse the provider's prompt caching for long, repeated prefixes such as instructions and documentsCache rules and pricing differ by provider
Batch processingSend non-urgent work through batch APIs, which providers typically offer at a discountResults arrive later, not in real time
Response cachingReuse answers to identical or near-identical requestsStale answers if source data changes
Retries and loopsCap agent steps and retries; stop runaway loopsAgents can call models many times per task

How do you cut costs without hurting quality?

  1. Build an evaluation set of real examples with expected answers.
  2. Measure quality and cost per task on the current setup.
  3. Change one lever at a time (model, prompt, context, caching) and re-run the evaluation.
  4. Keep the change only if quality holds and unit cost drops.
  5. Repeat monthly; new models and prices appear constantly.

What should an AI cost report show?

  • Spend by model, feature, team and customer, with the trend over time.
  • Cost per unit of value (per ticket, document or conversation).
  • Token mix: input, output and cached tokens.
  • Anomalies: sudden jumps in calls, tokens per call or retries.
  • GPU utilization and idle cost, if you run your own models.

Model prices change often; always check the current rates on each provider's pricing page before modeling savings.

Want this run for you? Our FinOps for AI service tracks token, GPU and cloud spend together and cuts it without lowering quality.

Frequently asked questions

Are output tokens more expensive than input tokens?

With most providers, yes. That is why limiting output length and asking for structured, concise answers is one of the simplest savings.

Is self-hosting an open-source model cheaper?

Sometimes, at high and steady volume. Include GPU cost, idle time and engineering effort, and compare cost per request, not just list prices.

What is prompt caching?

A provider feature that stores a long, repeated part of your prompt so later calls that reuse it are cheaper and faster.

Can you manage our AI spend alongside cloud costs?

Yes. Our FinOps service covers token, GPU and AI platform spend together with cloud infrastructure.

More questions? See all FAQs →

Inventipreneur Solutions Team

Written by the FinOps practitioners, cloud and DevOps engineers and applied AI engineers who deliver this work for our clients. About Inventipreneur.

Is your AI bill growing faster than your AI value?

We track and cut LLM, GPU and cloud costs together. Start with a consultation call.