Evaluating LLM Cost-Effectiveness: From Per-Token Pricing to Total Cost of Ownership
When API prices rise, switching to a cheaper model does not always lower the bill. Using a small interactive market-simulation game as a sample task, this article breaks total cost of ownership (TCO) into input/output tokens, retries, harness overhead, and cache discounts. It compares single-shot generation with round-based iteration, proposes a five-dimension scorecard, and lists practical ways to cut costs without sacrificing quality.
1. Redefining Cost-Effectiveness After a Price Increase
When API prices rise significantly, many teams immediately look for a cheaper model. Yet real bills often contradict intuition: for the same task, a model with a lower per-token price can end up costing more overall, while a higher-priced model can cost less because it gets the code right on the first attempt and requires fewer retries. Cost-effectiveness therefore cannot be judged by the “price per million tokens” alone. It should be measured by the total cost of ownership (TCO) of completing one acceptance-ready task.
This article uses a small development task as a sample: build an interactive market-manipulation simulation game in which players can influence a group of bots that follow specific trading styles as well as purely random noise traders. The game must support per-round goals, such as pushing the closing price above a certain level, accumulating a set quantity below the average price line, or distributing a large block of holdings without breaking the price. The task has three defining traits: a short requirements description, many implicit constraints, and a deliverable that must actually run. That makes it a useful combined test of model capability and economics.
2. Cost Model: Breaking the Bill into Explainable Terms
The total cost of one task can be abstracted as:
TCO = (input tokens + output tokens) × unit price+ extra tokens from retries and rework+ orchestration overhead from tool calls / harness- discounts from cache hits
The engineering meaning of each term is as follows:
- Input and output structure: Code generation tasks are output-heavy, and generating a long file in one shot significantly raises output cost. In contrast, splitting a large task into small steps and rewriting only the diff is usually cheaper.
- Cache hit rate: If stable prefixes such as system prompts, project conventions, and dependency lists can be reused from cache, the marginal cost of long sessions drops noticeably. Placing volatile content later is the key to improving the hit rate.
- Reasoning depth: A higher reasoning tier can reduce logic gaps but amplifies token consumption. It suits architecture decisions and difficult debugging, not bulk boilerplate code.
- Harness overhead: AI coding tools make extra calls for retrieval, rewriting, validation, and running tests. This part is often overlooked, yet it can account for a considerable share of total cost.
- Rework cost: The gap between getting it right on the first attempt and patching it over multiple rounds is often larger than the difference in unit price.
3. Decomposing the Sample Task: Single-Round Goals and Multi-Round Iteration
Two important lessons from the original practice are worth abstracting.
First, single-round one-shot generation. Give only a short requirement and ask the model to produce a runnable game in one pass. This approach genuinely exposes a model’s ability to fill in implicit requirements: whether it proactively adds market matching, slippage, volume constraints, parameterized bots, and random noise traders, and whether it turns the sandbox into a game with clear win and loss conditions.
Second, iteration by round-based goals. Break the objective into verifiable subtasks, for example “push the closing price above the execution price,” “accumulate 5,000 units in total below the average price line,” or “distribute an entire block of holdings without breaking the price.” Each subgoal maps to a clear acceptance function, making success or failure easy to determine automatically.
From a cost perspective, the single-round mode tests the “first-attempt success rate,” while the multi-round mode tests “controllable convergence.” The former saves calls but concentrates risk; the latter uses more calls, but each one is verifiable and rollback-friendly. The engineering recommendation is: get the architecture and interfaces right in one pass, and accept details round by round.
A sketch of the acceptance skeleton:
def check_round(state, target):if target.kind == "mark_up":return state.close > target.strikeif target.kind == "accumulate":return state.bought_under_vwap >= 5000if target.kind == "distribute":return state.block_sold and state.low >= target.floorreturn False
4. Evaluation Dimensions: A Reusable Scorecard
Replace the “unit price comparison” with five dimensions:
- First-attempt success rate: The proportion that runs without manual fixes.
- Constraint compliance: Whether implicit constraints on performance, compatibility, security, and compliance are met.
- Maintainability: Whether module boundaries, naming, logging, and tests are clear.
- Cost predictability: Whether token consumption and cache hits are stable and the bill stays controllable.
- Delivery completeness: Whether run instructions, parameter configuration, and acceptance cases are included.
When scoring, give higher weight to “runnable” and “constraint compliance,” because code that does not run shifts cost onto manual investigation no matter how low its unit price is.
5. Cost-Reduction Practices: Shrinking the Bill Without Sacrificing Quality
- Task tiering: Use a high reasoning tier for architecture, interfaces, and state machines; use a lower tier for boilerplate code, copy, and comments.
- Cache-friendly design: Put stable conventions at the front of the prompt and the volatile task description at the end to reduce cache invalidation.
- Small-step commits: Change only one verifiable unit at a time to avoid repeatedly replaying a long context.
- Budget guardrails: Set token and spend limits for each task, with automatic downgrade or pause when limits are exceeded.
- Automated acceptance: Use unit tests and scenario scripts to determine results and reduce manual trial and error.
- Observability: Record call volume, cache hit rate, and the distribution of failure reasons, and let data drive model selection.
- Security first: For simulation logic involving trading, funds, or external interfaces, add risk controls and limit constraints by default to avoid “runnable but dangerous.”
6. Conclusion
A price increase does not necessarily mean “more expensive,” nor does it mean a forced downgrade. What really determines the bill is how the task is organized: whether it can be right on the first attempt, whether cache can be reused, and whether a large goal can be split into verifiable small goals. Shifting the evaluation focus from unit price to total cost of ownership, and replacing subjective impressions with a scorecard and automated acceptance, allows developers to steadily select an economical and reliable model combination even under a tighter budget.
