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
- Input tokens per attempt, times the input price.
- Output tokens per attempt, times the output price. Some models write much longer answers for the same prompt.
- Attempts per finished task: retries, repair loops, and calls a human has to redo.
- Extra calls: verifier or summary calls you add because a model is less reliable.
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
- Pick 20 to 50 real tasks from your logs.
- Define "done" in code where you can: valid JSON, test passes, right answer.
- Run each model on the same set, a few times each.
- Record input tokens, output tokens, attempts and pass rate from the API responses.
- 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:
- A small, cheap model for simple steps: classifying, routing, extracting fields.
- A stronger model only where quality fails on the cheap one.
- Re-run your comparison when vendors release new models or change prices.
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
- Compare cost per finished task, not per token.
- Count output length and attempts.
- Test on your own tasks with a clear pass check.
- Use small models where they pass.
- Re-check when models or prices change.
Related: Cap retries and budget them.