LLM API Cost Comparison and Model Selection: A Practical Guide

    Choosing an LLM API by per-token price alone often leads to unexpectedly high bills. This guide explains how to run a reproducible model comparison using a fixed task set, consistent prompts, and raw metrics across delivery quality, latency, request count, and cumulative output tokens. It shares measured observations on convergence speed, outlines why models differ, and offers practical selection and cost-optimization recommendations.

    1. The Problem: A Low Unit Price Does Not Mean a Low Bill

    When integrating LLM capabilities into a business system, teams most often make the mistake of making decisions based only on the “price per thousand tokens.” The real bill is determined by four variables working together: the number of interaction turns required to complete a task, cumulative output tokens (including reasoning), end-to-end latency, and the extra consumption caused by failed retries. Unit price is only one multiplier among them. Moreover, vendors differ in how they price peak versus off-peak usage, input versus output, and reasoning tokens, so directly comparing unit prices side by side is almost meaningless.

    A more reliable approach is to treat model selection as a reproducible engineering experiment: fix the task set, fix the prompts, and fix the runtime environment, change only the model under test, and then record verifiable raw metrics.

    2. Experiment Design: Making the Comparison Reproducible

    A credible comparison experiment should satisfy at least the following constraints:

    1. Environment isolation: use a brand-new empty directory for every task and every model, so that artifacts from the previous run cannot be reused or served from cache;
    2. Consistent prompts: send exactly the same prompt to both models for the same task, without adding any supplementary instructions midway, simulating a real “one-shot delivery” scenario;
    3. Raw metrics only: record only data that machines can export, rather than scoring based on subjective impressions;
    4. Unified accounting: convert all costs into the same currency using publicly listed standard prices, and additionally provide a lower bound under off-peak discounts.

    The task set should cover two high-frequency categories. The first is everyday office work, such as generating an editable spreadsheet budget or turning a meeting recording transcript into structured minutes. The second is product and operations work, such as generating illustration assets or hand-written interactive animations. The former examines structured output and format fidelity; the latter examines long-context consistency, code correctness, and multi-turn self-correction.

    3. Metrics: All Three Dimensions Are Required

    • Delivery quality (first-pass usability): can the artifact be opened directly, edited directly, and does it satisfy every constraint? It is recommended to break constraints into a checklist and judge them item by item, avoiding “looks good enough.”
    • Efficiency (end-to-end latency + request count): the request count reflects the model’s “self-correction cost.” More requests often mean it needs repeated trial and error before converging.
    • Cost (cumulative output tokens × unit price): be sure to include reasoning output, because many options look cheap on the surface but have extremely long reasoning chains.

    A sample record structure can be written as:

    1. record = {
    2. "task": "budget_xlsx",
    3. "model": "model_a",
    4. "wall_time_sec": 0.0,
    5. "request_count": 0,
    6. "output_tokens": 0, # includes reasoning output
    7. "cost_cny": 0.0, # converted using public unit prices
    8. "checklist_pass": 0, # passed items / total constraints
    9. }

    4. Measured Observations: The Gap Appears in Convergence Speed

    In tests across four tasks, the difference between the two models was not reflected in the per-token price, but in the convergence path. One model produced about one hundred thousand cumulative output tokens at a total cost of less than one yuan; the other produced more than two hundred thousand cumulative output tokens, made over a hundred requests, took more than twenty minutes, and cost roughly a dozen times more when converted, still several times higher even at half price during off-peak hours.

    Take a task like a “three-style web animation” as an example. The requirement was to hand-write an animation of about 30 seconds from scratch, with the main subject moving to the right, smoothly switching art style every 10 seconds, and providing pause, restart, and speed controls. The low-convergence-cost model delivered with just over twenty requests, under six minutes, and about forty thousand tokens; the high-convergence-cost model needed over a hundred requests, twenty-five minutes, and two hundred and ten thousand tokens to converge. The root of the gap is that the former basically satisfied the constraints in a single generation, while the latter fell into a “generate—error—patch” loop, and every loop had to re-output large sections of context.

    5. Why This Gap Occurs

    1. Instruction following: the more constraints there are (duration, switching rhythm, complete controls), the more it tests the model’s ability to satisfy multiple conditions at the same time;
    2. Long-context stability: animation code can easily run to hundreds of lines, and the model must keep variable naming and logic consistent across a long output;
    3. Self-correction efficiency: whether it can pinpoint the issue precisely after an error, instead of rewriting the whole thing;
    4. Output redundancy: if a reasoning model lacks restraint, it produces a cost-amplifying effect.

    6. Actionable Selection and Optimization Recommendations

    • Build an internal baseline set: accumulate 10–20 real tasks and run them every time a new model is integrated, forming a trend curve;
    • Layered routing: send structured, short-output tasks to lightweight, cost-effective models; send complex code and long-form reasoning to more capable models;
    • Front-load constraints: write acceptance criteria into the prompt to reduce round trips, which is the most effective way to cut costs;
    • Caching and reuse: archive reusable artifacts to object storage, and make long tasks asynchronous with a message queue;
    • Observability: use logging services and monitoring alerts to collect latency, tokens, and failure rates, forming a cost dashboard;
    • Elasticity and fallback: use a container platform to host the inference gateway, and set timeout and degradation policies to avoid a single task draining the overall budget.

    If an enterprise wants to complete the evaluation and governance described above within its own data and compliance boundaries, it can use relevant cloud product capabilities from Baidu AI Cloud to bring the evaluation pipeline, cost dashboard, and permission auditing under unified management.

    7. Conclusion

    The right way to select a model is not to compare unit prices, but to compare “the cost per unit of effective delivery.” Fix the tasks, make the metrics raw, and unify the accounting, and you can make explainable, reviewable, and continuously optimizable decisions among quality, latency, and budget.