Learn · AI spend
How to measure the cost of an AI agent turn
IntSen team · Updated 12 November 2026 · 6 min read
Short answer
The cost of an AI agent turn is the sum of the cost of every model call the agent makes to answer one user message. To measure it, tag every call in the turn with the same identifier, record the tokens and price of each call, and add them up. The same records roll up to cost per conversation, per agent and per use case.
What a turn is, and why it matters for cost
A turn is everything an agent does to respond to one user message. A simple assistant makes one model call per turn. An agent may make many: it plans, asks for a tool, reads the result, asks for another, and finally writes the answer. Provider invoices show the total across all of those calls for the month, which tells you nothing about which agent, conversation or user drove the spend.
The calculation
For each model call, cost is the input tokens times the input price plus the output tokens times the output price, using the price of the model actually called. Some providers price cached input, reasoning tokens or embeddings differently, so record the token types the provider reports. The cost of the turn is the sum over its calls. The example below uses made-up prices of $2.50 per million input tokens and $10 per million output tokens.
| Call in the turn | Input tokens | Output tokens | Cost |
|---|---|---|---|
| 1 · Plan and request a search tool | 2,400 | 180 | $0.00780 |
| 2 · Read search results, request a second tool | 5,900 | 220 | $0.01695 |
| 3 · Write the final answer | 7,300 | 650 | $0.02475 |
| Turn total | 15,600 | 1,050 | $0.04950 |
Notice that input tokens grow with each call, because the agent resends the conversation and tool results each time. That growth, not the final answer, is usually where agent cost hides.
Grouping calls into a turn
To add calls up, each one has to say which turn it belongs to. The reliable way is for the application to create one identifier per user message and send it with every model call made for that message, including calls made by sub-agents. A second identifier for the conversation lets you roll turns up into conversations.
You also need to know when a turn is finished. Either the application says so, or the system infers it, for example when the model has returned a final answer and no further call arrives within a set time.
Rolling cost up
Once every call is costed and tagged, the same records answer the questions finance and engineering ask:
- Cost per turn and per conversation, for each agent.
- Cost per agent, use case, application and team, for budgets and chargeback.
- The most expensive users and conversations, to find abuse or loops.
- Overheads such as guardrail and evaluation model calls, shown separately from the agent's own work.
Stopping runaway turns
Measurement shows the problem after the fact. To prevent it, enforce limits in the request path: a maximum cost and a maximum duration per turn, after which further calls in that turn are refused, and monthly budgets per agent or use case that alert at thresholds and can deny when spent. A looping agent then fails one turn instead of running up a month's budget.
How IntSen does it
Cost per turn in IntSen
IntSen records cost on every governed request at its AI Gateway. Applications send a task id per user message and a conversation id; IntSen groups the calls into turns and ends a turn automatically when the model has given its final answer and no further call arrives within 20 seconds. Sub-agent calls join the parent turn when the task id is passed down.
Totals roll up per request, task, agent, registered use case and application service, with evaluation and guardrail spend shown separately. Monthly budgets alert at 50, 80 and 100 percent and can alert or deny; per-turn cost and time limits refuse further calls with the code task_budget_exceeded. Chargeback and invoice reconciliation are on the roadmap.
Common questions
Why is my agent's cost higher than the token count of its answers?
Because every call in a turn resends the conversation and the tool results so far. Input tokens grow with each step, and they usually make up most of an agent's cost.
How do I attribute AI cost to teams?
Tag every model call with the agent and use case it belongs to, and keep a record of which team owns each. Cost per call then rolls up to agents, use cases and teams.
Can I cap the cost of a single agent turn?
Yes, if your model calls pass through a point that tracks the turn's running cost, such as an AI gateway. It can refuse further calls in the turn once a cost or time limit is reached.
Should evaluation and guardrail costs count toward the agent?
Track them separately. They are real costs of running the agent safely, but mixing them in hides how much the agent's own work costs and makes budgets harder to set.