LLM Selection in Practice: Pricing, Capability, and Agent Scenario Testing

    A practical guide to choosing large language models that goes beyond comparing list prices. It shows how to define capability boundaries from input types and acceptance criteria, budget context and generation tokens correctly, and measure the real cost per successful task using a unified formula. It covers building a reproducible evaluation set, comparing models on Agent workloads such as tool calling and multi-step reasoning, and applying engineering techniques—prefix caching, context trimming, cascade routing, and gradual rollout—to control both cost and quality. Model names, specs, and pricing are left to each team's own business data rather than to marketing labels.

    Introduction: Ask the Right Questions First

    When a team debates model selection, three questions come up most often:

    • “Which model is the strongest?”
    • “Which one is the cheapest?”
    • “Which one has the longest context?”

    None of these can be answered directly.

    Model capability depends heavily on the task. The same model may be more than enough for summarization yet fail frequently on multi-step tool calls. A low sticker price also doesn’t mean a low total spend: if a cheap model has a low first-pass rate, repeated retries can push the total cost above that of a pricier model. Context length only determines “how much can be stuffed in”—it does not determine whether the model can actually use that content well.

    Engineering-oriented questions look more like this:

    1. What type of input does my business deal with, and what acceptance standard must the output meet?
    2. At real call volumes, how much does each successfully completed task cost?
    3. On tool calling and multi-step tasks, which model needs the least rework?

    This article walks through a reusable selection method in the order of define boundaries → unify metrics → test empirically → control cost → govern and launch.

    1. Capability Boundaries: Input and Acceptance Determine “Usability”

    The first step in evaluating capability isn’t running benchmarks—it’s drawing boundaries.

    1.1 Input Types: Define the Candidate Pool First

    Input type determines the range of candidate models and also affects implementation:

    • Plain text: long documents, code, conversation logs—standard capability across the vast majority of models.
    • Images: screenshots, receipts, UI screenshots. Whether a model can directly understand images depends on its documentation; models that don’t support images must first convert them to text via tools such as OCR.
    • Video: a few models can directly understand video, but most process it by extracting frames or lowering resolution. If your business only needs key information from the frames, it’s worth first checking whether keyframe extraction into image input is possible—this is often more economical.
    • Tool feedback: in Agent systems, error messages, logs, and web content returned by tools are also inputs. This content is often long and messy in format, and it quickly drives up context cost (see Section 3).

    1.2 Output Contract: Derive Capability Requirements from the Acceptance Method

    Different output forms call for completely different acceptance methods:

    Output form Typical acceptance method Key capability requirement
    Free text (summarization, Q&A) Human spot checks, judge-model scoring Instruction following, factual consistency
    Structured data (JSON, field tables) Format validation, field completeness checks Structured output stability
    Code patches Unit tests, static checks Code generation and repair ability
    Tool call arguments Argument validation, execution results Call decision and parameter accuracy

    A practical principle: any acceptance standard that can be judged automatically by rules or programs should be designed for automatic judgment. Automated acceptance not only lowers evaluation cost but also makes online quality monitoring and automatic retries possible.

    1.3 Scale and Throughput: The Often-Overlooked Threshold

    Task volume constrains selection in return:

    • High-concurrency online scenarios (e.g., customer service) place high demands on first-token latency, requests per minute (RPM), and token quotas (TPM), and require clear handling policies for rate limiting and timeouts.
    • Offline batch scenarios (e.g., document archiving) are latency-insensitive but sensitive to batch-call discounts and unit cost.
    • Long-document, large-context scenarios carry a high per-task cost and should focus more on cache hit rates and context-trimming strategies.

    2. Context and Generation Budget: Three Easily Confused Concepts

    2.1 Context Is a Shared Total Budget for “Input + Output”

    The context window is the upper limit on the combined length of input and generated content the model can handle in a single request. Both appending to the context and letting the model keep generating consume the remaining space. So a “million-level context” does not mean “feed in a million first, then output a million.” When designing long tasks, always reserve room for generation.

    2.2 The Generation Cap Isn’t the Answer Length

    The single-output cap is the platform’s upper limit, not the length the business actually needs. Setting it too high carries two risks: the model may produce overly verbose content that drives up cost, and if generation goes wrong, it consumes even more quota. It’s best to set the output cap according to the length the business actually needs.

    2.3 Thinking Content Also Consumes the Generation Budget and Cost

    Some models support a “thinking mode” (reasoning mode): they generate a chain of thought first, then the final answer. In these modes:

    • The chain of thought is usually counted as generated tokens and shares the generation budget with the final answer.
    • Vendors generally offer parameters to disable thinking, cap the thinking length, or adjust the thinking effort.

    Simple extraction or classification tasks often don’t need deep reasoning, and enabling thinking just adds latency and cost. Whether to enable thinking should be decided by testing, not enabled by default.

    3. Cost Accounting: Unify Everything to the Same Yardstick First

    3.1 A Four-Part Cost Structure

    Model call costs usually consist of four parts:

    Cost item Billing characteristic Optimization direction
    Regular input tokens Uncached input billed at the input unit price Trim context, compress tool feedback
    Cached input tokens The prefix-cache-hit portion billed at a lower unit price Stabilize prefixes, improve reuse
    Output tokens Billed at the output unit price; some platforms include thinking content Limit output length, enable thinking on demand
    Cache-write tokens Writing to the cache may be billed at a multiple of the input price Reduce frequently changing cache prefixes

    There are also two kinds of hidden costs: first, the cost of failed requests and retries; second, the human cost of manual fallback and review. Cost accounting should include both.

    3.2 The Same Text Can Have Different Token Counts

    Different models use different tokenization, so the same text can differ noticeably in token count. For this reason, you can’t compare only the stated unit price. Instead, use real business text as the sample and measure the cost per thousand typical calls, unifying prices to the same basis before comparing.

    3.3 Agent Cost Accumulates Across Turns

    Running a single task with an Agent often takes multiple calls: each turn re-sends the system prompt, tool definitions, conversation history, and tool-returned results into the context; each turn’s output also includes tool call arguments and sometimes thinking content. This leads to:

    1. Per-turn input cost = (history context tokens + new tokens this turn) × input unit price
    2. Per-task cost = Σ per-turn input cost + Σ per-turn output cost
    3. Context grows linearly => per-task input cost grows roughly quadratically with the number of turns

    This also explains a common phenomenon: for the same “read a file, call a tool” job, a task with few turns may pass in one go, while a task with many turns can cost several times more. The exact multiplier depends on the complexity of the task itself.

    3.4 Sample Code: Single-Task Cost Estimation

    The code below only demonstrates the accounting approach; the model names and prices are placeholders:

    1. from dataclasses import dataclass
    2. @dataclass(frozen=True)
    3. class PriceCard:
    4. """Unit price per million tokens; use the selected platform's official pricing documentation for actual values"""
    5. input: float # input not served from cache
    6. cached_input: float # input served from cache
    7. cache_write: float # input written to cache, often a multiple of the input price
    8. output: float # output (if thinking is enabled, usually includes thinking content)
    9. def call_cost(p: PriceCard, hit: int, miss: int, written: int, out: int) -> float:
    10. return (hit * p.cached_input + miss * p.input
    11. + written * p.cache_write + out * p.output) / 1_000_000
    12. def agent_task_cost(p: PriceCard, turns, fixed=800, cache_window=4096):
    13. """fixed: token count of the system prompt and tool definitions; cache_window: max prefix length that can hit the cache"""
    14. total, history = 0.0, 0
    15. for out_tokens, tool_result_tokens in turns:
    16. prompt = fixed + history
    17. hit = min(history, cache_window) # only history within the cache window can hit
    18. total += call_cost(p, hit, prompt - hit, 0, out_tokens)
    19. history += prompt + out_tokens + tool_result_tokens
    20. return total
    21. prices = {
    22. "model-a": PriceCard(input=1.0, cached_input=0.2, cache_write=2.0, output=4.0),
    23. "model-b": PriceCard(input=4.0, cached_input=0.8, cache_write=8.0, output=16.0),
    24. }
    25. # Example: 1200 tokens of output per step, 500 tokens of tool return, 12 steps per task
    26. for name, card in prices.items():
    27. turns = [(1200, 500)] * 12
    28. print(name, round(agent_task_cost(card, turns), 4), "per task")

    3.5 Unit Notation Isn’t Precision

    Notation like “1M”, “1,048,576”, and “960k” may each be based on decimal or binary conversion. In cost accounting, convert everything to the same unit and keep the original values, so you don’t treat numbers on different bases as exactly equal.

    4. Agent Scenarios: Compare Horizontally with the Same Task Set

    4.1 Suffixes Like “Max”, “Flash”, “Pro” Say Nothing About Agent Ability

    Suffixes like Max, Flash, Pro, and Lite in model names usually hint at positioning differences—for example, favoring a capability ceiling, speed, professional scenarios, or lightweight low cost. But each vendor defines its own naming rules: context length, parameter scale, and supported tool-calling capability can’t be inferred from the name alone. Whether a model can handle Agent tasks can only be determined by testing.

    4.2 Four Key Points to Examine

    • Call decisions: Given multiple tools, can it pick the right one rather than calling the same tool every time.
    • Parameter accuracy: Are tool argument types, formats, and required fields complete and correct—for example, date formats, numeric units, enum values.
    • Multi-step progress: When a task needs “query → judge → query again,” can it adjust the next step based on the previous result rather than mechanically repeating.
    • Failure recovery: When a tool errors, can it correct the arguments based on the error message; repeatedly calling with the same wrong arguments is a classic “invalid step.”

    4.3 Agent Evaluation Metrics

    Metric Definition What it reflects
    Task completion rate Share of tasks passing all acceptance assertions Overall reliability
    First-pass rate Share of tasks completed without human or model correction Rework cost
    Average number of calls Average number of model calls to complete one task Reasoning and loop cost
    Average number of steps Average number of tool-call rounds to complete the task Planning efficiency
    Invalid-step ratio Share of erroring, repeated, or irrelevant calls Error recovery ability
    Recovery success rate Share of errors eventually fixed after correction Robustness
    Average latency Time from request to final answer Interaction experience and timeout risk

    Among these, first-pass rate and average number of calls relate directly to cost, and are recommended as the core metrics for selection.

    5. From Unit Price to Unit-Task Cost: Can the Cheap One Pass First Try, and Can the Expensive One Cut Rework?

    5.1 The Effective Cost Formula

    Let a model’s cost per call be C, with an average of n calls per task, a task pass rate of p, and a manual fallback cost F for failed tasks. Then:

    1. Effective cost per task = (C × n) / p + (1 − p) × F

    The first term is the model cost of “getting the task done”; the second is the extra price of failures. The unit price only appears in C, while n, p, and F determine the actual spend.

    5.2 A Sample Calculation

    Suppose a task behaves as follows on two model types:

    Metric Model A Model B
    Cost per call C 0.01 0.04
    First-pass rate p 60% 90%
    Average number of calls n 1.4 (including failed retries) 1.1
    Manual fallback F for failed tasks 2 0 (fully automated)
    • Model A: (0.01 × 1.4) / 0.6 + 0.4 × 2 ≈ 0.82 per task
    • Model B: (0.04 × 1.1) / 0.9 ≈ 0.05 per task

    Model A’s per-call cost is only a quarter of Model B’s, yet its unit-task cost is more than ten times higher—the root cause being that many failed tasks need manual fallback. If the task pass rates were 60% and 90% but the fallback cost were 0 for both, Model A’s effective cost would be about 0.023 and Model B’s about 0.049, and the conclusion would flip.

    So the essence of selection is answering two questions:

    • Can the cheap model pass first try? Does the task pass rate meet the business floor, for example no lower than 95%.
    • Can the expensive model cut rework? Does it reduce retries, manual review, and timeout reruns.

    The only valid basis for judgment is measured results on your business task set, not the sticker unit price.

    6. Building a Business Evaluation Set: Give Selection Something to Stand On

    6.1 Task Sources: Real Logs + Constructed Samples

    • Real logs: From anonymized online samples, do stratified sampling by business distribution to cover both high-frequency and long-tail scenarios.
    • Constructed samples: Deliberately add edge cases—overly long documents, vague instructions, unauthorized requests that should be refused, tools that return abnormal results. These samples effectively widen the gap between models.

    6.2 Scoring Methods: Automatic First, Human as Supplement

    1. Assertion checks: For structured output, validate format and fields; for code tasks, run unit tests; for tool calls, verify execution results.
    2. Judge model: Suitable for open-ended answers—use another model to score along preset dimensions, and calibrate with human spot checks to avoid “judge bias.”
    3. Human spot checks: Keep human review for critical scenarios, and use it as a reference for the accuracy of automated evaluation.

    6.3 Reproducibility: Control Evaluation Variables

    • Fix the system prompt, tool definitions, and call parameters (such as temperature), and lock the model version.
    • Run the same task set on all candidate models with the same number of turns.
    • Record task completion rate, token usage, and latency together in each evaluation, so quality and cost appear in the same report.

    6.4 Sample Code: Evaluation and Retry Statistics

    1. import json
    2. def validate(task, raw: str) -> dict:
    3. """Assertion-based acceptance for structured output: format -> fields -> business rules"""
    4. try:
    5. result = json.loads(raw)
    6. except json.JSONDecodeError:
    7. return {"ok": False, "reason": "output is not valid JSON"}
    8. missing = [k for k in task["required_fields"] if k not in result]
    9. if missing:
    10. return {"ok": False, "reason": f"missing fields: {missing}"}
    11. if not task["rule_check"](result):
    12. return {"ok": False, "reason": "business rule check failed"}
    13. return {"ok": True, "reason": ""}
    14. def evaluate(task_set, model, max_retry=1):
    15. """model(prompt) returns raw output; returns each model's pass rate, first-pass rate, and average number of calls"""
    16. rows = []
    17. for task in task_set:
    18. raw, calls = model(task["prompt"]), 1
    19. verdict = validate(task, raw)
    20. while not verdict["ok"] and calls - 1 < max_retry:
    21. # feed the previous error reason back to guide the model to fix it
    22. repair = task["repair_prompt"](verdict["reason"], raw)
    23. raw, calls = model(repair), calls + 1
    24. verdict = validate(task, raw)
    25. rows.append({"task_id": task["id"], "ok": verdict["ok"], "calls": calls})
    26. total = len(rows)
    27. return {
    28. "pass_rate": sum(r["ok"] for r in rows) / total,
    29. "first_try_rate": sum(r["ok"] and r["calls"] == 1 for r in rows) / total,
    30. "avg_calls": sum(r["calls"] for r in rows) / total,
    31. }

    7. Cost and Quality Engineering: Turn Selection Conclusions into Architecture

    Picking a model is just the start. The following techniques affect both unit-task cost and pass rate:

    1. Prefix caching: Put fixed content (system prompt, tool descriptions, few-shot examples, knowledge-base templates) at the very front of the prompt, and ensure the prefix is byte-for-byte identical. Caches usually have a minimum length and a time-to-live, so don’t put frequently changing content in the prefix.
    2. Context budget: Set a context limit per task, including truncating tool return values, summarizing conversation history, and compressing parallel-retrieved content into the context.
    3. Structured output and validation repair: Use structured-output capability to constrain the format; when validation fails, feed the specific error reason back to the model for a limited number of repair attempts.
    4. Small-context divide and conquer: Break a large task into several subtasks, each carrying only the necessary context, then aggregate the results. Subtask intermediate steps needn’t enter the main context.
    5. Model cascade (small first, then large): Handle tasks with a low-cost model first, and escalate to a high-capability model when confidence is low or validation fails:
    1. def run_with_escalation(task, cheap, strong, validate, retries=1):
    2. """Sample models are also placeholders, representing low-cost and high-capability models"""
    3. raw = cheap(task["prompt"])
    4. for _ in range(retries):
    5. verdict = validate(task, raw)
    6. if verdict["ok"]:
    7. return raw
    8. # feed the error reason back to the low-cost model to fix it
    9. raw = cheap(task["repair_prompt"](verdict["reason"], raw))
    10. if validate(task, raw)["ok"]:
    11. return raw
    12. # after earlier calls fail, escalate to the high-capability model
    13. return strong(task["prompt"])
    1. Batching and concurrency control: For offline tasks, use interfaces that support batch calls, which usually come with discounts; for online tasks, design queuing, rate-limiting, and degradation strategies according to quotas.
    2. Observability: Record token usage, cost, latency, and pass rate by dimensions such as task type, model version, and input length; review periodically to catch cost or quality drift.

    8. Hybrid Architecture and Version Governance

    8.1 When Multi-Model Routing Fits

    When a business runs both “simple, high-frequency” and “complex, low-frequency” tasks, multi-model routing is worth considering:

    • Estimate difficulty from input features (length, whether it contains images, number of tools to call).
    • Decide on escalation based on validation confidence.
    • Route by scenario—for example, format conversion to a lightweight model, complex reasoning to a high-capability model.

    Routing itself has a cost, so it’s recommended to first use the evaluation in Section 4 to confirm: whether a single model already meets the quality floor at an acceptable cost.

    8.2 Launch and Governance Checklist

    • Gradual rollout: Let a new model take a small share of traffic first, or run shadow traffic in parallel with the existing model to compare; ramp up gradually after confirming quality and cost.
    • Version locking and regression: Model upgrades can change behavior, so rerun the evaluation set on every upgrade; keep a rollback plan.
    • Quotas and rate limiting: Configure dedicated quotas for core business to avoid evaluation tasks crowding out online capacity.
    • Data compliance: Pay attention to input data usage policies, retention requirements, and regional compliance; desensitize sensitive data before calling.
    • Vendor strategy: Map out backup models and switching plans to reduce the risk from a single vendor’s changes. For teams that need a unified way to connect to and orchestrate multiple models, a platform service offering multi-model access can help, such as Baidu AI Cloud’s model service platform; refer to the official documentation for specific capabilities, pricing, and limitations.

    9. The Selection Decision Process

    The whole process can be summarized in seven steps:

    1. Define boundaries: Clarify input types, output forms, acceptance standards, and throughput requirements.
    2. Build the task set: Form an evaluation set from real logs and constructed samples.
    3. Run a baseline: Have candidate models complete a first round of evaluation, recording pass rates and token usage.
    4. Calculate cost: Compute the effective cost per task on a unified basis.
    5. Adjust architecture: Optimize cost and quality through caching, context trimming, cascade routing, and other techniques.
    6. Do a gradual rollout: Validate with a small traffic share, then ramp up.
    7. Close the loop: Continuously monitor metrics, and rerun the evaluation after model upgrades or business changes.

    If a team needs a quick start, begin with high-frequency text and structured tasks whose output can be validated automatically, and build a task set of a few hundred entries. On that foundation, extend to tool calls and multi-step tasks to gradually cover more complex scenarios.

    Conclusion

    Model selection isn’t about picking an “all-round champion”—it’s about finding the best combination of quality and cost under business constraints. There are three key actions:

    • First use input types and acceptance standards to define capability boundaries.
    • Then unify the billing basis, replacing the sticker unit price with “effective cost per task.”
    • Finally, use the same task set to empirically test tool calls and multi-step tasks, and lean on caching, cascades, and gradual rollout to control risk.

    The same process applies to any candidate model. Specs and naming offer only reference; the conclusions should come from your own business data.