Foundation Model API Selection: From Parameter Count to Effective Cost
Competition among foundation models has shifted from parameter count to effective capability. What developers really care about is task completion rate, cost per call, response latency, context handling, and how easily a model integrates with existing systems. This article focuses on model selection and engineering implementation. It does not dive into model internals or cite benchmark scores that cannot be verified. It covers why parameter count is no longer the sole metric, how to evaluate optimization techniques like post-training, distillation, quantization, and caching, how to build an evaluation framework with real samples, engineering controls for agent systems, how to calculate per-task cost, and a practical selection checklist.
Competition among foundation models has shifted from parameter count to effective capability. What developers really care about is task completion rate, cost per call, response latency, context handling, and how easily a model integrates with existing systems. This article focuses on model selection and engineering implementation. It does not dive into model internals or cite benchmark scores that cannot be verified.
1. Why Parameter Count Is No Longer the Sole Metric
The early path to improving large models was straightforward: more data, more parameters, more compute, and results generally followed. But as parameters continue to grow, the marginal gain from each additional parameter shrinks, while training, storage, and inference costs keep rising.
More parameters also do not guarantee reliable task outcomes. A model must accurately understand objectives and constraints, break work down into reasonable steps, and call tools correctly when needed. If any of these links fail, no amount of parameters will prevent failure in code repair, log analysis, or multi-step tasks. For applications, whether a model can reliably apply its capability to concrete tasks matters more than its parameter count.
2. What Each of the Four Optimization Approaches Solves
Different optimization techniques target different problems and should be assessed separately during selection.
- Post-training: Instruction tuning, preference optimization, tool-call training, and task-trajectory training turn a model’s existing knowledge into executable steps. Its effectiveness depends heavily on data quality. If training samples contain flawed workflows, the model learns the flaws. Post-training suits tasks with relatively fixed formats and procedures; it offers limited help when the model lacks the underlying knowledge.
- Distillation: Use a large model’s outputs to train a smaller model, reducing the cost per call. It works well for narrow task scopes with stable input distributions. When inputs fall outside what the small model saw during training, quality can drop noticeably, so dedicated testing is required.
- Quantization and batching: Reduce resource consumption during inference and increase throughput per unit of time. These primarily affect latency and cost. Precision loss may impact results, so they must be measured on the target task rather than judged by generic metrics.
- Caching: Reuse existing results for identical or highly similar requests. Workloads with many repeated questions benefit significantly; tasks where every input differs see almost no benefit.
3. How Post-Training Affects Coding, Security, and Long-Horizon Tasks
Complex coding. A model suitable for development work should extract features, inputs/outputs, and edge cases from requirements, and ask questions proactively when information is incomplete. It should also consider interface design, error handling, and test coverage. A more reliable workflow is: generate code, generate tests, run verification, analyze failures, then iterate. Code involving database writes, permission controls, or payment flows must go through human review—fluent output alone is never a reason to merge directly.
Defensive security. Models can help summarize logs, classify alerts, and explain vulnerability principles. They should refuse to output content that could be directly used for attacks. Security judgment also requires asset information, permission relationships, and business context. Logs contain false positives, false negatives, and missing context, so model conclusions should come with supporting evidence and be verified by security staff before any action is taken.
Long-horizon tasks. Multi-stage tasks require tracking progress, maintaining context, and adjusting plans based on intermediate results. Task state should be persisted by the business system, not entrusted to the model’s memory. The model handles understanding and planning; the system handles recording and execution.
4. Build an Evaluation Table with Real Samples
Public benchmarks cannot replace business samples. The table below provides a minimal evaluation framework. The reference pass thresholds are only starting points and should be adjusted to business risk.
| Evaluation Item | Method | Fields to Record | Reference Pass Threshold |
|---|---|---|---|
| Task success rate | Sample 100–200 real cases per task type; score against predefined rules | Task type, success/failure, failure category | Simple tasks may require 90%+ |
| Call count | Count the average model calls needed to complete one task | Task ID, call count, retry count | Failing the budget limit means failing the test |
| Latency | Record median and P95 response times | Request time, response time, timeout flag | Set by acceptable user wait time |
| Stability | Run the same input 5 times | Key-field consistency rate | Consistency meets business requirements |
| Human review | Spot-check results at a set ratio | Review conclusion, amount of correction | Higher risk means higher sampling ratio |
| Security | Build samples for privilege-escalation requests, prompt injection, and sensitive-data elicitation | Attack type, whether blocked | Zero tolerance for high-risk categories |
After testing, classify every error into one of five categories: knowledge errors, reasoning errors, format errors, tool-call errors, and business-rule errors. The classification tells you whether to improve prompts, add tools, or introduce validation rules.
5. Engineering Controls for Agent Systems
Agents should not hold unlimited execution authority. Permissions, workflows, and resource management belong to the business system; the model only handles understanding, planning, and explaining results. Consider the following controls, with specific values set per scenario:
- State fields: task ID, current step, calls used, elapsed time, items awaiting confirmation.
- Timeout and retry: a single tool call may retry at most 2 times after timing out, then escalate to human handling.
- Budget limits: set maximum call count, maximum execution time, and maximum output length. Exceeding any limit terminates the task and saves its current state.
- Human confirmation: deleting data, making payments, changing permissions, or sending external messages all require human approval.
- Audit logs: record input summaries, tool-call parameters, result summaries, and the operator. Sensitive fields should be masked before storage.
When a model enters repeated call loops or endless self-correction, budget limits stop the task in time and prevent runaway costs.
6. Calculate Cost per Complete Task
The sticker price of a model is only part of the cost. Real cost should be calculated per complete task, using this formula:
Total cost per task = cost per call × average calls + retry cost + extra cost from context and cache misses + human review cost + rework cost
Here is a hypothetical example. Model A costs $0.014 per call (0.10 yuan) and averages 4 calls per task, with a 10% retry rate, giving roughly 0.10 × 4 × 1.1 = 0.44 yuan per task. Model B costs only 0.05 yuan per call but averages 9 calls per task, giving about 0.05 × 9 × 1.1 = 0.495 yuan. The cheaper-per-call model ends up costing more per completed task. These numbers are purely illustrative—real values should come from your own logs.
7. Selection Checklist
Answer each of the following questions when selecting a model:
| Decision Item | Question to Answer |
|---|---|
| Task type | Is the task Q&A, code generation, security analysis, or a multi-step agent? |
| Success criteria | What counts as a correct result, and who judges it? |
| Cost basis | Is cost calculated per complete task rather than per single call? |
| Latency requirement | What P95 latency can users or systems tolerate? |
| Data security | Does the workload involve personal data, internal logs, or credentials? Can the data leave your environment? |
| Integration | Is there a usable SDK? Does it support structured output and tool calling? |
| Failure handling | On failure, does the system retry, degrade, or escalate to humans? |
Leaderboard rankings can help narrow the candidate pool, but they cannot make the decision for you. Final conclusions should come from your own business samples, cost statistics, and security reviews.
Model selection is fundamentally an engineering problem: define the task and success criteria first, then measure quality, cost, and latency, and only then decide the scope of integration.
