Session spend
What each of a Tenant's sessions spent on AI calls, per UTC day range or in real time for named sessions, under /v1/orgs/{orgId}/usage/sessions.
GET /v1/orgs/{orgId}/usage/sessions tells you what a Tenant's sessions spent on AI calls, so you can charge your customer per session or see which sessions cost the most. It works two ways: list every session that spent in a date range, usually 15 to 20 minutes behind, or look up named sessions in real time, to charge for a task as soon as it ends. It sits next to Organisation usage and takes the same credentials: an owner's or admin's session, or an Organisation Key of this Organisation. A Tenant of another Organisation is 404 not_found.
The figures are what the Organisation is charged for these calls, not an estimate. They are not the Tenant's whole bill: see What is counted.
List a Tenant's session spend
curl -s "$SAI_API_URL/v1/orgs/$ORG_ID/usage/sessions?tenantId=$TENANT_ID&from=2026-10-01&to=2026-10-31&limit=50" \
-H "Authorization: Bearer $SAI_ORG_KEY"{
"sessions": [
{
"sessionId": "cs_01HZY",
"title": "Reconcile the October invoices",
"costUsd": 0.4172,
"modelCalls": 23,
"firstDay": "2026-10-03",
"lastDay": "2026-10-04"
}
],
"nextCursor": null,
"dataThrough": "2026-10-28T09:45:00Z"
}Sessions come in order of firstDay, oldest first. A session that spent nothing in the range is left out. Paging never returns a session twice. But a session that starts or resumes spending while you page may be missed by that pass and show up only when you page again. For a range wholly in the past, older than the lag, the results don't change.
A page can hold fewer sessions than limit, or none at all, and still have a nextCursor. Keep paging until nextCursor is null; an empty page is not the end.
Each Tenant can be read at most 1200 pages an hour, counted from its first page in the hour. Pages read with a member's session for the same Tenant count too. Past that, requests get 429 rate_limited until the hour is up.
Across all its Tenants, an Organisation can make at most 60 requests a minute to this endpoint, pages and real-time lookups together, with an Organisation Key or a member's session, counted from its first request in the minute. Requests that end in 503 count too, so back off before retrying them. Past that, requests for any of its Tenants get 429 rate_limited until the minute is up. The message says which limit was hit, and the Retry-After header says how many seconds until that limit's minute or hour is up: wait that long before trying again. The minute and the hour start at the first request rather than on the clock, so the wait can be anything up to 60 seconds for the Organisation's limit, or up to an hour for a Tenant's.
{ "error": "invalid_request", "message": "from and to are at most 93 days apart, inclusive" }Look up sessions in real time
Send sessionIds instead of a date range to get the named sessions' spend right now, with a settled flag that says whether every charge for the session's latest task has come in. Use it to charge your customer when a task ends.
curl -s "$SAI_API_URL/v1/orgs/$ORG_ID/usage/sessions?tenantId=$TENANT_ID&sessionIds=cs_01HZY,cs_01J0A" \
-H "Authorization: Bearer $SAI_ORG_KEY"Don't send from, to, limit or cursor with sessionIds; that is 400 invalid_request.
{
"sessions": [
{
"sessionId": "cs_01HZY",
"title": "Reconcile the October invoices",
"costUsd": 0.4172,
"modelCalls": 23,
"settled": true
},
{
"sessionId": "cs_01J0A",
"title": "Book the follow-up visits",
"costUsd": 0.0381,
"modelCalls": 4,
"settled": false
}
],
"asOf": "2026-11-03T09:45:12Z"
}Sessions come back in the order you named them. A session of this Tenant that has spent nothing yet comes back with 0. An id that is not one of this Tenant's sessions, or a session that has been deleted, is left out of sessions, not an error, so check that each id you sent came back. There is no nextCursor, dataThrough, firstDay or lastDay in this form.
One lookup has a limited amount of reading it can do, and one very busy session can use it up for every session in the request. When a lookup naming several sessions brings back some or all of them with costUsd: null, take those sessions out of the shared request and, from then on, look each of them up in a request of its own, one session per request, spreading those requests over your polls so they fit in your limits alongside your other lookups. A session that still comes back null in a request of its own a couple of times can't be read in real time for now: leave it out of later lookups, and take its figure from the list once the list has caught up with it, as for a session that never settles (see below).
Each lookup counts as one page toward the Tenant's 1200 pages an hour and as one request toward the Organisation's 60 a minute, however many ids it names. Errors are the same as the list's; see the table above.
Charging when a task ends
- Wait for the task to end: its turn is
succeededorfailed. Read the task's result before you look up its cost. A failed task has spent too.finalizingis not the end. Read the turn, not just/v1/agents/events: sometimes a turn only finishes once it is read, and until thensettledstaysfalse. - Look the session up. If
settledisfalse, ask again every 10 seconds or so. Put every session of that Tenant you're waiting on into one request (up to 50) rather than one request each, except sessions that came back withcostUsd: null(see above). Sessions of different Tenants need one request per Tenant. To stay within the Organisation's 60 requests a minute, don't send your lookups in bursts: send at most one request every 1.25 seconds across the whole Organisation (about 48 a minute), cycling through the requests you have waiting (one per waiting Tenant, plus one per session you look up on its own, plus extra ones for a Tenant with more than 50 waiting sessions), and send the same request (the same group of sessions) no more often than every 10 seconds. All of one Tenant's requests together also count toward its 1200 pages an hour, so when a Tenant needs several requests, send them no more often than one every 3 seconds. With 10 requests waiting, each comes around every 12.5 seconds; with 40, every 50 seconds. The rest of the minute is headroom for retries and list pages. - Once
settledistrue, chargecostUsd.
settled usually turns true about half a minute after the turn is succeeded or failed. With output_schema or success_criteria, the turn itself stays finalizing for up to a few minutes after Sai stops, while Sai makes those calls. If Sai can't tell whether all the charges are in, settled stays false. If it is still false about 10 minutes after the turn ended, stop asking and take the session's figure from the list once it has caught up.
settled is about the session's latest task. A POST /message to the session after its task has ended starts a new task: its costUsd keeps adding up from where it was, across every task, and settled goes back to false. To charge per task, start a new session for each task, or subtract what you charged for the earlier tasks.
Rarely, a charge can still arrive after settled turns true. When the list catches up, it counts it, so the list is the figure to reconcile against.
What is counted
Both forms count the same thing. Once the list catches up, a session's figure in the list, over a range that covers the session's whole life, should match its real-time figure, for sessions that ran after this endpoint shipped. A session's spend is its AI calls: the model calls Sai makes to do the task, choosing a model when the session uses auto, locating elements on the screen, and the calls Sai makes after a task finishes, to fill in output_schema and check success_criteria.
- Only AI calls. Computer time, residential proxy traffic and storage are not split by session. Read them per Tenant from Organisation usage.
- The sessions don't add up to the Tenant's bill. Adding up every session's
costUsdcan come to less than what the Tenant cost. Besides computer time, proxy traffic and storage, it leaves out AI calls that don't belong to a chat session, such as writing or repairing learned code, and the spend of sessions that were deleted. For the Tenant's own spend, see its entry underbyTenantin Organisation usage. - In the list, spend from before this endpoint shipped is not counted. Sessions that ran before then read low or are missing from it.
- Locating elements on the screen is counted once the machine's Sai runtime is updated, where that work runs on the machine. Until then, those calls are missing from the sessions that ran on it.
When the figures are final
This section is about the list. For a real-time figure, see settled.
- Days are UTC. A session that runs across the edge of your range counts only the days inside it.
- The figures lag, usually by 15 to 20 minutes, and longer when a backlog builds. The most recent day reads low until they catch up;
dataThroughsays how far they go. - A running session's figures change each time you ask.
- The calls after a task finishes are charged a little after the task ends, so a session can still go up for a few minutes after it goes idle.
Compared with sessionUsage on /events
sessionUsage on GET /v1/agents/events is a live count while you watch a task. It covers only the model calls Sai makes to do the task, not choosing a model, locating elements or the calls Sai makes after a task finishes, to fill in output_schema and check success_criteria. Its costUsd is also rounded to cents and this endpoint's is not, so the two won't match exactly. Use this endpoint for what a session cost, and its real-time lookup to charge as soon as a task ends.