How to Evaluate the Cost-Effectiveness of LLM Inference Services
Per-token pricing alone doesn't tell you how much it costs to actually get a task done. This article breaks down the real cost structure of LLM inference—input/output pricing, hidden costs like retries and context growth, and key performance metrics like TTFT and throughput—then walks through a practical framework with sample code for comparing services based on effective cost per completed task rather than list price.
1. Why Listed Price Isn’t Enough
When teams evaluate LLM inference services, the first thing they usually check is the price per million tokens. That number is useful, but it only answers “how much does one call cost,” not “how much does it cost to get the job done.”
Two situations commonly distort this judgment. First, a service with a low unit price might produce long, rambling responses that require multiple rounds of correction, ending up consuming more tokens overall. Second, a service with a higher unit price might generate faster and pass quality checks on the first try, eliminating the need for manual rework and retries. Both cases show that unit price is just one link in the cost chain.
Evaluation should therefore center on three questions: how many resources a task actually consumes, how long the user waits, and whether the result is usable.
2. Breaking Down the Cost Structure
2.1 Input and Output Tokens Are Priced Separately
Most pay-as-you-go inference services price input tokens and output tokens separately, usually at different rates. Output tokens typically cost more, since generation requires computing each token sequentially.
When evaluating a service, track both token types separately rather than looking only at the total. A task with a long prompt but a short response is dominated by input cost. A task with a short prompt but a long required output is dominated by output cost.
2.2 Differences Between Inference Tiers
Many services offer different inference tiers, such as a standard tier optimized for quality and a fast tier optimized for speed. Price and speed can differ significantly between tiers. When comparing them, make sure both are evaluated against the same business target, such as the same latency ceiling or the same quality threshold. Otherwise the comparison doesn’t mean anything.
2.3 Hidden Costs
The following costs are frequently overlooked:
- Retry costs: Request timeouts, malformed output, or results rejected by business rules all trigger retries.
- Truncation and continuation costs: An output length limit set too low causes responses to get cut off, requiring a second call.
- Context growth: In multi-turn conversations, accumulated history causes input tokens to grow linearly with each turn.
- Manual review costs: When output quality is inconsistent, results need to be checked by hand line by line, and this labor often costs more than the token fees themselves.
2.4 Core Formulas
The cost of a single call can be written as:
Cost per call = input tokens × input price + output tokens × output price
But the metric that actually matters for comparison is “cost per effective result”:
Cost per effective result = total cost ÷ number of tasks that pass quality checks
This metric folds price, retries caused by speed issues, and rework caused by quality issues into a single denominator.
3. Defining Performance Metrics
Performance metrics generally fall into four categories, each answering a different question.
| Metric | Meaning | Use Case |
|---|---|---|
| Time to First Token (TTFT) | Time from sending the request to receiving the first output token | Conversational interaction, real-time assistants |
| Output speed | Tokens generated per second | Long-form text generation, streaming display |
| End-to-end latency | Total time from request to complete result | Batch processing, background tasks |
| Task pass rate | Share of results that meet quality standards | Any scenario requiring usable results |
A faster output speed doesn’t guarantee lower end-to-end latency. If a model generates longer content, the overall latency can still be higher even if tokens are produced faster per second. Speed metrics need to be read alongside output length.
Concurrency limits also matter. Even if a single request is fast, if requests queue up or get throttled under high concurrency, the real-world experience will still suffer. Load testing should simulate realistic concurrency peaks.
4. Building an Evaluation Framework
A reliable evaluation framework generally includes the following steps.
Step 1: Build a representative sample set. Pull 50 to 200 requests from real business scenarios, covering common cases, edge cases, and high-risk inputs. A sample that’s too small or contains only simple questions won’t produce representative conclusions.
Step 2: Fix the variables. Use the same prompts and the same sampling parameters, such as temperature, across the same batch of samples, and record the test date. Pricing and model versions for a service can change at any time, so conclusions need to be timestamped.
Step 3: Define quality criteria. Make quality criteria as automated as possible—for example, validating JSON format, checking whether key fields are present, or using rules or manual sampling to judge answer correctness. The clearer the criteria, the more reproducible the results.
Step 4: Calculate metrics and compare. For each service, aggregate total cost, pass count, average TTFT, and cost per effective result, then make a decision based on business priorities.
5. Sample Code
The code below demonstrates how to batch-collect data and calculate cost per effective result. call_model is a placeholder function that needs to be replaced with an actual API call. Pricing parameters should be obtained from the relevant service’s pricing page; the code does not include any specific prices.
def now():# Return the current high-precision timestamp (in seconds)...def run_case(call_model, prompt, check):start = now()resp = call_model(prompt) # Expected return: text, input_tokens, output_tokens, ttfttotal_time = now() - startreturn {"input_tokens": resp["input_tokens"],"output_tokens": resp["output_tokens"],"ttft": resp["ttft"],"total_time": total_time,"passed": check(resp["text"]),}def summarize(results, price_in, price_out):cost = sum(r["input_tokens"] * price_in + r["output_tokens"] * price_outfor r in results)passed = sum(1 for r in results if r["passed"])unit_cost = cost / passed if passed else float("inf")avg_ttft = sum(r["ttft"] for r in results) / len(results)return {"total_cost": cost,"passed_count": passed,"cost_per_effective_result": unit_cost,"avg_ttft": avg_ttft,}def check_json_field(text):# Example criterion: output is parseable and contains a "summary" fieldimport jsontry:return "summary" in json.loads(text)except ValueError:return False
The usage pattern is: run the full sample set against each service separately to get two sets of aggregated results, then compare cost per effective result rather than comparing unit prices directly.
6. A Hypothetical Comparison Example
Assume two services, both using fictional data for illustration only.
- Service A: cost per call of 1.00 (currency unit), pass rate of 90%, cost per effective result ≈ 1.00 ÷ 0.9 ≈ 1.11.
- Service B: cost per call of 0.60, pass rate of 50%, cost per effective result = 0.60 ÷ 0.5 = 1.20.
Service B has a lower unit price, but because its pass rate is lower, the actual cost of each usable result is higher. If manual review is also required, the gap widens further. This illustrates why sourcing decisions should be based on actual measurements from the same batch of samples, not list prices alone.
7. Common Pitfalls
- Looking only at unit price: Ignoring output length, retries, and rework leads to conclusions that diverge from reality.
- Looking only at speed: Fast but unusable results are effectively worthless.
- Unrepresentative samples: Using a handful of demo questions instead of real business data produces conclusions that don’t hold up.
- Ignoring the time factor: Both pricing and performance change over time; data without a test date is hard to reuse.
- Ignoring concurrency: Good single-request performance doesn’t guarantee stability during peak load.
8. Practical Recommendations
In real-world projects, consider routing requests by task type:
- Interactive tasks (e.g., real-time Q&A): Prioritize TTFT, and within the constraint of meeting a quality threshold, choose the faster-responding tier.
- Batch tasks (e.g., offline summarization, data cleaning): Prioritize cost per effective result, and accept longer end-to-end latency.
- High-risk tasks (e.g., compliance review, financial output): Prioritize quality criteria over cost, and keep a manual review step in place.
It’s also worth formalizing the evaluation process and re-testing periodically. Model capabilities, pricing rules, and business requirements all change over time, so a one-time sourcing decision will become outdated quickly. Archive the samples, parameters, and results from each test run so future comparisons have a solid basis.
Ultimately, judging whether a service is cost-effective comes down to calculating the effective cost of completing real tasks while meeting latency and quality requirements. Once the framework is in place, sourcing decisions shift from subjective judgment to reproducible, data-driven decisions.
