How to Evaluate AI Programming Models: A Framework for Speed, Quota, and Cost

    This article provides a practical evaluation framework for selecting an AI programming model, moving beyond benchmark rankings and single-session impressions. It defines three core dimensions—throughput speed, quota structure, and billing rules—and offers a reproducible Python script for measuring tokens-per-second across different time windows. It also explains how to convert heterogeneous quota systems into comparable per-million-token costs, how to detect throttling and overselling, and how to build a weighted decision matrix tailored to your development workflow. The goal is to help engineering teams make data-driven, repeatable model choices.

    Why Benchmarks and Single-Session Tests Are Not Enough

    Model evaluation leaderboards typically use standardized questions and measure the upper bound of general capability. But a developer’s real work is constrained by three factors: whether response speed is stable, whether the quota can support continuous coding sessions, and whether the cost per unit of effective output is acceptable. These three factors do not have a simple linear relationship, and looking at any one of them in isolation can lead to incorrect conclusions.

    The problem with a single-session test is that the sample size is too small. An afternoon coding session may happen to fall during a period of low service load, or it may just as easily hit peak-hour congestion. A model that performs well in the morning does not necessarily maintain the same level at midnight or during the evening rush. Therefore, evaluation needs to cover different times of day and different task types, and keep quantifiable data.

    Three Core Dimensions Defined

    1. Throughput Speed (Tokens Per Second)

    Throughput speed refers to the number of output tokens a model generates per second. It directly affects the waiting time for long code generation and multi-round edits. Two metrics need to be distinguished:

    • Time to First Token (TTFT): The time from when the request is sent to when the first output token is received. This reflects queuing and prefill overhead.
    • Decoding speed: The average generation rate after the first token, reflecting the model’s sustained output capability on the server side.

    A non-streaming request’s measured time includes the TTFT, which lowers the observed speed. To measure decoding speed, use streaming output and start timing from the first data chunk.

    2. Quota Models

    Quotas are typically expressed in three ways: per-token billing, a monetary-equivalent quota, or a number of calls restricted by a time window. Developers need to convert these into comparable units.

    Common window structures include short periods (e.g., 5 hours), weekly periods, and monthly periods. Short-period limits determine the experience during high-intensity sessions, while weekly or monthly quotas define the total ceiling. When both exist, the actual available amount is determined by whichever limit is hit first.

    In addition, some services separately count agent features, tool calls, or multi-turn context in the web interface. When evaluating, test pure API calls and in-product features separately to see the difference in consumption.

    3. Billing Rule Details

    Billing rules determine the real cost. Details to watch for include:

    • Whether cache-hit tokens are billed at a lower rate or for free;
    • The price ratio between input and output tokens;
    • Whether thinking/reasoning tokens are counted as output tokens in reasoning models;
    • Whether quota is deducted at a multiplier during peak hours.

    If the service provider does not publicly disclose these rules, developers should verify them with small test calls and keep records that map requests to usage.

    Building a Reproducible Speed Test Script

    The example below uses the standard library to make requests and records output tokens, elapsed time, and throughput. The service URL, API key, and model identifier are injected via environment variables to avoid hard-coding.

    1. import os
    2. import json
    3. import time
    4. import urllib.request
    5. BASE_URL = os.environ["LLM_BASE_URL"]
    6. API_KEY = os.environ["LLM_API_KEY"]
    7. MODEL = os.environ["LLM_MODEL"]
    8. def run_once(prompt: str, max_tokens: int = 1024) -> dict:
    9. payload = {
    10. "model": MODEL,
    11. "messages": [{"role": "user", "content": prompt}],
    12. "max_tokens": max_tokens,
    13. "stream": False,
    14. }
    15. req = urllib.request.Request(
    16. BASE_URL.rstrip("/") + "/chat/completions",
    17. data=json.dumps(payload).encode("utf-8"),
    18. headers={
    19. "Authorization": f"Bearer {API_KEY}",
    20. "Content-Type": "application/json",
    21. },
    22. method="POST",
    23. )
    24. start = time.perf_counter()
    25. with urllib.request.urlopen(req, timeout=300) as resp:
    26. body = json.loads(resp.read().decode("utf-8"))
    27. elapsed = time.perf_counter() - start
    28. usage = body.get("usage", {})
    29. out_tokens = usage.get("completion_tokens", 0)
    30. return {
    31. "elapsed_s": round(elapsed, 3),
    32. "output_tokens": out_tokens,
    33. "tps": round(out_tokens / elapsed, 2) if elapsed > 0 else 0.0,
    34. "prompt_tokens": usage.get("prompt_tokens", 0),
    35. "cached_tokens": usage.get("prompt_tokens_details", {}).get("cached_tokens", 0),
    36. }
    37. if __name__ == "__main__":
    38. sample = "Write a Python in-memory cache class with expiration, and provide unit tests."
    39. print(json.dumps(run_once(sample), ensure_ascii=False, indent=2))

    Usage notes:

    • Use a fixed set of test prompts so that all models handle the same tasks;
    • Run at least one group of tests during early morning, late morning, midday, and evening peak each day, with at least 10 repetitions per group;
    • Record elapsed_s, tps, and failure status for each call; compute the P50 and P90 values, not just the average;
    • If the service does not return a usage field, fall back to a self-implemented token estimation method and clearly note that estimation in the report.

    Converting Quotas into Comparable Cost

    Different services use different quota units, so comparing raw numbers is meaningless. The recommended approach is to first unify everything into “equivalent cost per million tokens,” then weight by your own workload.

    The formula for a single task cost is:

    1. Single task cost = regular input tokens × input unit price
    2. + cache-hit tokens × cache unit price
    3. + output tokens × output unit price

    Using a one-week real usage sample, calculate the ratios of input, cache-hit, and output tokens, then plug in each provider’s published or measured unit price. If the quota is a monthly flat fee, divide the monthly fee by the number of effective tasks completed in that period to get the per-task cost.

    Keep in mind that the “effective quota” of a monthly plan is affected by time windows. Suppose a monthly plan has a large total quota but a small 5-hour window limit. In that case, its actual usability during high-intensity coding periods will be lower than the total amount suggests. When calculating, include the window limit and estimate the number of tokens available per hour during the most intensive working hours.

    Identifying Throttling and Overselling

    Overselling and dynamic rate limiting are usually not stated explicitly on the service page, but they can be detected through data:

    • The TPS distribution for the same model becomes noticeably wider at different times of day, with many timeouts during peak hours;
    • Speed gradually drops after successive requests, then recovers after a fresh request, indicating per-user or per-time-window dynamic limits;
    • Different tiers of the same plan show significant speed differences at the same time, suggesting tiered resource allocation.

    When you observe these phenomena, record the time, sample size, and results honestly in your report. Avoid drawing conclusions from isolated cases.

    Building a Decision Matrix

    Combine all the data above and compare options with a weighted scoring table. The example dimensions and weights below can be adjusted to your context:

    Dimension Weight Evaluation Method
    Decoding speed (P50, P90) 20% Multi-session streaming speed tests
    Stability (failure rate, timeout rate) 15% One week of continuous recording
    Code quality 25% Human scoring on a fixed task set
    Cost per task 20% Usage statistics and unit price conversion
    Quota transparency 10% Clarity of usage records and rule disclosure
    Integration and tool compatibility 10% Actual difficulty of integrating into existing workflows

    Code quality carries the highest weight because even if speed is high and price is low, code that requires extensive rework will lower overall efficiency. Use real historical requirements as the task set—such as completing functions, fixing defects, writing unit tests, and refactoring modules—and have developers familiar with the project score each item individually.

    Conclusion and Implementation Recommendations

    Choosing a programming model is an ongoing engineering decision, not a one-time purchase. The recommended steps are:

    1. Clarify your team’s typical task types and daily working hours;
    2. Collect at least one week of speed and failure-rate data using the script above;
    3. Calculate the real token consumption structure and per-task cost;
    4. Score candidates with the decision matrix, and keep two to three backup options;
    5. Re-run the evaluation quarterly, because service load, pricing, and quota limits can change.

    Making decisions based only on marketing claims or personal impressions often leads to reactive adjustments when quota or speed problems appear. By making the evaluation process data-driven, you can find the right balance among cost, efficiency, and quality for your team.