Request tags
Label requests with X-Tokamak-Tag, then use those labels to read Analytics, find and export captured data, and split an agent's budget between the people it serves.
A request tag is a label your client puts on an inference request, such as exp-42, task:pick-and-place or user:g_4f2a. You set it once, with the X-Tokamak-Tag header or tokamak launch --tag, and Tokamak carries it everywhere the request is recorded.
| Where | What tags do there |
|---|---|
| Analytics | Group usage by tag, or narrow the whole page to one tag |
| Data capture | Search, filter and export captured records by tag; capture only tagged traffic |
| Agent budgets | Give each tier or each person an agent serves its own allowance |
Tags are labels. They never choose a model, set a price or grant access, and the provider never sees them. The one place they affect whether a request runs is a budget on one of your agents, and there they can only narrow what the agent may already spend.
Send tags
From your own client
Send X-Tokamak-Tag on any request to /v1/chat/completions, /v1/messages or /v1/responses. Repeat the header, or separate tags with commas.
curl https://<gateway>/v1/messages \
-H "Authorization: Bearer $TOKAMAK_API_KEY" \
-H "X-Tokamak-Tag: exp-42, task:pick-and-place" \
-H "X-Tokamak-Tag: team:robotics" \
-d '{"model": "anthropic/claude-sonnet-5", "max_tokens": 512, "messages": [{"role": "user", "content": "..."}]}'With an SDK, set the header as a default on the client:
from openai import OpenAI
client = OpenAI(
base_url="https://<gateway>/v1",
api_key=TOKAMAK_API_KEY,
default_headers={"X-Tokamak-Tag": "exp-42,task:pick-and-place"},
)Tokamak-Tag, without the X- prefix, is still accepted as an alias for now. Prefer X-Tokamak-Tag.
From tokamak launch
# One launch, two tags
tokamak launch claude --tag exp-42 --tag task:pick-and-place
# A comma list works too
tokamak launch codex --tag=exp-42,team:robotics
# Tag every launch from this machine by default
tokamak config set-tag team:robotics
tokamak config clear-tagThe launcher takes the first of these that is set: --tag, then the TOKAMAK_TAG environment variable (a comma list), then the defaults saved with tokamak config set-tag. They are not merged. Every agent tokamak launch starts sends the same tags on every inference request it makes, and on its telemetry as the tokamak.tags resource attribute. See Coding agents.
How tags are read
| Rule | Example |
|---|---|
| Each header value is split on commas and trimmed | exp-42, team:robotics is two tags |
| Lower-cased | Exp-42 is stored as exp-42 |
Must match ^[a-z0-9][a-z0-9._:/@-]{0,63}$, so at most 64 characters | exp 42 (space) and #42 are not tags |
| De-duplicated, sorted, at most 16 per request | |
| A value that is not a tag is dropped, not refused | The request still runs and is still metered |
| No tag | Shown as Untagged |
A dropped value is easy to miss. The CLI warns when it drops one. When data capture is on, each record counts the dropped values in tags_rejected. Agent budgets are stricter: they refuse a malformed tag for their key instead of dropping it.
Choose a convention
key:value is a convention, not a rule, but it makes tags easy to filter and is required for per-value budgets. Agree on a few keys before you start; for example:
| Key | Use | Example |
|---|---|---|
exp | An experiment or evaluation run | exp:grasp-v3 |
task | The task or dataset split | task:pick-and-place |
team, project | Who the work is for | team:robotics |
app, tier, user | An agent's own product, customer tier and end user | app:drive, tier:guest, user:g_4f2a |
Don't put secrets or personal data such as email addresses in a tag. Tags are shown in Analytics, request lists, captured data and exports to everyone who can read them. For people an agent serves, send a stable opaque identifier instead.
Tags in Analytics
Every request's tags are recorded on its usage record.
- Group by tag. Analytics has a Tag breakdown, and the leaderboard can rank tags by usage cost, requests or tokens. A request with two tags counts under both, so tag rows don't add up to the total. Untagged has its own row, which shows how much of your work is unlabelled.
- Filter by tag. Pick a tag from the Tag button next to the date range, or select its row in the breakdown. Overview, Costs, Reliability, Breakdown and Requests then count only requests carrying that tag. Untagged narrows to requests sent without one. The filter stays in the page link. See Filter by tag.
- Requests shows each request's tags, and you can search loaded requests by tag.
Limits of the tag filter:
- It covers windows of up to 92 days. Past that, the page offers Use last 90 days or Remove tag filter.
- Value, client sessions and Insights digests can't be filtered by tag, and Tools shows inference usage but not client activity, because outcomes and client telemetry carry no request tags.
- Only the tags sent with each request count. Data capture default tags are added to capture records, not to usage.
From the API, pass tag=<tag> (or tag=none) on the me, team, organization or platform analytics endpoints, and by=tag to group. One tag per query; a value that is not a valid tag, or a window longer than 92 days, returns 400. See Usage API: tag requests.
Tags in data capture
When an administrator turns on data capture, each captured record carries the request's tags, so your data or research team can find and export work by experiment or task.
| Setting or tool | What it does with tags |
|---|---|
| Only capture tagged requests | Records a request only if it carries a tag. Experiments are recorded and untagged everyday work is not. |
| Default tags | Added to every captured record, after the request's own tags, up to 16. They never displace a request tag, and they don't appear in Analytics. |
| Insights → Captured data | Filter and search records by tag. |
| Session labels | Separate from request tags: labels such as outcome:success that reviewers add to a captured session afterwards. |
| Dataset export | Choose records by tag. A filter can keep one session per task:* tag, and every export line carries the record's tags in its _tokamak block. |
The capture API filters by tag too. GET /v1/admin/active-org/captures?tags=exp:grasp-v3,robot:ur5 returns records carrying every listed tag. See Tag what you collect.
Tags can't turn capture back on. An agent's own capture setting, and a member's opt-out where allowed, apply whatever tags a request sends.
Tags in agent budgets
A server holding an agent key often serves people of its own: a public page, a chatbot, an internal tool. A budget on that agent can use the tags the server sends to divide the agent's spend:
- Only requests tagged limits the budget to requests that carry every listed tag, for example
tier:guest. - A separate budget per tag value, with a tag key such as
user, gives every value of that key its own allowance:user:u_1,user:g_7, and so on.
For example, an agent behind a public page could have:
| Budget | Settings |
|---|---|
| Agent cap | All of the agent's requests, one shared $150 a day |
| Guest pool | Tagged tier:guest, one shared $5 a day |
| Each guest | Tagged tier:guest, separate per user, $0.25 a day |
| Each client | Tagged tier:client, separate per user, $20 a day |
The server then sends, on every request:
X-Tokamak-Tag: app:drive,tier:guest,user:g_4f2aTo set these up, open Organization › Budgets & limits, choose Set budget, and pick the Agent audience. See Budgets for an agent's own users.
Why a tag can't raise spend
- Agent keys only. Tokamak recognises the agent from the key itself, never from a header. On a member's key or any other key, the same tags stay labels and match no agent budget.
- Narrowing only. Every budget that applies still applies, and the tightest one decides. The agent cap limits the tier pools, the tier pools limit each per-value allowance, and your organization's budgets limit them all. A wrong or forged tag can move spend between the agent's own allowances; it can't raise the total.
Exactly one value
When a Stop requests at the limit budget gives each tag value its own allowance, every request it applies to must carry exactly one well-formed tag for its key. Otherwise Tokamak refuses the request before it reaches a model, with 400 and error code budget_tag_required. The error's budget object names the budget, its tag_key, and a reason:
reason | The request carried | Fix |
|---|---|---|
missing | No user: tag | Send X-Tokamak-Tag: user:<id> |
ambiguous | Two or more user: tags | Send exactly one |
malformed | A user: value that is not a valid tag | Use lower-case letters, digits and ._:/@-, at most 64 characters in all |
A 400 has no Retry-After: sending the same request again changes nothing. A refused request is never charged to a shared pool. A Track only budget doesn't refuse; it just doesn't count requests it can't place.
When a budget for an agent is used up, the request gets 429 usage_limit_exceeded with a budget object, like any budget. 402 means the organization's wallet is empty, not that a person's allowance is used up.
Agent budgets read every well-formed tag, without the 16-tag limit, so a budget's key is never dropped because a request carries many tags.
Tips for agent servers
- Use an identifier that stays the same across a person's visits, such as a signed cookie for a guest, not a token minted per request. A new identifier starts a new allowance, which is why a shared pool should cap the total.
- Put alerts on the agent's shared budgets. Allowances per tag value don't send alerts.
- The budget page shows Allowances by
user:tag with the heaviest values first.
What tags never do
- Choose a model, a provider or a route.
- Change a price or what is billed.
- Grant access, select or skip a guardrail policy, or raise an agent's capture setting.
- Reach the provider. Tokamak removes
X-Tokamak-Tagbefore forwarding the request.
Anyone holding a key can send any tag, so treat tags as what the caller says about the request, not as proof.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| A tag is missing from Analytics | It didn't match the tag pattern and was dropped, or the request carried more than 16 tags. With data capture on, check tags_rejected on the record. |
| A tag appears on captured records but not in Analytics | It is a data capture default tag. Send it with the request instead. |
| The tag filter won't load | The window is longer than 92 days. Choose Use last 90 days. |
| Tag rows add up to more than the total | Expected: a request with several tags counts under each. |
An agent's requests fail with 400 budget_tag_required | A per-value budget needs exactly one tag for its key. Read budget.reason. |
| Some captured sessions are missing | Only capture tagged requests is on and those requests carried no tag. |