Docs/Session spend
Organisations

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

List a Tenant's session spend for October
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"
QueryRequiredNotes
tenantIdyesThe Tenant, as tenantId in Tenants.
fromyesFirst day, YYYY-MM-DD, in UTC. Inclusive.
toyesLast day, YYYY-MM-DD, in UTC. Inclusive. On or after from. The range is at most 93 days, counting both ends.
limitnoSessions per page, 1 to 100. Default 50.
cursornoThe nextCursor of the previous page. Keep from and to the same.
200 OK · Session spendJSON
{
  "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"
}
FieldNotes
sessionIdThe session, as in /v1/agents/events.
titleThe session's title. An empty string, or null, when it has none.
costUsdWhat the session's AI calls cost on the days inside from to to, in US dollars. Not rounded to cents.
modelCallsThe AI calls counted in costUsd, on the days inside from to to only.
firstDay, lastDayThe UTC days the session's spend was first and last counted, over its whole life, not just the range. They can fall outside from to to. A call that is charged late can count toward an earlier day without moving firstDay.
nextCursorPass as cursor for the next page. null on the last page.
dataThroughThe time the figures are complete up to. Calls after it are not counted yet. null when unknown.

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.

StatuserrorWhen
400invalid_requesttenantId is missing or sent twice; without sessionIds, from or to is missing, sent twice, or not a real day in YYYY-MM-DD form; to is before from; the range is longer than 93 days; limit is not 1 to 100; or cursor is not one this endpoint gave. With sessionIds: it is empty, sent twice or names more than 50 sessions; an id in it isn't a valid session id; or from, to, limit or cursor is sent too.
403session_requiredA personal API key, or any credential other than a member's session or an Organisation Key.
403not_available_for_tenantA Tenant token.
403organisation_disabledAn Organisation Key of a disabled Organisation.
404not_foundNo such Organisation, not yours, or an Organisation Key of another Organisation; or no such Tenant in it.
429rate_limitedMore than 1200 pages for this Tenant within the hour, or more than 60 requests for this Organisation's Tenants within the minute. The message says which limit; wait the seconds in the Retry-After header before trying again.
503session_usage_unavailableSession spend can't be served right now: it isn't available yet, or spend can't be read at the moment. Try again later.
503billing_unavailableSpend could not be read right now. Try again shortly.
400 Bad Request · invalid_requestJSON
{ "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.

Look up two sessions' spend
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"
QueryRequiredNotes
tenantIdyesThe Tenant, as tenantId in Tenants.
sessionIdsyes1 to 50 session ids, separated by commas. An id named twice is answered once.

Don't send from, to, limit or cursor with sessionIds; that is 400 invalid_request.

200 OK · Sessions in real timeJSON
{
  "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"
}
FieldNotes
sessionIdThe session, as in /v1/agents/events.
titleThe session's title. An empty string, or null, when it has none.
costUsdWhat the session's AI calls have cost so far, over its whole life, in US dollars. Not rounded to cents. null when it can't be read in full right now, for example for a very long session, or because another session in the same request used up the reading; it is never 0 for that. settled is then false; the paragraph after this table says what to do.
modelCallsThe AI calls counted in costUsd. null with costUsd.
settledtrue once the session's latest task has ended and every charge for it has come in. false while it runs or while charges are still arriving.
asOfThe time the figures were read.

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

  1. Wait for the task to end: its turn is succeeded or failed. Read the task's result before you look up its cost. A failed task has spent too. finalizing is not the end. Read the turn, not just /v1/agents/events: sometimes a turn only finishes once it is read, and until then settled stays false.
  2. Look the session up. If settled is false, 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 with costUsd: 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.
  3. Once settled is true, charge costUsd.

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 costUsd can 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 under byTenant in 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; dataThrough says 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.

© 2026 Simular Inc. All rights reserved.