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.
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.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-OpenRouter-TitleandX-TitleX-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.
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
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.