How to Evaluate the True Cost of Large Language Models with Token Efficiency

    List price alone does not show what a large language model call actually costs. This article explains how to measure token efficiency, combine usage with input and output prices, and compare models by cost per accepted task, latency, and completion quality using a small, repeatable benchmark.

    1. Unit price is not the same as cost

    Large language model services are usually billed by token. A token is the smallest unit the model uses to process text. Input and output are priced separately, and the two rates are often different. To judge the cost of one call, you need both the unit price and the amount used.

    The basic relationship is:

    Total cost = unit price × usage

    Looking only at the listed price leads to incomplete conclusions. Suppose one model’s unit price is four times another’s, but it uses about half as many tokens to finish the same task. The total cost of the two runs then differs by only about two times. What determines real cost is token efficiency per task. The listed price is only one factor.

    2. What token efficiency means

    Token efficiency is the total number of tokens used to complete a clearly defined task. It usually has three parts:

    1. Input tokens: the prompt, context, conversation history, examples, and similar content.
    2. Reasoning tokens: some models produce intermediate reasoning before the final answer. Whether this usage is billed, and at what rate, depends on the provider’s pricing rules. Record it separately during tests.
    3. Output tokens: the content finally returned to the user.

    Three metrics are useful for evaluation:

    • Tokens per task: the sum of input, reasoning, and output tokens for one task.
    • Cost per task: the amount after applying the different prices for input and output.
    • Cost per accepted output: total spend divided by the number of tasks that pass acceptance. This is closest to a business view, because failed calls are included in the cost.

    The following function estimates the cost of a single task by pricing input and output separately:

    1. def estimate_task_cost(input_tokens, output_tokens,
    2. input_price_per_k, output_price_per_k):
    3. """
    4. Estimate the cost of a single task.
    5. Prices are per 1,000 tokens.
    6. If reasoning usage is priced separately, include it in output usage
    7. or add a dedicated parameter.
    8. """
    9. input_cost = input_tokens / 1000 * input_price_per_k
    10. output_cost = output_tokens / 1000 * output_price_per_k
    11. return input_cost + output_cost

    3. Look at speed and completion together

    End-to-end time includes queue wait, generation time, and retry time after failures. A short duration does not by itself mean better results. If a model stops early and leaves the task unfinished, the run is naturally shorter. Every latency record should therefore be paired with a completion record.

    Completion can be measured in several ways:

    • Feature coverage: the share of required features that were actually completed.
    • Acceptance-test pass rate: the share of predefined automated checks that passed.
    • Human scoring: scores on a shared scale, for example 1 to 5, with the criteria for each level written down.

    Latency and cost comparisons are meaningful only when completion reaches an acceptable level.

    4. Design a small, reproducible test

    The goal of a small test is comparable data, not an absolute verdict. A practical sequence is:

    1. Choose a task set that covers typical production scenarios, with a representative spread of difficulty.
    2. Fix the prompt and parameters. Use the same prompt, maximum output length, and sampling settings for every model.
    3. Record data in a consistent way. Read input and output token counts from the usage fields returned by the API, and record elapsed time.
    4. Define the scoring rules. Prefer automated checks. Where automation is not possible, have several people score independently.
    5. Run multiple times and use the mean. Model output is stochastic, so a single run is not enough.
    6. Compute cost per accepted output for the final comparison.

    A simplified test harness looks like this:

    1. import time
    2. def run_benchmark(models, tasks, check):
    3. """
    4. Run the same task set on multiple models and record usage,
    5. latency, and pass or fail.
    6. models: a list of model clients with a shared calling interface
    7. tasks: a list of tasks, each with an id and a prompt
    8. check: a function that returns True when the result passes
    9. """
    10. records = []
    11. for model in models:
    12. for task in tasks:
    13. start = time.perf_counter()
    14. resp = model.generate(task.prompt)
    15. elapsed = time.perf_counter() - start
    16. records.append({
    17. "model": model.name,
    18. "task": task.id,
    19. "input_tokens": resp.usage.input_tokens,
    20. "output_tokens": resp.usage.output_tokens,
    21. "seconds": round(elapsed, 2),
    22. "passed": check(task, resp.text),
    23. })
    24. return records

    Common sources of bias should be avoided in advance:

    • Too few tasks: results from a handful of tasks can be driven by chance. Increase the sample.
    • Output randomness: the same input can produce different outputs. Run each case more than once.
    • Cache effects: repeated requests may hit a cache and change both latency and billing. Separate first calls from repeat calls.
    • Environment drift: load varies by time of day, and model versions may change. Record the date and version with the test results.
    • Inconsistent prompts: different prompts for different models make the comparison misleading.

    5. How to read the results

    After the test, calculate cost per accepted output for each option, then judge it together with completion and latency.

    The calculation below uses illustrative numbers only:

    • Option A: total spend of 1, 8 tasks passed, cost per accepted output of 0.125.
    • Option B: total spend of 1, 10 tasks passed, cost per accepted output of 0.1.

    In this example, Option B spends the same amount but completes more tasks, so its unit cost is lower.

    Two rules help when interpreting results:

    • When spend is similar, compare completion first.
    • When completion is similar, compare spend and latency. If one option is faster, check whether it finished early without completing the task.

    6. Putting the results into practice

    Test findings can become a longer-term cost policy:

    • Route by task tier. Send simple tasks to a lower-cost model and harder tasks to a more capable one. Base the rules on task type and historical pass rate.
    • Limit output length. Specify the output format and cap the maximum length so unrelated content is reduced.
    • Shorten prompts. Remove repeated instructions, reuse a fixed system-instruction prefix, and periodically check whether the context has grown too long.
    • Add monitoring. Log token usage, latency, and status for every call, and alert when daily spend or the failure rate crosses a threshold.
    • Retest on a schedule. Model versions and pricing rules change. Rerun the benchmark on a fixed cadence and update the routing policy.

    7. Summary

    When evaluating large language model cost, unit price is only the starting point. The more useful metric is cost per accepted output, which reflects usage, latency, and completion together. With a shared task set, fixed parameters, and reproducible records, a team can reach a reliable comparison at modest test cost and use it to guide model selection and ongoing cost management.