Skip to main content
Use Cases
Name each request so cost and performance slice by product, feature, or environment.
Attach an Identity so spend, latency, and error rates attribute to a user, team, or client, with optional per-identity budgets.
Tag each turn with a Thread ID so the full conversation groups together in observability.
Attach key-value metadata, such as tier, channel, or feature flag, and filter traces by those fields.

Overview

Every AI Gateway request can carry context through several mechanisms:
  • name: marks the app or service
  • identity: marks the end user or tenant
  • thread: groups a conversation
  • metadata: carries business context
  • tags: adds grouping labels
Each mechanism answers one question and surfaces through its own channel. Use the decision table below to pick the mechanism for a given question. variables also travel with the request, but fill prompt templates instead of describing the request. The how-to for each mechanism lives in App Tracking, Identities, and Thread Management; the span attribute reference is in Metadata.

Which mechanism to use

Quick Start

Send one request with all five mechanisms attached.

Configuration

On /v2/router/chat/completions:
  • metadata is limited to 16 key-value pairs with keys up to 64 characters and values up to 512 characters
  • thread, identity, and tags are passed under the orq object (orq.thread, orq.identity, orq.tags)
  • name is passed at the top level

Where each mechanism surfaces

Filter names follow the Traces page. Custom metadata surfaces as metadata.<key> span attributes on router requests, and as an orq.metadata JSON attribute on agent and gateway-client spans. See Metadata for the full reference.

Best Practices

  • Keep app names low-cardinality: Use a small fixed set of app names (around 50 per workspace) with consistent patterns such as Service-Environment. Avoid timestamps or dynamic values, which fragment analytics.
  • Use a fixed metadata key set: Define a small set of keys (customer_tier, channel, region) and reuse them. High-cardinality keys, such as request IDs or timestamps, defeat filtering and increase storage.
  • Thread IDs: Use UUIDs or composite keys such as user-{userId}-{sessionId} to avoid collisions across sessions.
  • Identity IDs: Use predictable patterns such as user-{userId} or tenant-{tenantId} so identities stay consistent across requests.
  • One mechanism per question: If the value describes the app, use name; if it describes the user, use identity; if it is business context, use metadata.

What not to store in request metadata

  • PII: Do not put emails, phone numbers, or personal data in metadata, name, or tags; they persist on stored traces. To keep sensitive values out of stored traces, include "metadata" in security.mask, or enable PII Redaction.
  • Secrets: Pass tokens and keys as template variables with {"secret": true, "value": "..."} so they are redacted from traces. See Run Agents for the variable reference.