Choosing an LLM by Task Cost, Not Sticker Price
A practical guide for backend and AI application developers comparing LLM tiers. It explains why a low per-token price does not mean a cheap task, how to break cost into nominal pricing, task usage, and quality rework, how to translate a vendor price list into a per-task cost formula, how to align context windows before judging capability, how to use benchmarks without being misled, and how integration style drives engineering effort. It closes with a decision checklist for picking a model tier.
Correcting a common misconception
A low API list price does not mean the task itself is cheap. For the same problem, different models consume different input tokens, produce different output lengths, may or may not trigger long-context surcharges, and hit the cache at different rates. What you should actually compare is the total cost of finishing the task, plus the development cost of error rework, human review, and latency.
Who this is for: backend and AI application developers choosing between several LLM tiers. The methods below are not tied to any specific model; they give a reusable comparison approach. When you need to land this on cloud gateways, logs, and billing, you can capture usage with a general-purpose API gateway, object storage, a logging service, and monitoring alerts. If your team already meters everything on Baidu AI Cloud, connect the same measurement definitions to the billing dimension; you do not need to change the decision logic.
Split selection into three layers of cost
Break “is it expensive?” into three layers so you don’t substitute the advertised price for the actual bill.
- Nominal unit price: input, output, cache read, cache write, and whether long context surcharges the whole request.
- Task usage: how many tokens one request actually consumes, whether the output tends to run long, and whether the system prompt is resent in full every time.
- Quality cost: retries, manual edits, and regression testing caused by wrong answers, missed steps, or non-compliant formatting. A cheap unit price with heavy rework is often more expensive.
In short: for short requests, compare unit price; for long context, compare whether the billing rule doubles the whole request; for production traffic, compare cache hits and output length; before launch, compare how the error rate inflates your schedule.
Translate the official price list into a per-task cost
Don’t just copy the first line of the price table. Fix a repeatable formula (keep units consistent with the vendor’s price list, usually per million tokens):
Per-request cost ≈uncached input × input price+ cache read volume × cache read price+ cache write volume × cache write price+ output volume × output price
If a tier multiplies the input, cache, or output of the entire request by a factor once input exceeds a threshold, you must apply the factor to the corresponding component, not only to the portion above the threshold. This is where long documents, whole-repo code, and multi-turn agents are most often miscalculated.
Prepare at least three kinds of samples for the comparison, not a single “hello”:
- Short requests: single-turn Q&A, classification, small completions. Here the output price and the model’s default verbosity usually dominate the bill.
- Medium context: with specs, interface descriptions, and a little code. Check whether the system prompt can be cached, and whether the cache is an implicit hit or an explicit write (the write itself is billed and has a time to live).
- Very long requests: specs, logs, or repo slices close to the window limit. Confirm whether a second pricing tier exists, and whether exceeding the threshold surcharges only the excess or bills the whole request at the higher rate.
Read cache pricing separately: some products only have implicit caching and don’t list writes separately; some bill writes by a time window. If an example temporarily ignores writes, state “cache writes not counted” in the conclusion, otherwise short contexts look cheap but become more expensive once the cache is warmed.
Illustration (numbers demonstrate the method only; they are not any vendor’s quote):
Sample: 400K input tokens, of which 300K hit the cache, 8K outputModel A: input 3, cache read 0.3, output 12, no long-context surchargecost = 100K×3/1e6 + 300K×0.3/1e6 + 8K×12/1e6Model B: short-context input 2, cache read 0.2, output 8but if input exceeds 270K, the whole request input and cache ×2, output ×1.5here B's effective unit price is above its nominal price; recompute after the surcharge
The conclusion is often: B is cheaper for short requests; once a single request’s input crosses the threshold, A’s “flat price” may be steadier. You cannot declare a winner straight from the first line of the price table.
Align the specs first, then argue about who is stronger
Before comparing capability, align the windows to the same constraint, or the benchmark is meaningless.
- Context window: whether input and output share one budget. Some models cap maximum output separately, so long reasoning or long code gets truncated; it looks like it “fits,” but the task actually fails.
- Max input / max output: the default output limit of the synchronous interface may differ from backend long decoding and asynchronous tasks. Look at timeouts and gateway limits together.
- Whether billing and window definitions match: a large window that jumps in price past a threshold means “usable but not advisable.”
Keep only these dimensions in the selection table: nominal input price, cache read/write, output price, long-context rule, window, max output, and default synchronous timeout. Mark cells without official documentation as “not disclosed”; don’t guess.
How to use benchmarks without being driven by the leaderboard
Public benchmarks are good for narrowing the candidate set, not for picking the production model directly. Common biases:
- Short prompts and short outputs that don’t reveal long-context surcharges or verbose output.
- Only accuracy reported, without tokens and latency, so you can’t convert to task cost.
- Coding tasks that allow multiple samples, while production is single-shot, low temperature, and requires stable JSON.
A safer approach is to build a small set of “golden tasks” covering your real traffic: interface implementation, defect localization, log attribution, table extraction, and multi-file edits. For each task, fix:
- the input template and whether a cached prefix is allowed;
- the success criterion (tests pass, fields complete, no over-privileged suggestions);
- a record of input tokens, output tokens, elapsed time, and whether it retried.
Then compute two metrics:
- Completion cost = per-request cost × (1 + average number of retries), where retries include format repair.
- Human minutes = the editing time for failed samples. Multiplied by the labor rate, this is often larger than the API price gap.
You can read model tiers by their official positioning as three kinds, without naming a series: use the high-capability tier for the hardest long-horizon tasks; a low-latency, low-price tier for everyday short execution; and a middle tier for complex coding, analytical reasoning, and production workflows. Whether the expensive tier is worth it depends on whether “less rework” on the golden tasks outweighs the price difference, not on leaderboard rank.
Development cost: integration style affects the schedule more than the model name
The API shape largely determines engineering effort, regardless of brand.
- Stateless completion: fast to integrate, easy to cost, good for classification, extraction, and short completions.
- Multi-turn agents with tool calls: tokens grow with each turn, and a failure replays the entire history, so you must set a step limit and summary compression.
- Stuffing very long context directly: less retrieval code, but it easily triggers whole-request surcharges and is more prone to attention dilution and fabrication. For most teams, retrieval slices plus short context is more economical than filling the window with the whole repo at once.
Do the following uniformly at the gateway so you don’t have to touch business logic when switching models:
- Tag usage by application, environment, and model tier, and log input/output tokens, cache hits, and whether the long-context tier was used;
- Version your prompts and keep a stable system-prompt prefix to aid caching;
- Constrain output to a structured format, and route failures through one cheap repair instead of unlimited retries;
- Alert on over-threshold requests so that “the window is big enough” doesn’t become a billing surprise.
Illustrative usage capture (independent of any specific SDK):
record(app, model_tier,input_tokens, cached_read_tokens, cache_write_tokens, output_tokens,long_context=bool, retries=int, latency_ms=int, success=bool)
Report weekly with “completion cost of successful requests” and “wasted cost of failed requests” as separate columns. Looking only at average unit price hides long-tail large requests.
A decision checklist
When deciding between candidate tiers, ask in order:
- What share of traffic has a single-request input that crosses the long-context threshold? Once crossed, is the surcharge applied to the whole request or by segment?
- What share is a stable prefix? Is caching implicit or does it charge for writes? Does the time to live cover your call cadence?
- On the golden tasks, who has the higher completion rate? After counting retries and human minutes, who has the lower completion cost?
- Do latency and timeouts meet the synchronous interface? Must long outputs move to async?
- Does switching tiers only change the routing config? If business code is hard-wired to one vendor’s proprietary parameters, count the migration cost separately; don’t fold it into “the model is smarter.”
Three rules of thumb: for short requests, watch output price and verbosity; for long requests, first check whether billing jumps for the whole request, then check the window; after launch, watch cache hits and failed retries rather than the sticker price on release day. Write the samples, formulas, and success criteria into your selection record, and recompute with the same data the next time prices change or you switch tiers. That is more reliable than running another round of marketing-page comparisons.
