How to Evaluate LLM Cost-Effectiveness: A Two-Dimensional Framework for Cost and Performance

    This article explains why the listed per-token price of a large language model does not show its real cost. It shows how to model the total cost of a task, including cache hits, failed runs, and retries, and how to measure performance with automatically checkable metrics and repeated trials. It also covers simulated environments for testing agents, the trade-off between reasoning depth and caching, experiment design practices, and a scenario-based approach to model selection.

    1. Unit Price Is Not the Same as Cost

    LLM API usage is typically billed by token. Input and output tokens are priced separately, and output tokens usually cost more. As a result, a model with a lower listed price is not necessarily cheaper to run. There are three main reasons. First, the same task can produce very different output lengths across models. Second, when deep reasoning is enabled, the model generates a large number of reasoning tokens, and these are usually billed as output. Third, retries after a failed task can multiply the cost.

    To judge cost-effectiveness, use the total cost of completing one task as the unit of measurement. The price per million tokens is only one input to that total.

    2. Breaking Down the Cost Model

    The cost of a single call can be expressed as:

    C = N_in × P_in + N_cache × P_cache + N_out × P_out

    Here, N_in is the number of input tokens that miss the cache, N_cache is the number of input tokens that hit the cache, N_out is the number of output tokens, and P is the unit price for each category. If a task requires multiple calls, sum the cost across all rounds, including every call made for failed retries and debugging.

    The following is an illustrative calculation function. The prices are passed in by the caller, and the code does not include any specific pricing.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Usage:
    4. input_tokens: int # Input tokens that miss the cache
    5. cached_tokens: int # Input tokens that hit the cache
    6. output_tokens: int # Output tokens, including reasoning tokens billed under the pricing rules
    7. @dataclass
    8. class Price: # Unit: currency per million tokens
    9. input: float
    10. cached: float
    11. output: float
    12. def task_cost(usages: list[Usage], price: Price) -> float:
    13. total = 0.0
    14. for u in usages:
    15. total += u.input_tokens * price.input
    16. total += u.cached_tokens * price.cached
    17. total += u.output_tokens * price.output
    18. return total / 1_000_000

    The effect of caching is often underestimated. In multi-turn conversations or agent loops, the system prompt and conversation history are highly repetitive, so the cache hit rate can directly change the bill. However, caching rules, minimum hit lengths, and validity periods differ across platforms. Verify actual cache hits in your call logs rather than estimating them from marketing claims.

    3. Quantifying Performance

    Cost is the numerator, and performance is the denominator. Only by combining the two can you assess cost-effectiveness. Break performance into metrics that can be judged automatically:

    • Goal completion rate: whether the explicit termination conditions are met;
    • Constraint compliance: the number of rule violations during execution;
    • Step efficiency: the number of operation rounds needed to reach the goal;
    • Stability: the success rate and variation across repeated runs of the same task.

    LLM outputs are stochastic, so the result of a single run is unreliable. Run each task several times, and report the success rate and the distribution of costs. Do not look only at the best run.

    On this basis, you can define a composite metric:

    Cost per successful task = total spend / number of successful runs

    This metric counts the cost of failed calls as well. A model with a low unit price but a low success rate can have a higher cost per successful task than a more expensive model that is more reliable.

    4. Stress Testing with Simulated Environments

    Question-answering benchmarks do not capture how an agent performs in long decision chains. One feasible approach is to build a simulated environment with clear rules and results that can be scored automatically.

    Consider a market microstructure simulation as an example. The environment includes several types of participants: noise traders who trade at random, informed traders who have some information advantage, and market makers who adjust quotes according to set rules. The tester takes on the role of a trader and must complete several stage goals in sequence under constraints, for example:

    • Push the closing price above a target level;
    • Accumulate a position of a specified size at prices below the volume-weighted average price (VWAP);
    • Sell a large holding in batches while keeping the one-directional price deviation under control.

    This type of task has three advantages. The goals can be quantified, the full process can be recorded, and the constraints can be checked by a program. The model must maintain state across multiple steps, understand the rules, and weigh trade-offs. Because of this, it reveals differences in capability more clearly than single-turn Q&A.

    The following is a sample scoring script:

    1. def score_run(log: dict) -> dict:
    2. rounds = log["rounds"]
    3. goals_met = sum(1 for r in rounds if r["goal_met"])
    4. violations = sum(r["constraint_violations"] for r in rounds)
    5. return {
    6. "goal_rate": goals_met / len(rounds),
    7. "violations": violations,
    8. "total_tokens": log["usage"]["total_tokens"],
    9. "cost": log["usage"]["cost"],
    10. }

    When you design the scoring rules, define the boundary of a “violation” in advance. For example, should a price deviation above a threshold in a single round count as one violation, or should a violation count only when the cumulative deviation exceeds a threshold? The clearer the boundary, the fairer the comparison between models.

    5. Trade-offs Between Reasoning Depth and Caching

    Higher reasoning depth usually improves the completion rate of complex tasks. However, it also increases output tokens and lengthens response time. For simple tasks such as classification, information extraction, and text rewriting, a high reasoning depth often adds cost without a clear benefit. A practical approach is to set reasoning levels by task difficulty, using different parameter combinations for different requests.

    The benefit of caching also needs to be measured. Tiered configuration and the cache hit rate together determine the final bill. Record the number of cached tokens for each request at the call layer, aggregate the figures by task type, and identify the stages that cost the most.

    6. Experiment Design Considerations

    1. Use the same prompts, task descriptions, and scoring scripts for all candidate models.
    2. Record the model version, inference parameters, and call time, because server-side models can be updated at any time.
    3. Track one-shot generation and multi-turn iteration separately, because their cost structures differ significantly.
    4. Include all calls in the cost calculation, including failed runs, retries, and intermediate debugging.
    5. Use enough samples. If each task runs only once, the conclusions are not reliable.

    7. Model Selection Recommendations

    No model leads on every dimension. Teams can build a selection matrix based on their scenarios:

    • High-frequency, low-complexity tasks: compare cost per token and response latency first;
    • Long-chain reasoning and agent tasks: compare task completion rate and cost per successful task first;
    • Code generation and structured output: compare format compliance rate and the amount of manual editing required first.

    We recommend that teams maintain their own evaluation set. Rerun it after each price change or model version update, and then decide whether to switch models based on the results. This is more reliable than relying on a single trial or public leaderboard rankings.