What is LLM inference?
LLM inference is running a trained model on a prompt to get an answer. Learn how a single call works, what it costs and how speed is measured.
Updated
LLM inference is the step where a trained language model reads an input and produces an output. Your app sends a prompt, the model runs its weights over it, and text, JSON or a label comes back. Every call is inference, and every call uses compute time and money, so inference is where the bill and the response speed come from.
What happens during one call
The model does not read words. It reads tokens, which are pieces of words, often a few characters long. The first pass reads the whole prompt at once. The second pass writes the answer one token at a time, and each new token depends on everything before it. Long inputs make the first pass heavier, and long outputs make the second pass longer.
To avoid rereading the prompt for every new token, the server keeps a cache of what it has already processed. That is the KV cache. It takes memory for every active request, so the number of requests a server can handle at once depends on how long those requests are.
A worked example: one invoice
Take a tool that reads a supplier invoice and returns the vendor name, invoice date, total and tax as JSON. The input is the full invoice text, including the footer, the payment terms and the line-item table. The output is one short object with four fields.
Most of the work sits in the first pass, because the input is long and the answer is short. Trimming the footer before the call means every invoice reads fewer tokens, and the four fields do not depend on that text. A two-line question sent to the same model would finish almost at once. The size of the input and output decides the work, not the model’s name.
Inference is not training
Training changes the model’s weights, the numbers that store what it has learned. It runs on large datasets and happens once, or each time you retrain. Inference only reads the weights. A normal call does not teach the model anything, and the answer it returns is not written back into the model.
That split matters for cost. Training is a project you pay for once or on a retraining schedule. Inference cost grows with every call, which is why it is the line item that surprises teams later.
Cost, speed and quality, and their traps
Inference is judged on three things, and each one has a trap.
Cost is usually quoted per million tokens. That number ignores how many tokens your task needs and how often a call has to be retried. A call retried once costs twice as much for that task, even if the price per token never moves. Cost per finished task is closer to the business question. The cost per million tokens guide shows the arithmetic.
Speed has two meanings. Latency is how long one answer takes. Throughput is how much work the server finishes per second across many requests. A tokens-per-second figure is usually a per-stream number and says little about waiting in line under load. See throughput vs latency.
Quality only means something on your own data, because public leaderboards test general skills. Your task has its own documents, labels and edge cases.
In one public test of contract clause finding, a model trained for that single task beat a general model that was prompted with no examples. Full results show how the test was split and scored, and that is one task on one dataset.
Hosted APIs versus a model you run
A hosted API bills per token and sets the model, its version and its limits. Vendors retire model versions on their own schedule, so the model you tested can change under you. Running your own inference lets you choose the open-weight model, where it runs and which version you keep, and it moves uptime, capacity and evaluation onto your team. See self-hosted LLM for what that involves.
Own Weights fine-tunes an open-weight model for one high-volume task, tests it against the current model on the company’s own data, and serves it in the customer’s cloud account or on-prem. The customer owns the weights. The trained model has to beat the current model on that test before it is deployed.
Measure the inference you already run
Start with a count. List every call that sends a model request, the model it uses, the tokens going in and out, and whether it sits inside a loop. Then work through each call:
- Find every call site, including background jobs and retries.
- Record the model name and version, and flag any version the vendor has announced for retirement.
- Check for instructions that repeat on every call, which are candidates for prompt caching.
- Confirm every call sets an output limit and a timeout.
- Check whether JSON is parsed without a schema, since a failed parse usually means a retry.
- Note which calls could wait for a batch run instead of a live response.
Doing this by hand across a large codebase is slow. The free AI cost audit reads your repository as text on your own machine. It makes no network calls while reading, uploads nothing, and saves a PDF that lists AI calls, models, estimated cost and common problems such as missing output limits, calls with no timeout and calls inside loops. The tool is open source under the MIT license, at github.com/ayaangazali/ownweights-audit.
Want to know which of your inference calls could run on a model you own? Book a free audit and we will go through them with you.
Questions
Is LLM inference the same as running a chatbot?
A chatbot is one product that uses inference. Any feature that sends a prompt to a model and gets a result back, such as a classifier, an extractor or a summarizer, runs inference too. The model does not need to hold a conversation for a call to count.
Does inference make the model learn from my prompts?
No. A normal call reads the model's weights and returns an answer without changing them. Whether your prompts are stored or used for training is a separate question that depends on the provider's terms and settings.
Why does inference cost more for long documents?
The model reads the whole input before it writes anything, so longer inputs take more compute. Long outputs add steps because the model writes one token at a time. Removing text the model does not need is often the cheapest fix.