Latency
Time to first token measures the wait. Generation speed measures how quickly the answer continues.
Learn which metrics make an agent feel fast, how cache reuse changes economics, and when serverless or dedicated GPUs fit.
Time to first token measures the wait. Generation speed measures how quickly the answer continues.
Throughput only matters inside the latency and user speed your product requires.
Repeated agent context can move across GPU memory, CPU memory, and NVMe instead of being recomputed.
LLM inference is running a trained large language model to turn a prompt into output tokens. The weights stay fixed. Each request tokenizes the input, runs it through the model, and generates the answer one token at a time until the model emits a stop token or hits the length limit.
Training happens once per model version. Inference happens on every request from every user and agent, so it is the cost a product pays every month and the latency its users feel on every turn.
The model reads the entire prompt in one parallel pass and stores each token's attention keys and values in the KV cache. This phase is compute-bound. A longer prompt means a longer wait before the first output token.
The model generates one token per forward pass, reading the weights and the growing KV cache each step. This phase is bound by memory bandwidth, so serving engines batch many users' decode steps together with continuous batching.
Agents stress prefill more than chat does, because every turn resends the growing transcript. Prompt caching cuts that cost by reusing the cached prefix instead of recomputing it.
| Metric | What it measures | Driven mostly by |
|---|---|---|
| Time to first token (TTFT) | Wait before the answer starts | Prompt length, prefill compute, queueing, cache hits |
| Tokens per second per user | How fast one answer streams | Memory bandwidth, batch size, speculative decoding |
| Aggregate throughput | Total tokens per second across all users | Batching, KV cache memory, number of GPUs |
| Cost per completed task | Spend to finish one agent task | Model price, tokens generated, retries, cache reuse |
An inference engine loads the weights, schedules requests, and manages KV cache memory. All four below serve an OpenAI-compatible API.
| Engine | Built for | License |
|---|---|---|
| vLLM | Multi-user GPU serving with PagedAttention and continuous batching | Apache 2.0 |
| SGLang | GPU serving with RadixAttention prefix reuse for agents and RL rollouts | Apache 2.0 |
| Ollama | Running GGUF models locally with a model library | MIT |
| llama.cpp | C/C++ GGUF runtime for laptops, Apple Silicon, CPUs, and edge | MIT |
Compare them head to head in vLLM vs Ollama and SGLang vs vLLM, or read LLM inference optimization for the techniques that sit on top of the engine.
A cheap token is not cheap when a weaker model retries, loops, or fails the task. Compare models using completion quality, generated tokens, elapsed time, and total inference cost for the same representative trace.
For interactive agents, set the minimum acceptable generation speed per user first. Measure how much aggregate throughput remains at that speed. This prevents a highly batched benchmark from hiding a poor user experience.
Prefill dominates an agent's bill because every turn re-sends the whole conversation. Prompt caching reuses the KV cache for the repeated prefix and bills it at a cached rate, but only when the turn reaches the same model and the same worker; see prompt caching and cache-aware routing.
Per-user speed depends on the serving stack as much as the GPU: speculative decoding multiplies decode speed 2-3x on the same hardware with identical output.
Providers bill fresh input at the full rate and cached input at a fraction of it. Output costs the most per token. A coding agent re-sends its conversation every turn, so the cached rate sets most of the bill. The example turn below sends 45,000 cached tokens, 5,000 new tokens, and gets 1,000 tokens back.
| Model | Input / 1M | Cached / 1M | Output / 1M | One turn | Same turn, no cache |
|---|---|---|---|---|---|
| Kimi K3 morph-kimik3 | $2.5 | $0.29 | $14 | $0.040 | $0.139 |
| GLM-5.3 morph-glm53-744b | $1.19 | $0.1955 | $6 | $0.021 | $0.066 |
| GLM-5.3-Flash morph-glm53flash | $0.2 | $0.04 | $0.7 | $0.0035 | $0.011 |
| DeepSeek V4.1 Flash morph-dsv41flash | $0.12 | $0.008 | $0.8 | $0.0018 | $0.0068 |
The cache hit cuts the Kimi K3 turn by 72%. A 200-turn agent session at that rate costs $7.910 with caching and $27.800 without. Rates come from Morph pricing. Steady traffic at high volume can be cheaper on reserved GPUs; the dedicated inference calculator compares the two.
It fits uncertain or bursty demand. You pay for tokens and avoid reserving idle GPUs.
It fits steady production traffic that can use the reservation and needs isolated, predictable capacity.
How to size a GPU clusterLLM inference is the work a trained language model performs to read a prompt and generate an answer. Production inference includes model execution, batching, cache management, networking, and request scheduling.
Prefill processes the whole prompt in one parallel pass and writes its keys and values into the KV cache. Decode then generates one token per step, reading that cache each time. Prefill is limited by compute, decode by memory bandwidth, which is why long prompts raise time to first token and long answers lower tokens per second.
Training updates a model's weights from data and runs once per model version on large GPU clusters. Inference runs the finished model, with weights frozen, every time a user or agent sends a prompt. For a deployed product, inference is the recurring cost.
Inference engines load the weights, schedule requests, and manage the KV cache. vLLM and SGLang are the common open-source choices for GPU serving with many concurrent users. Ollama and llama.cpp run GGUF models on laptops, Apple Silicon, and CPUs. All four expose an OpenAI-compatible API.
On Morph, one agent turn with a 50,000-token prompt (45,000 tokens cached) and a 1,000-token answer costs $0.0018 on DeepSeek V4.1 Flash and $0.040 on Kimi K3. Without the cache hit, the same Kimi K3 turn costs $0.139. Per-token rates are listed at /pricing.
Model size, prompt length, generated tokens, active users, hardware, and cache reuse drive cost. For agents, retries and task completion quality also matter.
Track time to first token, generation speed per active user, completed tasks, retries, prompt cache reuse, and total cost per completed task.
Morph's top speeds come from dedicated deployments, not shared public endpoints: speculators trained on your traffic, caching tuned to your workload, and volume discounts over public per-token rates. Over 1 trillion tokens per day run this way.