How to Choose an LLM API: Pricing, Capabilities, and a Practical Testing Method for Agent Workloads
Choosing an LLM API on per-token price alone almost always leads to the wrong decision. This article explains why identical tasks can cost an order of magnitude more on one provider than another, lays out a vendor-neutral selection order (input profile → acceptance criteria → shared evaluation set → total cost), and shows how to read context window, output budget, and thinking-mode specs without falling into common misreadings. It also includes a Python script for converting per-token prices into per-task and effective cost, the task categories and metrics needed to test long-document, multimodal, code, and multi-turn tool-calling workloads, the specific thresholds that make agent evaluation different, and the observability and cost-governance practices that keep bills predictable.
1. Same Work, Several Times the Cost
Hand the same business requirement to two different model services and the bill can differ by an order of magnitude. Take a concrete case: analyze a 200-page annual report, extract the key clauses, and generate a structured summary. On the cheaper option, one call costs a few cents. On the expensive one, it can cost a few dollars. The gap usually has nothing to do with which model is “smarter” and everything to do with four engineering factors:
- Unit price: input and output are billed separately, so the impact of unit price grows with the volume you generate;
- Number of calls: in a multi-turn agent loop, every turn resubmits everything generated so far as context, so token usage keeps accumulating;
- Output length: reasoning, code, and explanations all consume output budget, and output is usually priced higher than input;
- First-pass rate: any plan that needs rework has a real cost equal to its per-call cost multiplied by the number of retries.
So the right question is not “which one is cheaper,” but “does the cheap one pass on the first attempt, and does the expensive one actually reduce rework.”
Most mainstream models today support image and text understanding, tool calling, very long context, and streaming output as baseline capabilities. That means suffixes like “flagship,” “lite,” “Pro,” and “Flash” in a model name reflect the vendor’s product positioning only. They say nothing reliable about agent success rates. If your workload is mainly product image moderation or reading technical documents, the flagship and lite models from different vendors may not show a meaningful quality gap, so choosing by name is a poor strategy.
Only two things count as evidence: whether the specs match your actual inputs, and whether the model passes your own acceptance tests in practice.
2. Selection Order: Define Inputs and Acceptance First, Do the Math Last
The recommended order is: characterize input shape and quality → define acceptance criteria → build a shared evaluation set → estimate total cost. Many teams invert this order. They compare prices first and trial later, then discover the cheap model fails their quality bar and are forced to switch, which adds a whole round of migration cost.
1. Characterize input shape and quality. Start by profiling the real input distribution of your workload:
- What share is text, and what are the average and maximum input lengths in tokens?
- Are images mostly screenshots, scans, or high-resolution photos? What resolution, and do they contain small-print tables?
- Is there any video requirement, and do you need the model to interpret consecutive frames directly?
Input quality sets the effective ceiling on model capability. When an image is blurry or a document’s encoding is a mess, even the strongest model cannot return correct results reliably. Fix that with preprocessing first.
2. Define acceptance criteria. “Seems fine” is not acceptance. Break it down into measurable metrics:
- task completion rate (the share of structured outputs that pass schema validation);
- first-pass rate (the share needing no manual rework);
- manual rework time;
- P95 response time;
- average cost per task.
3. Build a shared evaluation set. Sample 30–50 representative cases from real historical tasks, covering high-frequency requests, long inputs, multimodal inputs, tool calls, and boundary or hard cases. Fix the inputs and expected results, then run every candidate model against the same set.
4. Estimate total cost. Total cost = API charges + rework cost + integration and operations cost. Rework cost can be converted as “rework rate × manual handling time × labor rate.” In high-value scenarios with heavy human involvement, this line item can dwarf the API charges themselves.
Under this framework, you get a vendor-neutral order for trials:
| Workload characteristic | Model type to try first | Rationale |
|---|---|---|
| High-volume image/text processing, structured extraction | Lite / high-speed | High call volume and short outputs make unit price the most sensitive factor; use it to establish a cost baseline |
| Tight budget but longer generation per call | Mid-tier, tuned for output length or price-performance | A larger single-response budget means fewer truncations and less segmentation when outputs are long |
| Requires direct video input | Multimodal, with video understanding | Whether the model reads video directly determines whether you need extra frame-extraction and transcoding pipelines |
| Complex agent orchestration and decisions | All candidates | Success rates across multi-turn tool calls vary widely and must be measured case by case |
| Critical steps with very high answer-quality requirements | Flagship | Serves as a high-quality or fallback channel, and can be layered with lite models |
After validating a model class, put it into the real business flow as a small canary release and observe it for at least a week before deciding whether to roll it out. A high score on the evaluation set does not equal production stability.
3. Reading Specs: Context Window, Output Budget, and Thinking Modes
Spec conventions differ across vendors, so comparing raw numbers from documentation is an easy way to get it wrong. These are the dimensions worth checking closely.
| Dimension | Questions to confirm | Common misreading |
|---|---|---|
| Context window | In what unit is it measured? Is the window shared between input and output? | Treating 1M, 1,000,000, and 1,048,576 as exactly equal |
| Single-response output budget | What is the maximum number of generated tokens? Do thinking tokens count toward it? | Reading the output cap as the length of the final answer |
| Thinking mode | Is it optional? Are thinking tokens billed? | Assuming thinking mode is always more accurate |
| Input modalities | How well are text, images, and video each supported? | Equating “supports images” with “supports video” |
| Billing structure | How are input, output, caching, and batch requests priced? | Comparing a single unit price in isolation |
1. Context window: check the unit and the accounting rule. Common notations on model pages and in API listings include 1,000,000 tokens, 1M, and 1,048,576 tokens. Some services also publish split limits, such as “1M total context, 960k maximum input.” All of these sit in the same order of magnitude, but they are not precisely equal:
- when making calls, treat the token usage returned by the service as authoritative;
- when planning capacity, leave headroom for the system prompt, retrieved snippets, and the output you intend to reserve;
- when you exceed the window, truncate or compress on the application side rather than relying on server-side errors.
2. The output budget is not the length of the final answer. Some models offer a “thinking” mode. Once enabled, the chain of thought itself consumes generation quota. Some services let the chain of thought and the final answer share one cap; others set a separate limit for thinking content. For example, with a 128K output budget, a single complex reasoning task might produce only a 2K-word final answer, with the rest spent inside the reasoning process. Thinking output has to be counted when you evaluate cost.
3. Input and generation share the same window. The longer the context, the less room is left for the current generation. If the total context window is 1M and the input already occupies 900K, then computed against the total window, this turn can generate at most roughly 100K more. Effective input length can be estimated as follows:
effective input length ≈ total context window − expected output length (including thinking) − safety margin
For long-document tasks, use a segmented “retrieve first, then summarize” strategy instead of stuffing everything into one prompt.
4. Model identifiers and version management. An invocation identifier and a version snapshot are not the same thing. The former is the name you call; the latter points to a snapshot of one specific version. Snapshots help reproduce past behavior, while rolling updates deliver continuous improvements but can also make the same test suite produce different results at different times. The recommendation is to pin versions in production and re-run the evaluation set as a regression check before any upgrade.
5. Input modalities. “Supports images” and “supports video” are two different capabilities. The former generally means understanding a single image or a handful of images; the latter involves modeling consecutive frames or temporal order. When your workload needs video understanding, verify first whether a candidate model accepts video input directly, and what duration and frame rate it can handle per call, so you avoid building your own frame-extraction pipeline in the application and adding complexity and error.
4. Cost Modeling: Turn Unit Prices into Per-Task Cost
1. The basic formula. Usage-based billing generally follows this model:
cost per call = (input tokens × input price + output tokens × output price) / 1,000,000
Output tokens here include thinking content. On most services the output price is higher than the input price, which means controlling output length is often more effective than compressing input.
2. Real input length gets amplified. Each time an agent executes a tool-call round, it typically resubmits the system prompt, the tool definitions, and the entire message history. Suppose a task runs 5 rounds on average and each round appends the previous result to the context. Input length per round is then roughly L, L+Δ, L+2Δ, …, L+4Δ, for a cumulative input of about 5L + 10Δ tokens. As rounds increase, cost grows noticeably faster than the round count.
3. Discounts and quotas. Batch processing (offline asynchronous submission, results retrieved later) is usually cheaper than real-time calls. Some services also offer cache discounts for repeated prefixes, and new users typically get free quota. These rules should be taken directly from the provider’s official billing documentation. This article does not reference the price of any specific product.
4. An estimation script. You can use the script below to compare candidate options at a given task volume (the prices are illustrative values used only to demonstrate the calculation):
# Estimate per-task cost at a given volume; replace prices with values# from the provider's official pricing page.# Example numbers are for demonstrating the algorithm only and do not# represent the price of any real product.def estimate_task_cost(input_tokens, output_tokens, thinking_tokens,price_in, price_out, agent_rounds=1, growth=0):"""Estimate the cost of a single task.price_in / price_out: input / output price per million tokensagent_rounds: number of tool-call roundsgrowth: tokens appended to context each round (e.g. previous output + tool result)"""base_in = input_tokens + sum(growth * i for i in range(1, agent_rounds))total_in = base_in * agent_roundstotal_out = (output_tokens + thinking_tokens) * agent_roundsreturn (total_in * price_in + total_out * price_out) / 1_000_000# Example: document summary with 20k input tokens, an 800-token answer,# and 1,200 thinking tokens.# Lite option: 1 per million input tokens, 4 per million output tokenslight = estimate_task_cost(20_000, 800, 1_200, 1, 4)# Flagship option: 10 per million input tokens, 30 per million output tokensflagship = estimate_task_cost(20_000, 800, 1_200, 10, 30)print(f"light: {light:.5f} per call, flagship: {flagship:.5f} per call, ratio {flagship / light:.1f}x")
The same script can simulate multi-round agent scenarios. Calibrate its results against measured token usage from real calls rather than trusting the theoretical values in the documentation.
5. Decide on price-performance, not unit price. “Cost per task” and “first-pass rate” only become meaningful when you look at them together:
effective cost = cost per task / first-pass rate
Suppose candidate A costs 0.02 per call with a 70% first-pass rate, and candidate B costs 0.08 per call with a 95% first-pass rate. Their effective costs are roughly 0.029 and 0.084 respectively. A is still cheaper. But if failed tasks require manual rework and the fully loaded labor cost reaches the order of a hundred per hour, that gap closes quickly. Conversely, if the target is a first-attempt success rate above 99% (for example, in a customer-facing service), A will need a second validation pass or retries, pushing its total cost higher still.
5. Capability Testing: Replace “It Feels Fine” with a Unified Task Set
Specs tell you whether something is possible; only testing tells you whether it works. The evaluation set should cover at least these categories:
- Long-document understanding: feed in a contract or report of several hundred thousand tokens, ask the model to locate specified clauses and cite their source, and check information recall within a long context;
- Image and text extraction: feed in screenshots containing tables, stamps, and handwritten annotations, and require output that conforms to a JSON Schema, testing visual understanding and format compliance;
- Video understanding (if the workload needs it): feed in a video with speech or subtitles and ask about event ordering and timestamps, testing whether consecutive frames are genuinely understood;
- Code generation and repair: provide an interface specification and unit tests, require the model to produce an implementation that passes all tests on the first attempt, testing coding ability and instruction following;
- Tool calling and multi-turn repair: simulate ordering or lookup scenarios, deliberately make the first call return a parameter error, and observe whether the model can read the error and correct its own call.
For each sample, record fields like these to make later analysis easier:
{"task_id": "doc-qa-001","model": "candidate-a","input_tokens": 48213,"output_tokens": 1520,"thinking_tokens": 900,"latency_ms": 4200,"success": false,"error_type": "schema_violation","cost": 0.0123}
Score candidates on four metrics — first-pass rate, rework rate, P95 latency, and effective cost — weighted according to business priorities. A real-time assistant serving end users should weight latency more heavily; a backend batch document-extraction pipeline should weight cost more heavily. The final choice should sit near the inflection point of the quality-cost curve, not at the single best value on any one metric.
6. Agent Workloads: Where Multi-Turn Tool Use Really Gets Hard
The biggest difference between an agent application and conventional question answering is the loop: the model observes a result, calls a tool, and keeps reasoning from that result until the task is complete. Evaluating agent capability therefore cannot rest on single-turn answer quality alone. Focus on:
- Tool selection and parameter correctness: does it pick the right tool, and are the parameters complete and correctly typed?
- Error recovery: when a tool returns an error, can it read the message and adjust the call?
- Context retention: after many turns, does it still remember the original goal and constraints?
- Termination judgment: once the task is done, does it stop promptly and avoid useless loops?
Thinking mode cuts both ways here. For complex tasks that require planning, decomposition, and trial and error, reasoning usually raises the success rate. For simple classification or format conversion, thinking can add token cost and latency with almost no benefit. Configure different thinking strategies per task type, and validate them with A/B tests.
On the engineering side, you can abstract a routing layer that is independent of any specific model:
def route(task):"""Select a model strategy by task type; a real implementationneeds to connect to each provider's API."""if task.type in ("classify", "extract_short"):return {"strategy": "light", "thinking": False}if task.type in ("long_doc_qa", "code_fix"):return {"strategy": "balanced", "thinking": True}if task.type == "video_understanding":return {"strategy": "multimodal"}return {"strategy": "flagship", "thinking": True}
The benefit of a routing layer is that models can be swapped without touching business code. It also makes canary releases, cost-based tiering, and fast fallback during incidents straightforward.
7. Observability and Cost Governance
Model calls are an external dependency, so both stability and cost need ongoing governance:
- Unified logging: for every call, record the model identifier, version, input and output tokens, thinking tokens, latency, and result status, so cost can be attributed per business line;
- Quotas: set daily call-volume and token quotas per team or business line to prevent runaway loops from blowing up the bill;
- Context compression: summarize conversation history and rerank and truncate retrieval results, keeping only the snippets most relevant to the current question;
- Batch and caching: route offline work through the batch API where possible, and enable caching for repeated prefixes when the provider supports it;
- Monitoring and alerting: bring failure rate, P95 latency, and cost per task into monitoring with threshold-based alerts, so you avoid the situation where “the model is fine but the bill is not.”
8. Common Mistakes
- Mistake 1: a longer context is always better. A large window is a necessary condition, not a sufficient one. When information density is too high, the model may “see it without being able to use it,” which makes retrieval and segmentation just as important.
- Mistake 2: thinking mode is always more accurate. Thinking brings gains, but also cost and latency. On simple tasks, turning it off is often both faster and cheaper.
- Mistake 3: comparing unit prices only. Output price, thinking tokens, retries, and rework all get ignored, so the actual bill ends up far above the estimate.
- Mistake 4: picking models by name. A suffix is product positioning; it proves nothing about performance on a specific task.
- Mistake 5: drawing conclusions from one trial. A single sample carries too much noise. Use an evaluation set that covers multiple scenarios.
- Mistake 6: treating specs as a ranking. Specs answer “can it,” testing answers “does it.” Neither substitutes for the other.
9. Summary: An Actionable Selection Checklist
- Define the inputs: profile the real distribution and length of text, images, and video, and confirm whether direct video understanding is required.
- Define acceptance: set targets for first-pass rate, P95 latency, and cost per task.
- Build the evaluation set: sample 30–50 cases from real tasks and fix the inputs and expected outputs.
- Run the baseline: start with a lite model to establish a cost baseline, then add mid-tier and flagship candidates.
- Do the full math: estimate token cost with a single shared script, then convert rework and labor cost into the same unit.
- Roll out gradually: validate at low traffic for at least a week and watch behavior under the real distribution.
- Keep governing: record usage, set quotas, and re-run regressions regularly.
Price differences are worth watching, but they are only the starting point of the decision. What actually determines whether a selection succeeds is whether the model gets it right on the first attempt and whether it can recover quickly when it does not. Treat specs as hypotheses and treat testing as the conclusion, and you can find the balance point between cost, quality, and stability that fits your own workload.
