Skip to main content
Every session has one cost: what your credit balance is charged for its whole session tree. It covers the session and every subagent and teammate it started, and all of their model calls, provider tools such as a provider’s web search, and sandbox compute. Read it in the console or as costUsd on the session, and use costState to tell a final cost from one that can still grow. An automation coordinator’s cost covers the subagents linked to it now: when a coordinator is replaced, its independent subagents still running or waiting on a person, and everything they have spent, move to the coordinator that takes them over.
Any organization role that can read sessions can read their cost: user, developer, or admin. The billing role cannot see sessions. See Organizations and roles and API keys. Credits are bought separately on the Billing screen; see Billing.
To estimate cost before a session, open an agent in the console and select its Cost estimate tab. It shows what one session hour typically costs, priced on the compute you choose. Pick a model first to see an estimate. Pricing explains what that price covers.

Read one session’s cost

getSession returns costUsd and costState with the rest of the session, in both the full and summary views.
The console shows one figure for the whole session tree: the session and every subagent and teammate under it.
  1. Open Advanced in the sidebar, choose Sessions, and read the Cost column.
  2. Open the session. The session header and the Session tab of its details show the same Cost.
  3. While the figure can still change, it reads so far. Session costs can take up to an hour to settle, and a subagent, teammate, the advisor or the supervisor waiting to be called on again can keep its conversation cached for up to six hours while the session that calls on it is still working, each cache read charged.
Some fields are omitted from this response.
Record costUsd once costState is final (see Know when a figure is final).
A subagent or teammate session returns the cost of its whole tree, the same figure as its root. costUsd is one total; to split it by model and kind of charge, or to read what was spent in a time window, see Break a run’s cost down. Read the root session to learn when a cost is final: a subagent or teammate session can still report so_far after its tree has settled.A so_far cost can be behind what the session has cost. When the cost can’t be read again in time, costUsd is the last amount that was read. When running compute can’t be priced right now, costUsd leaves it out until it can be.Both fields are absent when there is no cost to return yet or when the cost is withheld in the session’s current state. An absent cost is not zero. Read the session again later if no cost has been read yet; retrying alone does not resolve a withheld cost.

Compare many sessions

Rows from listSessions carry costUsd and costState too. Send root_only=true to get one row per run. A child session repeats its tree’s cost, so adding child rows counts the same cost twice.
For token counts, listSessionUsage takes session_ids, a comma-separated list of up to 1000 ids.
  • listSessionUsage returns session_usage: the event count and token counts for each session’s own events. Children are not included. Unknown ids and sessions with no events are left out, so compare the number of rows with the number of ids you sent.
  • cost_micros is the cost the session’s own model events reported, in millionths of a US dollar. It is for diagnostics, not what your balance is charged: it leaves out child sessions, sandbox compute, and the requests that keep a waiting session’s cache alive, which add no event. Use costUsd on the session for what you are charged.
  • In v2 (listSessionUsageV2), each row also has models: the same totals split by public model id, one item per model, which add up to the row. They cover the same own events, so they also leave out context-compaction summaries, cache keep-alives, memory digests, sessions your key can’t see such as the agent’s oversight advisor or supervisor, and sandbox compute. For the billed cost by model, use the breakdown below.

Break a run’s cost down

getSessionCostV2 returns a root session’s billed cost split by where it was spent, kind of charge, and model. It covers exactly what the root’s costUsd counts: its own tree, plus the subagent, oversight and grader runs costUsd includes, which are reported by role and never identified. source is self, subagent, oversight (the advisor or supervisor configured under the agent’s oversight settings) or grader. Every amount is read at one moment, readAt.
  • Send a root session’s id. A child session inside a tree is refused with 400, naming its root. A subagent that runs as its own root reports its own tree.
  • Without a window, totalUsd is bookedUsd plus computeEstimateUsd, the estimate for sandbox compute still running, and equals the root’s costUsd read at the same moment.
  • bookedAtGte and bookedAtLt select the half-open window [bookedAtGte, bookedAtLt). A charge counts by when it was booked and a correction by when it was made, so a window can hold a correction to an earlier charge and total less than zero. A windowed read has no computeEstimateUsd, because running compute has no booking time yet.
  • costState is the root’s costState. unsettledAttempts.indeterminate counts requests lost in flight that the provider may still bill. These counts cover requests only, not running compute: a finished run whose compute has stopped can stay so_far while indeterminate requests remain, but the counts alone don’t show that spending has stopped.
  • To total a campaign, list its roots with listSessionsV2 filtered by metadataAll (it lists root sessions only), then read the breakdown of each root, at most two at a time. Each serving process admits two breakdowns at once for your organization and waits up to two seconds for a slot; when your organization’s slot doesn’t free in time the read answers 429 session_cost_breakdown_limit (with details.limit), and when the service’s shared capacity doesn’t it answers 503 session_cost_unavailable. Both carry Retry-After. If any root answers 409 session_cost_withheld, its cost is unknown: report the total as incomplete rather than counting it as zero.

Know when a figure is final

  1. The session is still running. The session or one of its subagents or teammates is working or waiting for you.
  2. The session is waiting on a timer, its subagents, its grader or a long-running command. On models that keep a conversation cached for an hour, the cache is read again about every 50 minutes while the session waits, for up to six hours; on models that keep it for 30 minutes, about every 20 minutes for up to two hours. That way the session doesn’t pay to send the whole conversation again when it resumes. Each read is a model charge, normally a small fraction of sending the conversation again. If the cache is gone by then, that one request is charged as the full conversation and the reads stop. A read adds no event to the session, so usage rows don’t count it.
  3. A subagent, teammate, the advisor or the supervisor is waiting to be called on again. A subagent that reported and waits for the session that started it to message it again, a teammate waiting for work on its team’s board, the advisor between consultations and the supervisor between detector firings have their cache read the same way, and each read is charged. Their cache is kept only while the session that calls on them is still working, running or waiting on a timer, its subagents or its grader: the session that started the subagent, the team’s leader, or the session the advisor or the supervisor oversees. Once that session finishes, waits on you, is cancelled or fails, the reads stop until it next calls on them; cancelling it stops them sooner. A subagent that reported, the advisor between consultations and the supervisor between detector firings show completed, so their cost, and the session’s cost, reads so_far until about an hour after their last model call or cache read, whether or not their cache is kept.
  4. The sandbox is still running. A sandbox can keep running after the session ends, until the environment’s idle stop. Its compute is included as an estimate until it stops.
  5. Charges are still settling. Session costs can take up to an hour to settle.
  6. You resumed the session. A message that starts a new turn makes a final cost so_far again.
costUsd is an exact decimal string, such as "1.234567". Add costs with a decimal type, such as Decimal in Python or a decimal library in TypeScript. Floating-point sums drift.
  • All amounts are in US dollars. No other currency is used.
  • costUsd has up to nine decimal places and no trailing zeros. A zero cost is "0".
  • cost_micros in usage rows is an integer in millionths of a dollar.

What can go wrong

The most common problems:
  • The cost changed after you recorded it. costState was so_far. Record the cost once it is final.
  • A list adds up to more than the runs cost. Child rows repeat their tree’s cost. Send root_only=true.
  • Usage cost_micros and costUsd differ. cost_micros covers only the session’s own model events and is for diagnostics. Use costUsd.
The full list of codes is in Errors.

Limits

Every other limit is on Limits.

Next steps

Billing

Buy the credits that session costs are charged to.

Teams

See why a team costs more than one agent.

Multi-agent

Understand the session trees behind one session cost.

Limits

Check quotas and request limits.