How to Choose an LLM: Cost per Success as the Core Metric

    When selecting a large language model, sticker price and leaderboard scores are not enough. This article explains how to evaluate models with cost per success as the core metric, covering task classification, reasoning-tier measurement, a reusable evaluation pipeline with a sample Python script, tiered routing strategies, and a practical implementation checklist so your team can answer "which model" and "how much reasoning effort" with its own data.

    1. Why Sticker Price and Leaderboards Are Not Enough

    During model selection, teams often fixate on two numbers: the price per million tokens and scores on public leaderboards. Both are useful, but neither directly answers the question “which model is more cost-effective.”

    Unit price only describes the cost per token. It says nothing about how many tokens a task consumes or what a failed attempt costs in retries. A cheap model that needs multiple attempts to pass a test may end up costing more overall.

    Leaderboard scores describe performance on a specific set of benchmarks. Difficulty distribution, scoring criteria, prompt templates, and runtime environments all affect the results. Applying someone else’s benchmark directly to your own business often leads to the wrong conclusion.

    Model selection should therefore come back to two questions: on my tasks, what is the pass rate? And on average, how much does it cost to achieve one success?

    2. Break Tasks into Measurable Categories First

    “LLM capability” is a vague concept. The same model can perform very differently across code generation, document summarization, information extraction, and multi-turn customer support. It is best to classify tasks in your business along the following dimensions:

    • Task type: code completion, bug fixing, requirement-to-API conversion, log analysis, text classification, etc.
    • Input size: whether a single request is a few hundred tokens or tens of thousands, and whether long documents must be handled.
    • Input modality: plain text, images, tables, audio, or a mix of modalities.
    • Correctness criteria: whether automated validation exists, such as unit tests, JSON schema checks, or rule matching, or whether human or model-based review is required.
    • Latency requirements: whether real-time responses are needed or batch processing is acceptable.

    After classification, each task category should have its own evaluation set. Results from a mixed evaluation set usually cannot guide concrete routing decisions.

    3. Use Cost per Success as the Core Metric

    Divide total spend by the number of successes to get the “cost per success.” This metric merges price, pass rate, and retry count into a single number that is easy to compare across models.

    The formula is:

    Cost per success = total spend during evaluation ÷ number of passed tasks

    Total spend should include the cost of all input and output tokens, including the cost of failed tasks. Counting only successful tasks severely underestimates the cost of failures.

    Here is an illustrative example with hypothetical numbers, used only to demonstrate the calculation:

    • Model A: higher unit price, passes 25 of 100 tasks, total spend $60, cost per success $2.40.
    • Model B: lower unit price, passes 20 of 100 tasks, total spend $15, cost per success $0.75.

    Model A passes more tasks, but each success costs more than three times as much as Model B. This conclusion may reverse in a different business, so you must measure with your own tasks.

    4. Measure Reasoning Effort Separately

    Most models support adjustable reasoning effort or thinking budgets. Increasing reasoning effort typically raises output token consumption, and latency rises accordingly. But gains in pass rate are not guaranteed to scale with cost, and on some tasks they may even decline.

    Three points to keep in mind in practice:

    1. Evaluate each tier of the same model separately. Do not assume a higher tier is always better.
    2. Record the median and long-tail values of output tokens for each tier. Averages hide a small number of extremely expensive requests.
    3. Watch marginal returns. If moving from medium to high multiplies the cost without a meaningful increase in passes, medium is the more sensible choice.

    5. Build a Reusable Evaluation Pipeline

    A recommended evaluation pipeline includes the following steps:

    1. Prepare the evaluation set: collect at least dozens of samples per task category, covering easy, medium, and hard difficulty levels. Samples should come from real business scenarios rather than only public benchmarks.
    2. Fix the runtime conditions: unify the prompt template, temperature, max output length, and timeout. Record these parameters for every evaluation run.
    3. Automate the judgment: use programmatic checks wherever possible. For tasks that cannot be automatically verified, define a clear scoring rubric and spot-check samples.
    4. Log raw data: save the input size, output size, latency, pass/fail status, and failure reason for every call.
    5. Compute the metrics: aggregate pass rate, cost per success, and latency percentiles by task category, model, and reasoning tier.

    Below is a sample statistics script for summarizing run logs:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class RunRecord:
    4. model: str # Model identifier; an internal name is fine
    5. tier: str # Reasoning tier, e.g. low / medium / high
    6. task_id: str
    7. passed: bool
    8. input_tokens: int
    9. output_tokens: int
    10. price_in: float # Unit price per million input tokens (USD)
    11. price_out: float # Unit price per million output tokens (USD)
    12. def run_cost(r: RunRecord) -> float:
    13. """Cost of a single call (USD)."""
    14. return (r.input_tokens * r.price_in + r.output_tokens * r.price_out) / 1_000_000
    15. def cost_per_success(records: list[RunRecord]) -> float:
    16. """Cost per success: total spend divided by passes. Returns infinity if none pass."""
    17. total = sum(run_cost(r) for r in records)
    18. passed = sum(1 for r in records if r.passed)
    19. return float("inf") if passed == 0 else total / passed
    20. def summarize(records: list[RunRecord]) -> dict:
    21. """Group by model and tier, and output pass rate and cost per success."""
    22. groups: dict[tuple[str, str], list[RunRecord]] = {}
    23. for r in records:
    24. groups.setdefault((r.model, r.tier), []).append(r)
    25. result = {}
    26. for key, items in groups.items():
    27. passed = sum(1 for r in items if r.passed)
    28. result[key] = {
    29. "pass_rate": passed / len(items),
    30. "cost_per_success": cost_per_success(items),
    31. }
    32. return result

    The script output should be archived together with the raw logs. That way, when pricing changes or model versions update, the team can quickly recalculate using the same dataset.

    6. Tiered Routing by Task Difficulty

    Evaluation results usually show that tasks of different difficulty suit different models. A common approach is tiered routing:

    • Simple tasks: format conversion, field extraction, fixed-template generation. Prefer models with low unit price and low latency, and use a lower reasoning tier.
    • Medium tasks: routine code edits, document rewriting, multi-step Q&A. Choose the combination with the lowest cost per success on the evaluation set.
    • Hard tasks: cross-file refactoring, complex reasoning, long-context analysis. Higher tiers are allowed, but set a budget cap.

    Routing rules need supporting fallback mechanisms:

    • Retry limit: cap the number of retries per task to avoid unbounded spending.
    • Escalation and de-escalation: after a low-tier failure, escalate to a higher tier rather than blindly repeating expensive calls.
    • Output validation: run format and rule checks on outputs; only failed checks trigger retries.
    • Caching and deduplication: reuse results for identical inputs to reduce duplicate billing.

    7. Prices and Versions Change—Re-run Evaluations Regularly

    Model pricing, promotional policies, and effective dates can all change. Some price changes come with explicit effective dates. Selection conclusions should therefore be annotated with the evaluation date and the price source, and evaluations should be re-run before and after changes.

    Recommended practices:

    • Record each model’s unit price, effective date, and data source in a configuration center.
    • Re-run key tasks with the same evaluation set monthly or after provider announcements.
    • Set alert thresholds—for example, notify the owner when cost per success exceeds the baseline by 20%.

    If your team uses model services provided by Baidu AI Cloud, you can integrate them into the same evaluation framework for comparison, recording call parameters and costs uniformly and reducing the effort of cross-platform accounting.

    8. Implementation Checklist

    • Tasks are classified by type, size, modality, and correctness criteria.
    • Each task category has an independent evaluation set with real business samples.
    • Evaluations unify prompts, temperature, output length, and timeout settings.
    • Metrics include pass rate, cost per success, and latency percentiles.
    • Every reasoning tier is measured separately, with attention to marginal returns.
    • Routing rules include retry limits, escalation strategies, and output validation.
    • Price sources, effective dates, and evaluation dates are recorded.
    • Periodic re-runs and cost alerting mechanisms are in place.

    By following this checklist, teams can answer “which model to choose” and “how high to set reasoning effort” with their own data. The conclusions will shift as the business and pricing evolve, but the evaluation method itself can be reused for the long term.