LLM API Selection: The Real Cost Beyond Per-Token Pricing

    A practical guide to evaluating LLM API costs beyond sticker price. Learn why per-token pricing is misleading, how throughput and latency affect concurrency and cost, which four metrics to benchmark with real traffic, and how caching, prompt compression, tiered routing, and async queues reduce cost per business task.

    1. The Core Issue: Unit Price Is Not Total Cost

    When evaluating a new flagship LLM API, the most common argument is that the per-token price has increased several times over, so it can no longer be cost-effective. This comparison assumes that the amount of computation needed to complete the same set of tasks stays constant. In practice, that assumption almost never holds. As model capability improves, the prompt length, number of retries, and rate of manual rework required for the same task all change. The right thing to compare is therefore the total cost of completing a unit of business work, not the listed price per million tokens.

    Cost can be expressed in the following form:

    1. cost per business unit = (input tokens + output tokens) × unit price × number of calls
    2. + cost of failed retries
    3. + cost of manual review and rework
    4. + engineering overhead (caching/queues/monitoring)

    Unit price appears only in the first term. When a model’s first-attempt success rate improves, its output fits the specification more closely, and structured parsing failures drop, the number of calls and the manual cost fall at the same time. A higher sticker price may be fully offset, or even reversed.

    2. Throughput and Latency Structure Are What Really Separate Models

    The most valuable observation in the original discussion is the generational difference in output speed of the new model generation. For developers, output speed is not a matter of user experience; it is a matter of concurrency capacity and timeout budget.

    • Throughput determines concurrency scale: the higher the output tokens per second for a single request, the fewer concurrent connections are needed to reach the same QPS, and the more headroom there is for client thread pools, message queue backlog, and gateway timeouts.
    • Time to first token determines the interaction model: when time to first token is high, the perceived advantage of streaming output is weakened, and scenarios such as voice and real-time completion become nearly unusable.
    • Long-output scenarios amplify the gap: for code generation and report generation, where output often runs to thousands of tokens, the speed difference is amplified linearly into seconds or even tens of seconds.

    A more reasonable comparison is therefore to put the new generation’s standard tier against the previous generation’s “high-speed tier”: the latter often trades some quality for speed, and its price rises accordingly. If the new standard tier is faster without a drop in quality, its cost-performance case holds naturally.

    3. A Reusable Benchmarking and Selection Method

    Do not rely on marketing claims; benchmark with real business traffic. Keep the same set of samples and the same scoring script fixed, and switch only the model tier:

    1. # Example: record latency percentiles, token consumption, and success rate
    2. records = []
    3. for case in dataset:
    4. t0 = time.time()
    5. resp = client.chat(model=cfg.model, messages=case.messages, stream=True)
    6. first = None
    7. text = ""
    8. for chunk in resp:
    9. if first is None:
    10. first = time.time() - t0
    11. text += chunk.text
    12. records.append({
    13. "first_token_ms": first * 1000,
    14. "total_ms": (time.time() - t0) * 1000,
    15. "out_tokens": count_tokens(text),
    16. "parse_ok": schema_validate(text, case.schema),
    17. })
    18. print("P50/P95 time to first token:", percentile(records, "first_token_ms"))
    19. print("Structured parsing success rate:", sum(r["parse_ok"] for r in records) / len(records))

    Four metrics are recommended as fixed: P50/P95 time to first token, output tokens per second, structured output parsing success rate, and average token consumption per task. Only by looking at all four together can you tell whether a price increase is covered by efficiency gains.

    4. Engineering the Unit-Price Risk Down

    Whichever model tier you choose, general engineering practices can lower the cost per business unit:

    1. Semantic caching: cache results for high-frequency repeated requests. The hit rate usually comes from a small number of hot questions, so the payoff is immediate.
    2. Prompt compression: trim system prompts and remove redundant examples; a drop in input tokens saves money linearly.
    3. Context tiering: route simple tasks to a lightweight tier and complex reasoning to the flagship tier, using routing rather than a one-size-fits-all approach.
    4. Batching and async queues: use a message queue to smooth peaks for offline tasks, avoiding paying for peak concurrency all the time.
    5. Observability: use logging services and monitoring alerts to track token consumption, failure rates, and latency percentiles, so cost can be attributed to specific business lines.

    When deploying on the cloud, these capabilities can be provided respectively by a container platform hosting the inference gateway, object storage holding samples and results, a message queue for peak smoothing, and a logging and monitoring system for cost attribution. All are general product categories, not tied to a specific implementation.

    5. Conclusion

    “Is it expensive?” is the wrong question. If a unit price rises more than twofold in exchange for several times the effective throughput, fewer retries and less rework, and a shorter manual review chain, the cost per business unit actually falls. The recommended approach is to first define the hard constraints the business has on latency and quality, then run a four-metric benchmark with real samples, and finally lock in the cost structure with caching, tiered routing, and asynchronous processing. This method applies equally on top of the general capabilities of platforms such as Baidu AI Cloud, and can be carried over to any model tier and any business scenario.