What a trace holds
A trace is a tree of spans rooted at the turn. The root carries:
Routing has its own root span: the classifier’s model call is recorded and
billed separately from the answer, tagged as the handoff agent. Memory,
title generation and embeddings fold into the answer’s span.
Traces are the one source of truth. Cost on the traces page, on a group’s
usage bar, in the margin tile and in a CSV export all come from summing the
same root-span costs, so the dashboards agree with each other by
construction.
How cost lands on a trace
Cost is not estimated from token counts. After each answer, and hourly as a safety net, a sweep asks the model gateway what each request actually cost and writes it onto the root span. The write is monotonic: spend that arrives late for a trace — a background task’s second turn, a delayed usage record — is picked up by the next sweep and added, never dropped, and re-running a sweep is a no-op when nothing changed. The consequence for you: a turn’s cost is normally visible moments after the answer, and a figure can grow slightly in the following minutes as late records land. Bill from a window that has closed, not from the last few minutes.Billing groups
A group is the unit that spend attaches to — typically one of your customers. Every session, chat turn and workflow run names one. Use a stable id. Sessions and users takegroup_id; name the group once
with PATCH /v1/groups/{groupId} or POST /v1/groups. Sending a display
name without an id makes the name the match key, so “Acme”, “Acme Corp”
and “ACME” become three groups and the same customer’s spend splits across
them. An id never has that problem, and a changed name simply renames.
Groups create themselves. An unseen group_id on a mint or a user update
provisions the group with the default monthly cap. A session minted without
any group bills to the user’s current group, then to the organization’s
Default group — silently, so send it explicitly if you bill per team.
Every group has a monthly limit. monthly_limit is enforced per calendar
month against the sum of that group’s traces; null removes the cap. A
group over its limit gets 429 on chat, workflow runs and experiments until
the month rolls over or the cap is raised. The check is cached for ten
seconds and fails open, so a transient database problem never blocks a
customer.
GET /v1/groups?id=acme returns month_spend and limit_remaining
alongside the cap, for showing a customer their own usage. In the Studio,
each group’s usage bar turns amber at 70% of its cap and red at 90%.
The organization itself has a lifetime credit balance; when spend across all
groups reaches it, every request answers 429 until credits are added.
Margin
Each group has a margin percentage — what you charge that customer on top of model cost. The Studio’s cost page computes:- Gross margin — each group’s spend times its margin, summed.
- Sidenet fee — the platform’s percentage of total spend, from your pricing plan.
- Net margin — gross margin minus the fee. It can go negative when margins are set below the fee.
Evaluation spend
LLM judges used by experiments, trace scoring and the judge-backed guardrails bill to a dedicated LLM Judges group per organization, with its own cap. It never appears in a customer’s usage, and it is excluded from the group listing.The traces page
The Studio lists one row per turn — root spans only, with the routing classifier’s spans folded out of the list — for a date range that defaults to the last 30 days, with presets from today to year-to-date. Filters are added on demand and apply server-side across pages:- Environment — Dev, Staging, Prod.
- Group — by billing group.
- Agent — the agent that streamed the answer, all versions collapsed into one option.
- Model — the model that actually served, which is how you find the turns a routing policy sent to a fallback.
GET /v1/traces/{traceId}/scores — see
Scoring live traffic.
Reading requests over the API
Everything the traces page and the home page show is readable over the API, from the same request log the spend gate bills on. One row per request: a chat turn, a workflow run, an experiment item, a scorer run. A scorer run is a request of its own because it can run long after the turn it scores: it is counted in the window it ran in and billed to your judges group, exactly as on the monthly statement, and reported apart from the other requests. Each request also carries what scoring it has cost so far. A chat request answered with an error before any turn ran (an invalid body, the spend limit, an unknown agent) is in the log too, as a failed request whoseerror is the response you received plus its status.
Windows are
from (inclusive) to to (exclusive), ISO 8601, defaulting to
the last 30 days. Group ids are your stable ids, the ones you send on a
session mint. Agent and workflow ids match every version; pass
agent_version_id or workflow_version_id to narrow to one.
A chat turn carries both ends of the exchange: message_id is the
assistant message it produced, and prompt is the user message that
started it — its id and its text, clipped to 1 000 characters in the list
(truncated says when) and returned whole by GET /v1/requests/{id}. A
turn whose user message is not in the thread (a run, an experiment item)
has prompt: null. model is the model that actually served, and
model_profile the profile the copilot’s model classifier chose for the
turn, when one runs — so a turn served on a cheaper model than the agent’s
own can be traced to the profile that picked it.
GET /v1/requests/{id} also returns api_key_id, the API key the request
came in with (a session token counts as the key that minted it), and
http_request: the call that started the request as the caller sent it — method, path, query and JSON body
(variables, context, approval payload…). Credentials such as runtimeAuth,
tokens, passwords and keys are redacted before it is stored, data URLs and
long strings are clipped, and a body over 32 000 characters is kept as
clipped text with body_truncated: true. Scheduled runs, experiment items
and scorer runs have no HTTP call behind them, so theirs is null.
cost is the same figure the billing endpoints sum, so a
customer’s statement, their group’s usage bar and their rows here always
agree. A figure can still grow for a few minutes after the turn while late
usage records land (see above); stats over a closed window is stable.
Exports
Export writes the filtered rows to CSV, up to 50,000, with the columns in display order: timestamp, network and environment, group, streamed agent and model, participants, error count, latency, tokens, cost, scorers, rating, user id with thread id, input and output. Tokens and cost are separate numeric columns, so a monthly invoice per group is a pivot away. For programmatic billing,GET /v1/groups with month_spend is the
lighter-weight call; the CSV is for reconciliation and audits.