LLM Inference Cost: Benchmarking Token Consumption Rates and Tiered Scheduling in Practice

    This article breaks down how to measure real LLM inference costs when per-message pricing feels misleading, especially for AI agents that make multiple round trips per task. It explains how to reverse-engineer input and output token consumption rates through regression fitting, convert credit budgets into processable token capacity across model tiers, and use prompt caching to cut input costs. It then presents a practical four-tier scheduling architecture with rule-based routing, budget guardrails, quality gates, and observability, along with common cost-optimization pitfalls to avoid. All figures are order-of-magnitude estimates from personal testing, not official pricing.

    1. The Problem: Why “Cheap Models” Feel Expensive

    After adopting AI coding assistants and agent-based applications, most teams find that their model quota drains faster than expected. The reason is straightforward: a single conversation looks negligible in cost, but agents follow a “one task, multiple round trips” pattern. They read files, modify code, run tests, and read the results back, resending the context at every step. What actually drives the bill is not how many times you ask, but the accumulated input tokens and the price gap between input and output tokens.

    So the first step in cost governance is not cutting requirements, but replacing vague intuition with a computable model. Once you know each model tier’s consumption rate per million tokens, you can answer questions like “how many more tasks can I run in the next 5 hours?”

    2. Method: Reverse-Engineering Consumption Rates from Real Usage Logs

    When official billing details are unavailable, you can use regression fitting to infer the rates. Treat the input and output token counts of each session as independent variables and the credits deducted for that session as the dependent variable, then run a binary linear regression:

    1. credits consumed = a × input tokens + b × output tokens + c

    Here, a and b are the unit consumption rates for input and output, and c absorbs rounding and statistical error. Three practical points matter:

    1. Cover different workload shapes in your samples: include both short Q&A (low output ratio) and long-form generation (high output ratio). Otherwise a and b become highly collinear and the fit is unstable.
    2. Keep the measurement consistent: decide once whether input tokens include the system prompt, conversation history, and tool return content, and apply it uniformly. Otherwise residuals are systematically inflated.
    3. Validate with residuals: after fitting, check whether residuals are near zero and whether the coefficient of determination approaches 1. When residuals approach zero, credit deduction is essentially linear per token and the model is usable. If residuals show clear structure (for example, higher values with long contexts), tiered pricing or extra factors exist and you need piecewise modeling.

    Using this method across several model tiers, the order-of-magnitude relationships look roughly like this (illustrative magnitudes from personal testing, not an official price list; rules may change at any time):

    Tier Input rate (per million tokens) Output rate (per million tokens)
    Flagship reasoning ~80,000 ~400,000
    Mid-to-high general purpose ~32,000 ~112,000
    Cost-effective execution ~4,000 ~8,000
    Lightweight batch ~2,000 ~2,000

    Two key takeaways are worth remembering: the flagship tier’s output price can be about 200 times that of the lightweight tier; and the execution tier, on a cache hit, may see input costs drop to roughly 2% of the normal input rate.

    3. Budget Conversion: Turning Credits into “Completable Tasks”

    With consumption rates in hand, you can do capacity planning. Assume a quota of 60,000 credits per 5 hours and 600,000 credits per week. Using an empirical split of “80% input, 20% output” and ignoring cache benefits for now, the processable token volume per 5-hour window is approximately:

    • Flagship reasoning: ~417,000 tokens
    • Mid-to-high general purpose: ~1.25 million tokens
    • Cost-effective execution: ~12.5 million tokens
    • Lightweight batch: ~30 million tokens

    The same quota differs by two orders of magnitude across tiers. This is the economic basis for tiered scheduling: spend the most expensive compute only on the “thinking” stage, and push the “doing” stage down to lower-cost tiers.

    4. Caching: The Underrated Cost Lever

    The value of prompt caching lies in the fact that a large portion of agent input is repeated and stable: system prompts, project conventions, directory structures, and file contents that have not changed. On a cache hit, this portion is billed at a very low rate, effectively lowering the effective input price by an order of magnitude.

    To improve hit rates in practice, you need to:

    • Keep the prefix stable: move volatile content (timestamps, random IDs, current-round summaries) to the end of the prompt so it does not pollute the shared prefix.
    • Fix the ordering: do not randomize the order of tool definitions, examples, and specification documents.
    • Batch and merge: consolidate fragmented reads into one larger, reusable context block.
    • Truncate promptly: proactively clear history when switching tasks so old context does not crowd out the cache window.

    5. Tiered Scheduling Architecture

    A practical four-tier structure looks like this:

    1. Task entry
    2. ├─ Planning / decomposition / final review → Flagship reasoning (low frequency, high value)
    3. ├─ Complex reasoning and hard debugging → Mid-to-high general purpose
    4. ├─ Main code execution and rewriting → Cost-effective execution
    5. └─ Batch simple tasks → Lightweight batch (high concurrency)

    Routing decisions should be made by rules rather than by the model itself, to avoid extra overhead:

    1. def route(task):
    2. if task.needs_global_plan or task.is_final_review:
    3. return "tier_reasoning" # Flagship tier
    4. if task.complexity >= 3 or task.cross_module:
    5. return "tier_general" # Mid-to-high tier
    6. if task.batch and task.simple:
    7. return "tier_lite" # Lightweight tier, high concurrency
    8. return "tier_execute" # Execution tier, main workload

    Three supporting constraints apply. First, budget guardrails: set a credit cap per task, and automatically downgrade and retry when exceeded. Second, quality gates: a downgraded result may only be merged if it passes tests or validation scripts; otherwise it falls back to a higher tier. Third, observability: log the tier, input and output tokens, cache hit status, and credits deducted for every call into a logging service, configure monitoring and alerts, and build daily and weekly cost dashboards.

    6. Common Pitfalls

    • Looking at unit price but not structure: for output-heavy tasks, choosing the wrong tier multiplies the cost several times over.
    • Ignoring retry overhead: failed retries often re-bill input tokens, so track the retry rate.
    • Over-downgrading: handing the planning stage to the lightweight tier causes rework that costs far more than the credits saved.
    • Context bloat: without truncation and summary compression, long sessions make input costs grow linearly or even super-linearly.

    7. Conclusion

    The essence of cost optimization is scheduling compute as a finite budget: first use regression fitting to understand each tier’s consumption rate, then use capacity conversion to set task quotas, and finally use caching and tiered routing to push the budget as low as possible. The figures above are order-of-magnitude references from personal testing, not official billing documentation, and the actual rules may change. It is best to rely on continuous fitting of your own call logs. If you use Baidu AI Cloud products, you should likewise build a cost model from your own billing data and then define your tiering strategy accordingly.