Back to blog

AI for beginnersGuide

Price per 1M tokens vs cost per task: how to compare AI models

A model with a lower price per 1M tokens can still cost more per finished task. Learn to work out cost per task from tokens in, tokens out and attempts.

By CheapTokens TeamPublished 6 min read

Cover: price per token versus cost per task, a flow from tokens in and tokens out to cost per task
On this page
  1. A price per token is a price per kilo
  2. Where the tokens per task actually go
  3. A chatbot is the opposite story
  4. Measure your own task in ten minutes
  5. Quick check

Compare models by what a finished task costs, not by the price per 1M tokens. A task costs tokens in × input price + tokens out × output price, multiplied by however many attempts it takes. So a model at half the price per token can still hand you the bigger bill.

That is the usual surprise: the agent finished, the price list looked cheap, and the invoice is bigger than the task deserved. Let's find out where the difference hides.

A price per token is a price per kilo#

A price per kilo of flour tells you nothing about the cost of dinner. You need to know how many kilos the recipe takes, and whether you burn the first batch and start again.

AI models work the same way. The price per 1M tokens is the price per kilo. The task is the dinner. Every request is billed on two sides: the tokens you send (input) and the tokens the model writes back (output). Both numbers come back in the usage field of every response from an OpenAI-compatible API such as the CheapTokens API at https://api.cheaptokens.dev/v1 (checked 29 October 2026), so you never have to guess them.

Here is the whole formula:

text
cost per task = attempts × (tokens in × input price + tokens out × output price)

Say a task sends 3,000 tokens and gets 1,000 back. Model A costs $1 per 1M tokens for input and $5 for output. Model B is half that: $0.50 and $2.50. (These are made-up round prices for the sum, not anyone's price list.)

Model A, one attempt:

  • 3,000 × $1 ÷ 1,000,000 = $0.003 for input
  • 1,000 × $5 ÷ 1,000,000 = $0.005 for output
  • $0.003 + $0.005 = $0.008 per task

Model B looks like the bargain. But say it needs three tries to get a usable result, and every try costs the same:

  • 3,000 × $0.50 ÷ 1,000,000 = $0.0015 for input
  • 1,000 × $2.50 ÷ 1,000,000 = $0.0025 for output
  • $0.0015 + $0.0025 = $0.004 per attempt
  • 3 × $0.004 = $0.012 per task

Half the price per token, one and a half times the price per task. The same thing happens without retries if B simply writes longer answers: with 3,000 output tokens in one attempt, 3,000 × $2.50 ÷ 1,000,000 = $0.0075, and $0.0015 + $0.0075 = $0.009. Still more than A's $0.008.

Model A at one attempt costs less per task than model B at three attempts, even though B is half the price per token
Same task, two models: the cheaper price per token does not always mean the cheaper task. Example prices, not a price list.

And the reverse holds too. If B gets it right the first time, it costs $0.004 per task, half of A. The price per token wins only when the number of tokens and attempts is about equal. Which is exactly the thing to check.

Flashcards

Words you'll meet in every API doc

Where the tokens per task actually go#

Three things move the token count, and none of them show up on a price list.

  1. Answer length. A model that explains itself at length writes more output tokens than one that answers in a line.
  2. Retries. A failed or unusable answer still cost tokens, and the next try pays again.
  3. Resent context. An API does not remember: every step of an agent sends the instructions, the files and the history again. If this is new, why a long chat costs more shows the mechanism.

The third one is the big one for agents. Take a coding agent that works in 20 steps. Assume a heavy agent step: 20,000 tokens in and 1,000 back. For a lighter run with real step-by-step numbers, see why AI agents use so many tokens. The answers are short. The input is not.

Guess the number

How many input tokens does a 20-step agent send in total, if every step sends 20,000?

Show answer

Answer: 400,000

20 × 20,000 = 400,000. Every step resends the context, so the input piles up even though each answer is short.

So for this job the input side decides the bill, and the output side hardly matters. A model with a cheap input price can win here even if its output price looks ordinary. That is something a price list shows you only when you read it with your own task in mind.

Here is that exact job, 20 steps of 20,000 in and 1,000 out, on the models available at CheapTokens. The table is live, so the numbers follow the current prices, and the OpenRouter column is there for comparison. With input and output counted together, all three are cheaper than OpenRouter in total.

Model Per request 20 requests OpenRouter, 20 requests
GLM-5.3-Flash $0.00044 $0.0088 $0.0151
DeepSeek-V4-Flash $0.0004 $0.008 $0.0308
MiniMax-M2.7 $0.0012 $0.023 $0.276

20,000 input and 1,000 output tokens per request. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.

For agent loops like this, DeepSeek-V4-Flash is a natural fit: 380K context, up to 32,768 output tokens per answer, and one price at any time of day, so a night run costs the same as a daytime one. The whole job across all 20 steps on it comes to $0.008. See the model page for details and the pricing table for every model.

A chatbot is the opposite story#

Now take a support bot. Say it gets 1,000 requests a day, and each one is a 2,000-token question with context and a 500-token answer. No loop, no history that grows, one attempt.

Here the price per token is almost the cost per task, because nothing multiplies it. On GLM-5.3-Flash, with 390K context and up to 8,192 output tokens per answer, one request costs $0.00006 and the whole day of 1,000 requests costs $0.06.

So the rule of thumb is simple. A short, single-shot task: the price per token is a fair guide. A loop, a retry-prone job or a long-answer job: price a whole task before you pick.

Measure your own task in ten minutes#

Your own numbers beat any example here. The script below sends one request and prints what it actually used and what that costs. The prices in it are an example: substitute the current ones from the pricing table.

python
from openai import OpenAI

client = OpenAI(base_url="https://api.cheaptokens.dev/v1", api_key="YOUR_KEY")

# example prices per 1M tokens, substitute current ones
PRICE_IN, PRICE_OUT = 1.00, 5.00

resp = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Flash-0731",
    messages=[{"role": "user", "content": "Summarize this ticket in one sentence: <your text>"}],
    max_tokens=300,
)
u = resp.usage
cost = (u.prompt_tokens * PRICE_IN + u.completion_tokens * PRICE_OUT) / 1_000_000
print(u.prompt_tokens, u.completion_tokens, round(cost, 6))

When it works you get three numbers on one line: tokens in, tokens out and the cost of that attempt. Then:

  1. Run 20 real tasks of yours, not toy ones.
  2. Add up the cost of every attempt, including the ones you threw away.
  3. Divide by 20. That is your cost per task.
  4. Repeat with the other model and compare the two results.
The script reads prompt_tokens and completion_tokens from usage and multiplies them by the two prices
The whole calculation: usage in, two prices, one cost per attempt. Prices in the script are an example.

For a longer run, tracking agent token cost in Python adds a budget and a stop to the same idea, and how many tokens a request uses shows typical sizes to start from.

Quick check#

Quick check

Model B costs half as much per token as model A. When can B still cost more per finished task?

Show answer

Answer: When it needs more attempts or writes much longer answers

Cost per task = attempts × tokens × price. Halve the price, triple the attempts and you pay 1.5 times as much.

Next, input vs output tokens explains why the two sides are priced differently, and the docs get you from a key to a first request.