Skip to content

Pick a model by cost per task

Price per token is easy to compare and easy to get wrong. What you really pay for is a finished task: a correct answer, a working summary, a valid JSON object. A cheap model that needs three tries, or writes twice as much, can cost more than a pricier one that gets it right the first time.

What goes into cost per task

A quick calculator

Get real prices from each vendor's pricing page. The numbers below are placeholders, only there to show the math.

# Plug in your own prices from the vendor's pricing page. These are placeholders.
def cost_per_task(input_tokens, output_tokens, price_in_per_m, price_out_per_m, attempts=1.0):
    per_try = input_tokens / 1e6 * price_in_per_m + output_tokens / 1e6 * price_out_per_m
    return per_try * attempts

if __name__ == "__main__":
    A, B = 1.0, 4.0   # placeholder prices, not real ones
    a = cost_per_task(3000, 500, A, A * 4, attempts=1.6)  # cheaper model, more retries
    b = cost_per_task(3000, 300, B, B * 4, attempts=1.0)
    print(f"model A {a:.5f}  model B {b:.5f}  (units: whatever you entered)")

In this made-up example the cheaper model still wins, even with more retries. Change the attempt count or output length and it can flip. That is the point: measure, do not guess.

How to measure it

  1. Pick 20 to 50 real tasks from your logs.
  2. Define "done" in code where you can: valid JSON, test passes, right answer.
  3. Run each model on the same set, a few times each.
  4. Record input tokens, output tokens, attempts and pass rate from the API responses.
  5. Compute cost per passed task.

Also note latency. A slower model may be fine for batch jobs and wrong for chat.

Mix models

You do not need one model for everything. Common patterns:

Where to look

For plain-language comparisons of models, see ModelRaters . Use it to build a shortlist, then test the shortlist on your own tasks.

Checklist

Related: Cap retries and budget them.

All field notes