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.
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. Its Estimated cost per session hour section 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. In Sessions, 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.
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. The cost is one total; it is not split by session, model call, or kind of charge.Both fields are absent when the cost can’t be read right now. An absent cost is not zero; read the session again later.

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 and sandbox compute. Use costUsd on the session for what you are charged.

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 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.
  3. Charges are still settling. Session costs can take up to an hour to settle.
  4. 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.