Request Tagging And Cost Allocation
Attach AWS style tags and OpenRouter attribution metadata to LLM requests without adding them to model prompts or provider payloads.Attach AWS style tags and attribution metadata to LLM requests.
Up to 1 million free tokens. No card required.
Attribute every request without putting metadata in the prompt.
Attach up to 50 AWS style tags to Chat Completions, Responses, Messages, or Embeddings. TrustedRouter stores the effective tag set with generation metadata and keeps it out of provider request bodies.
Use tags for environment, application, team, project, cost center, customer tier, or any other non sensitive business dimension.
from openai import OpenAI
client = OpenAI(
api_key="sk-tr-v1-...",
base_url="https://api-aws.trustedrouter.com/v1"
)
response = client.chat.completions.create(
model="trustedrouter/zdr",
messages=[{
"role": "user",
"content": "Summarize this contract."
}],
user="user_123",
extra_body={
"session_id": "matter_456",
"tags": {
"environment": "production",
"team": "legal",
"cost-center": "legal-01"
}
}
)
The contract
A string map.
Send tags as a JSON object. Keys and values are case sensitive strings. Empty values are allowed. Empty keys are not.
Fifty tags per request.
Keys may contain 128 Unicode characters. Values may contain 256. The effective compact map is capped at 4 KiB.
A portable AWS style set.
Use Unicode letters, numbers, and spaces plus + - = . _ : / @. The prefixes aws: and trustedrouter: are reserved.
Set defaults once on an API key.
POST /v1/keys and PATCH /v1/keys/{hash} accept the same tag map. Request tags override key defaults. The merged result is frozen when TrustedRouter authorizes the request, so retries and later key edits cannot rewrite historical attribution.
curl https://trustedrouter.com/v1/keys \
-H "Authorization: Bearer $MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "production-legal",
"tags": {
"environment": "production",
"team": "legal"
}
}'
OpenRouter attribution compatibility
Body fields
useridentifies a stable end usersession_idgroups related requeststracecarries Broadcast metadatatagsallocates TrustedRouter usage and cost
Headers
X-Session-IdHTTP-RefererX-NYTE-Title,X-OpenRouter-TitleandX-Title, in that orderX-OpenRouter-CategoriesX-OpenRouter-Metadata: enabledopts into router metadata
When enabled for Chat Completions or Responses, TrustedRouter returns route metadata in openrouter_metadata. It never includes credentials, tags, trace contents, prompts, or outputs.
gateway_region identifies the TrustedRouter gateway, not where the upstream provider ran inference. The provider's serving location is separate in usage.inference_location.serving_region and remains null when not reported.
Filter or group activity by one tag.
Use exact matches for cost allocation. Tag filters operate on a bounded recent/date scan and the response reports whether that scan was truncated. Tag values are private to the workspace and are never included in public provider rankings.
# Individual generations
GET /v1/activity?group_by=none&tag_key=team&tag_value=legal
# Daily model and provider totals split by tag value
GET /v1/activity?group_by=tag:team
See tags on the Observability page.
The Observability page shows each request's tags as chips in the request list. Click a chip, or pick a key and a value under Tags, to filter the list to that tag. The filter stays when you change the range.
The Tags panel breaks requests, cost, tokens, and median generation time down by the values of one key. It counts every request in the selected range, not a sample. The 50 most expensive values each get a row, the rest are combined into Other, and requests without the key are shown as Untagged. Generation time is how long the server took to produce the response, not the latency your client saw. A request that fails before it produces a generation has nothing to tag, so the panel counts completed generations only.
A key with about 500,000 or more distinct values in the range, such as a request id, is not broken down. You can still filter by its values. Whenever some values are grouped in Other, which 50 are shown is a best effort for a busy key, and the panel says so. The totals in each row are exact either way.
Break down by: team Range: 7d
Value Requests Cost Median generation time
search 1,204 $18.40 820 ms
ads 311 $4.12 640 ms
Untagged 87 $0.95 910 ms
Tags are router metadata, not model input.
The attested gateway validates tags before authorization. Provider adapters build separate upstream payloads that omit tags, trace metadata, session identifiers, and app attribution. Generation records contain the effective tags but never the prompt or model output.