The attribution channel
X-Toolken-Metadata
A JSON object of arbitrary key-value pairs. Each key becomes its own dimension. Use when you already have a structured object.
X-Toolken-Metadata-*
Flat-header shorthand. The suffix after
X-Toolken-Metadata- is lowercased and converted from kebab-case to snake_case as the key. Use for one-off keys.X-Toolken-Metadata-Agent: research-agent is the same as X-Toolken-Metadata: {"agent":"research-agent"}.
Send your first tagged request
Sending multiple keys as one JSON header
If you already have a structured object, send everything inX-Toolken-Metadata:
Common attribution keys
feature and customer_id are the two most common attribution keys. Set them via the standard metadata channel:
These are regular metadata keys, not reserved dimensions. They land in the same metadata store as any other
X-Toolken-Metadata-* header.
Attributing by agent
To see cost per agent, send the agent’s name as a metadata key:agent = billing-agent to the request record. In the dashboard, group Cost by agent to see one line per agent name. Use a short, stable value so the groupings stay readable across time.
Customer attribution: which channel wins
You can setcustomer_id in more than one way. If you set it multiple ways on the same request, the following precedence applies (highest first):
The simplest rule: set it one way. Only the priority matters if you end up setting it multiple ways.
What happens to untagged requests
An untagged request still lands in the dashboard. You see it by model and provider. Tags add resolution on top of that baseline.
Metadata constraints
Values must be scalars. Nested objects are not supported.
If
X-Toolken-Metadata is not valid JSON, it is silently ignored and the request still succeeds. The gateway does not return an error for malformed JSON — it simply skips the metadata. Verify your JSON is well-formed, since bad JSON silently drops your attribution.Next
Dimensions & Filtering
See every built-in dimension and how to group and filter by them.
Dashboard
The views you get out of the box once your requests are tagged.