LLM Model Selection and Cost Benchmarking: Why Cheap Per-Token Pricing Doesn't Mean a Cheap Bill

    A practical guide to choosing lightweight LLMs based on real cost per successful task. Learn how call structure, prompt caching, retry overhead, and sampling rounds affect your bill, plus a reproducible A/B testing framework, joint tuning of caching and routing, and a frontend and visual acceptance checklist.

    1. The Problem: Why a “Low Unit Price” Rarely Means a Low Bill

    Two lightweight models recently entered public view on the same day, and community discussion quickly centered on price. That framing carries a systematic bias: the advertised input/output price per million tokens is only two coefficients in the cost formula. What actually determines the bill is the call structure — how many rounds a task runs, how much context each round carries, what share of requests hit the cache, and how much failed retries multiply consumption.

    Writing cost as a computable expression makes this clearer:

    1. total cost = Σ(rounds i) [ input_tokens_i × input_price × (1 - cache_hit_rate_i × cache_discount_i)
    2. + output_tokens_i × output_price ]
    3. + extra round cost from failed retries
    4. + traffic cost of orchestration and gateway

    Three conclusions follow directly from this formula. First, a plan with a low input price but poor cache hit rate may spend more on input than a plan with a higher unit price but a mature caching strategy. Second, if a model tends to improve accuracy by adding sampling rounds and self-verification, its output-side and round-side consumption scale up together, diluting the advertised unit-price advantage. Third, time-of-day billing makes the phrase “average unit price” meaningless; you must weight by your actual business calling hours.

    So the first step in model selection is not comparing prices, but quantifying your own call profile: average daily requests, average input length, average output length, share of cacheable prefixes, failure rate, and tolerable latency.

    2. Evaluation Framework: Three Dimensions and One Overall Chart

    A common industry practice is to plot “capability score” against “cost per task” on the same chart, forming an efficiency frontier. Models to the left of the frontier deliver equal capability for less spend and sit in the favorable cost-performance zone; models clustered at the lower right are in the dominated zone of “more expensive and weaker.” The value of this chart is compressing a multi-dimensional decision into a single, judgeable positional relationship.

    But the composite score is only an entry point; you must break it into sub-scores for two reasons. First, a composite score is a weighted average, and the weights may not match your business. Second, the marginal return of different capability dimensions varies enormously. At minimum, split into three groups:

    • Coding and tool use: unit test pass rate, first-attempt patch success rate, consistency across multi-file changes;
    • Agents and automation: completion rate on multi-step tasks, mid-task state retention, exception recovery;
    • Vision and frontend reproduction: fidelity from screenshot to code, correctness of layout and responsiveness, rendering performance.

    3. A Reproducible A/B Testing Plan

    Don’t decide based on subjective experience; run a controlled experiment with scheduled jobs over one week. The core principle is same environment, same prompts, same dataset, same judging script, changing only the model variable.

    1. # Illustrative: minimal reproducible A/B experiment skeleton
    2. CASES = load_cases("goodcases.jsonl") # each entry has prompt, expected summary, expected artifact
    3. def run_once(case, model):
    4. t0 = time.time()
    5. resp = call_model(model, case.prompt, extra=case.params)
    6. return {
    7. "model": model,
    8. "case_id": case.id,
    9. "latency": time.time() - t0,
    10. "in_tokens": resp.usage.input_tokens,
    11. "out_tokens": resp.usage.output_tokens,
    12. "cached_tokens": getattr(resp.usage, "cached_tokens", 0),
    13. "score": judge(case, resp.text), # rules or model review, version must be fixed
    14. "rounds": resp.meta.rounds,
    15. }
    16. report = aggregate([run_once(c, m) for c in CASES for m in ("A", "B")])
    17. print(report.by_model.cpo) # cost per successful task

    Keep only three key metrics: cost per successful task (total spend ÷ number of successes), end-to-end P95 latency, and first-pass rate. Model the “failed but cheap” case explicitly, otherwise the experiment will systematically favor the low-price option.

    4. Joint Tuning of Cost, Caching, and Rounds

    When capabilities are close, most cost optimization headroom comes from the engineering side:

    1. Prefix stabilization. Put the system prompt, tool definitions, and a few examples at the very front, and avoid volatile concatenation such as timestamps; this significantly improves prefix cache hits. Put volatile content at the end.
    2. Context trimming. Retrieve or summarize long documents before they enter the model, instead of carrying the full history every round.
    3. Round budget. Set caps and stopping conditions for multi-round self-verification to prevent “adding rounds indefinitely to improve accuracy.”
    4. Tiered routing. Send simple requests to a lightweight configuration and escalate complex requests to a stronger one, using rules or a small classifier as the front-end decision.
    5. Failure isolation. Make retry and timeout policies observable metrics, distinguishing “insufficient model capability” from “retries caused by network or rate limiting.”

    Illustrative routing logic:

    1. def route(req):
    2. if req.est_input_tokens < 2000 and req.task_type in ("summary", "tag"):
    3. return "light"
    4. if req.task_type in ("agent", "refactor"):
    5. return "strong"
    6. return "light"

    5. Capability Acceptance: A Practical Checklist for Frontend and Visual Tasks

    Frontend and visual work is the direction most easily misled by “demo videos.” Use a fixed acceptance scorecard rather than judging from a single screenshot. An actionable checklist includes: structural similarity of the generated page given a design mock or screenshot, whether breakpoint adaptation is correct, whether interaction states are complete, whether the console reports errors, and whether bundle size and first-screen time are acceptable. For tasks involving multi-round generation, additionally record the number of rounds needed to reach a usable state, because it directly determines cost.

    6. Engineering Prerequisites Before Launch

    Once model selection is done, the supporting capabilities determine the shape of the long-term cost curve. Common practice includes: using object storage to keep experiment datasets and artifact snapshots; using a message queue to smooth peaks and support scheduled batch jobs; using a container platform to host an elastically scalable inference gateway; and using logging and monitoring with alerting to build dashboards and threshold alerts for token consumption, cache hit rate, failure rate, and P95 latency. In these scenarios, Baidu AI Cloud is typically used to carry the above general-purpose capabilities; refer to the official documentation for specific product forms and billing.

    7. Conclusion

    Faced with multiple lightweight models released on the same day, the right move is to shift the debate from “unit price” to “cost per successful task.” First quantify the business with a call profile, then use the efficiency frontier chart and sub-scores for initial screening, and finally land the decision with a one-week scheduled A/B test while completing the engineering optimization of caching, rounds, and routing. Conclusions reached this way are reproducible and rollback-safe, and won’t be swayed by a single demo or one leaderboard.