Show what a session spent
PreviewShow what a session spent: totals by cost category (uncached prompt, cache read, cache write, output), spend per hour and per turn, what started the turns, tool calls, and sandbox running time.
/v1/sessions/{session_id}/costSee authentication for credentials and permissions.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Prefixed public identifier
Responses
200Success
Success
What a session spent, split by cost category, over time, by what started each turn, by tool, and by sandbox.
object
Spend and tokens per cost category, in a fixed order: uncached_input,
cache_read, cache_write, output.
Spend and tokens of one cost category.
object
uncached_input, cache_read, cache_write or output.
Tokens in this category across every model call.
USD, from each call’s cost split by the model’s price table.
Spend per UTC hour that had model calls, oldest first.
Spend in one UTC hour, by category.
object
USD of prompt tokens read from cache.
USD of prompt tokens written to cache.
Start of the hour (UTC).
Model calls made in the hour.
USD of output tokens.
Spend with no category split (see SessionCost.unattributed_usd).
USD of prompt tokens not read from cache.
Model calls recorded for the session.
Spend per model, largest first.
Spend of one model.
object
Model calls made with this model.
Model id as the provider reported it.
Provider driver that served the model, when known.
Spend in USD on this model.
Sandboxes the session ran, oldest first.
A sandbox the session ran and how long it ran.
object
When the sandbox was created.
Seconds the sandbox spent paused.
Sandbox template profile, when one was used.
Sandbox provider, e.g. daytona or e2b.
Seconds the sandbox spent running.
Sandbox’s prefixed public identifier.
Lifecycle spans, oldest first.
A span of time a Sandbox spent in one state.
object
The Sandbox is still in this state.
Incarnation during the span.
Fleet state during the span.
Session’s prefixed public identifier.
Turns and spend by what started them, largest spend first.
Turns and spend of one origin.
object
The schedule still fires: enabled and not deleted.
Cron expression of a recurring schedule.
user, schedule, agent_trigger, channel, …
The schedule’s description, when it is a session schedule.
The schedule, trigger or channel, when there is one.
Turns this origin started.
Spend in USD on those turns.
Tool calls across the session.
object
Tool calls across the session.
Summed running time of every call.
Tool calls that ended in an error.
Per tool, most calls first.
Calls, failures and running time of one tool.
object
Calls of this tool.
Summed running time of its calls.
Calls of this tool that ended in an error.
Tool name.
Total spend in USD: the provider-reported cost of each model call where reported, otherwise the price-table estimate.
Spend per turn, oldest first; the newest turns when turns_truncated.
Spend of one turn.
object
Prompt tokens of the turn, cached and uncached.
What started the turn: user, schedule, agent_trigger, channel, …
When the turn started.
running, completed, failed, cancelled or sealed.
Per-session turn number, 1-based.
Turn’s prefixed public identifier.
Spend in USD on the model calls of the turn.
Older turns were left out of turns.
Spend of model calls whose split by category is unknown: the provider reported a cost but the model has no price table.
Model calls with no reported cost and no price-table estimate. They count
tokens but add nothing to total_usd.
Example
{ "categories": [ { "key": "uncached_input", "tokens": 1060877013, "usd": 106.09 } ], "model_calls": 3811, "models": [ { "calls": 3811, "model": "meta/muse-spark-1.3-contributor", "provider": "openrouter", "usd": 106.26 } ], "sandboxes": [ { "paused_seconds": 1860, "provider": "daytona", "running_seconds": 4320, "sandbox_id": "sandbox_01a1510c99c8714eabb22a463e7c1fa1", "spans": [ { "state": "running" } ] } ], "session_id": "session_01a1510c99c8714eabb22a463e7c1fa1", "sources": [ { "cron": "*/5 * * * *", "kind": "schedule", "name": "Shipmail claim poll", "source_id": "sched_01a1510ebffc7370a495ed68cc7f9ab3", "turns": 1845, "usd": 106.11 } ], "tools": { "calls": 1977, "duration_ms": 645000, "failed": 14, "items": [ { "calls": 1180, "duration_ms": 627000, "failed": 13, "name": "web_fetch" } ] }, "total_usd": 106.26, "turns": [ { "prompt_tokens": 2034790, "source_kind": "schedule", "status": "completed", "turn": 1162, "turn_id": "turn_01a124cd7e9571ac95c312b3c6d0cd82", "usd": 0.2 } ], "unattributed_usd": 0, "unpriced_calls": 0}