agenttabGet the app
  • Models
  • Basics

AI agent cost per task: how tokens add up

What an AI agent costs per task: the tokens each step sends, a formula to estimate one run, a worked example, and the settings that cut the bill.

Updated 6 min read

On this page: 6 sections
  1. 1What each step sends to the model
  2. 2A formula to estimate the cost per task
  3. 3A worked example, with made-up numbers
  4. 4What pushes the cost up or down
  5. 5How agenttab shows and controls the cost
  6. 6FAQ

An AI agent’s cost per task is the tokens it sends and receives, multiplied by your model’s per-token prices. Every step of a run sends the model its instructions, the conversation so far and the current page, often with a screenshot, so the bill grows with the number of steps faster than you might expect. You can estimate it with one formula and bring it down with a few choices.

What each step sends to the model

An agent works in a loop. It looks at the page, asks the model what to do, does it, and looks again. Each trip to the model is a request, billed by its input tokens (what goes in) and its output tokens (what comes back).

The input of a single step usually holds:

  • The system prompt. The agent’s standing instructions: how to behave, when to stop, what to ask before doing.
  • Tool definitions. A description of every action the agent can take, such as tap, type, scroll or open a tab, with its parameters. Extra tools, such as connectors to outside services, add to this.
  • Your task. Usually short.
  • The conversation so far. Every earlier step: what the model decided, what happened, what the page said.
  • The current page. Its address, title, visible text and a list of the elements the agent can act on. A long page means a lot of text.
  • A screenshot, if the agent sends one. Images are counted in tokens too.

The output is smaller: a tool call (“tap element 14”), sometimes a line of text, and the final answer at the end. With reasoning models, the thinking the model does before it answers is usually billed as output tokens as well.

What a screenshot costs in tokens

Each provider has its own rule for images. Anthropic, for example, documents that an image costs one token for every 28 × 28 pixel block, rounding up. A phone screenshot scaled to 560 × 1,260 pixels works out to 20 × 45 = 900 tokens. Larger images cost more, up to each model’s cap. Your provider’s vision docs have its rule.

Why later steps cost more

The model doesn’t remember the last request. To keep it on track, the agent sends the conversation again each time, so step 20 carries everything from steps 1 to 19 plus its own page. If nothing is trimmed, the input grows with every step, and the total grows roughly with the square of the number of steps. That is the main reason a long run costs much more than a short one.

Apps soften this in two ways. Prompt caching lets a provider charge less for input it saw moments ago, such as the unchanged start of the conversation. Trimming drops old screenshots or tool results the model no longer needs.

A formula to estimate the cost per task

Call the part every step repeats the fixed tokens: system prompt, tool definitions and task. Call what each step adds to the conversation the new tokens: page text, screenshot and the model’s own reply. Then, with nothing trimmed or cached:

input for step n     ~ fixed + new × n
total input tokens   ~ steps × fixed + new × steps × (steps + 1) ÷ 2
total output tokens  ~ steps × output per step
cost                 ~ total input × input price + total output × output price

Prices are quoted per million tokens, so divide by a million at the end. Caching and trimming bring the real figure down from this.

A worked example, with made-up numbers

The figures below are invented to keep the arithmetic easy. They aren’t any provider’s prices and aren’t measured from any app.

Say a model charges $1 per million input tokens and $5 per million output tokens. A task takes 20 steps. The fixed part is 8,000 tokens. Each step adds 4,000 new tokens: 2,500 of page text, 1,000 for the screenshot and 500 for the model’s reply. Each step outputs 500 tokens.

  • Total input: 20 × 8,000 + 4,000 × 20 × 21 ÷ 2 = 160,000 + 840,000 = 1,000,000 tokens, or $1.00.
  • Total output: 20 × 500 = 10,000 tokens, or $0.05.
  • Cost of the run: about $1.05.

Now change one thing at a time:

ChangeTotal inputTotal outputCost
None (20 steps, as above)1,000,00010,000$1.05
Screenshots off (3,000 new per step)790,00010,000$0.84
Clearer task, 10 steps instead of 20300,0005,000about $0.33
A model at a fifth of the price1,000,00010,000$0.21
Three quarters of the input cached, at a tenth of the price1,000,00010,000about $0.38

Three things stand out. Halving the steps cut the cost by about two thirds, not by half, because of the growing history. Input is most of the bill: here, 95 percent of it. And the model’s price scales everything else.

What pushes the cost up or down

  • Model choice. The biggest lever. Per-token prices between a provider’s smallest and largest models can differ by ten times or more, and many routine web chores don’t need the largest one.
  • Number of steps. A clear task finishes sooner. “Download the October invoice from the billing page at portal.example.com” beats “get my invoice”. Start the agent on the right page if you can.
  • Screenshots. Each one adds image tokens. Text only is cheaper, though the agent can be less sure of itself on pages that are mostly pictures.
  • Long pages. Page text is input. A results page with 200 rows or an endless feed costs more per step than a short form.
  • Detours. Cookie banners, sign-in walls, pop-ups and errors each add steps. Signing in to a site yourself before the run saves the agent that trip.
  • Extra tools. Every tool definition goes out with every step. Turn off the ones a task doesn’t need.
  • A smaller model for routine steps. Some agents send plain navigation (scroll, tap, next page) to a cheaper model and keep the main model for reading and decisions.
  • A step limit. It caps the worst case when a run goes in circles.

How agenttab shows and controls the cost

agenttab is free; you pay your provider for the tokens a run uses, at its price, on your own key (more in what bring your own key means). There’s no single per-run figure to quote, because it depends on your model, the site and the task. What the app does is show you the numbers and hand you the levers above.

  • Tokens and cost per run. Every run’s step log shows token counts and cost per model. The cost is worked out from the model’s listed price; for a model the app has no price for, it shows the tokens and a dash. Runs on your own server show $0.00. Your provider’s bill is the final word.
  • Send screenshots. A switch in Settings. Off sends text only: cheaper, a little less sure-footed.
  • Small model for the walking. An optional smaller model from the same provider takes the navigation steps. The first step, reading, decisions and anything after an error stay on your main model, and the main model takes over at least every fifth step.
  • Step limit. A run stops after this many steps. It’s 40 unless you change it.
  • Trimming and caching. On Anthropic models, agenttab turns on prompt caching and asks the provider to clear old tool results. On OpenAI-compatible providers, only the two latest screenshots stay in the conversation.
A result card in agenttab headed 4 fares under €250 in a table, with Airline, Depart, Return and Price columns. Under the table a line lists the run’s steps, duration, tokens and cost, followed by CSV, JSON, Copy, Share and Export as video buttons.
The result of a demo run. The line under the table gives the run’s steps, time, tokens and cost.

A good habit: run a new task once while you watch, check its cost, and only then put it on a schedule. The how a run works section shows what each step looks like.

FAQ

How much does an AI agent cost per task?

There’s no single number. It depends on the model’s price, how many steps the task takes, how long the pages are and whether screenshots are sent. Estimate with the formula above, then run the task once and read the actual token count.

Why did a short task cost more than I expected?

Usually because it took more steps than it looked like it would: a cookie banner, a sign-in page, a search that needed a second try. Each extra step resends the conversation so far, so detours late in a run cost the most.

How do I check what one task cost?

Look at the run itself. In agenttab the result shows the run’s tokens and cost, and the step log splits them by model when a smaller model took some of the steps. Your provider’s usage page is what you’re billed from, so check it too once it has caught up.

Do stopped or failed runs cost money?

Yes. The provider bills every request the agent made before it stopped. A clear task and a step limit keep a failing run from going on for long.

Is running a model on my own computer free?

There’s no per-token bill, but you pay in hardware, electricity and speed. Smaller local models may also need more steps, or miss things a larger model would catch. Here is how to point a phone at one.

Keep reading

  • Models
  • Privacy
  • Basics

Bring your own API key: what BYOK means for AI apps

What bring your own API key means for AI apps: who bills you, where requests and keys go, and how to set a spending limit at OpenAI, Anthropic and Google.

9 min read