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.
Read one session’s cost
getSession returns costUsd and costState with the rest of the session, in both the full and summary views.
- Console
- cURL
The console shows one figure for the whole session tree: the session and every subagent and teammate under it.
- In Sessions, read the Cost column.
- Open the session. The session header and the Session tab of its details show the same Cost.
- While the figure can still change, it reads so far. Session costs can take up to an hour to settle.
costUsd once costState is final (see Know when a figure is final).
Cost fields
Cost fields
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 fromlistSessions 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.
- cURL
listSessionUsage takes session_ids, a comma-separated list of up to 1000 ids.
- cURL
Usage rows
Usage rows
listSessionUsagereturnssession_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_microsis 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. UsecostUsdon the session for what you are charged.
Know when a figure is final
Why a cost can still grow
Why a cost can still grow
- The session is still running. The session or one of its subagents or teammates is working or waiting for you.
- 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.
- Charges are still settling. Session costs can take up to an hour to settle.
- You resumed the session. A message that starts a new turn makes a
finalcostso_faragain.
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.
Amount format
Amount format
- All amounts are in US dollars. No other currency is used.
costUsdhas up to nine decimal places and no trailing zeros. A zero cost is"0".cost_microsin 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.
costStatewasso_far. Record the cost once it isfinal. - A list adds up to more than the runs cost. Child rows repeat their tree’s cost. Send
root_only=true. - Usage
cost_microsandcostUsddiffer.cost_microscovers only the session’s own model events and is for diagnostics. UsecostUsd.
Every usage and cost error
Every usage and cost error
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.