- a User
- a Team
- a Project
- a Client

- Per-user cost attribution and cross-charging to tenants or customers.
- Enforcing per-user rate limits to prevent abuse.
- Identifying which users generate the most load or cost.
- Linking LLM usage to existing user analytics for cohort analysis.
Creating an identity
AI Gateway
- API / SDK
In the AI Gateway sidebar, go to Identities and click New Identity. Fill in the external ID and any optional fields (display name, email, metadata), then click Create.The identity is available immediately and can be attached to requests using its external ID.
Attaching an identity to a request
Every AI Gateway request can be attributed to a specific user, team, or client. The gateway checks each of the following sources in order and uses the first match found:| Order | Source | Effect |
|---|---|---|
| 1 | identity object in the request body | Tags the request and upserts the identity record (name, email, metadata) |
| 2 | X-ORQ-IDENTITY-ID request header | Tags the request only; does not update the identity record |
| 3 | API key owner | Tags the request only; applies automatically when the key is user-owned |
- Body
- X-ORQ-IDENTITY-ID Header
- API Key Owner
Pass the identity’s Orq SDKOpenAI SDK
external_id in the identity.id field on any AI Gateway request. If no identity with that external_id exists, one is created automatically; if it does exist, its record is updated with any display_name, email, or metadata provided.The
identityId / identity_id constructor option was removed in SDK v4.10.0. Pass identity on each request instead.Retrieving an identity via the API
Once an identity is in use, fetch its full record at any time using its_id (ULID) or external_id.
See the API Reference for the full parameter and response specification.
Listing identities with metrics
Passinclude_metrics=true to retrieve 30-day usage metrics for each identity.
metrics object covering the last 30 days:
| Field | Description |
|---|---|
total_cost | Total spend in USD |
total_tokens | Total tokens consumed |
total_requests | Total number of requests |
error_rate | Ratio of failed requests (e.g. 0.33 = 33% errors) |
See the API Reference for pagination, search, and tag filtering parameters.
Identity field reference
Fields accepted on theidentity object for any AI Gateway request:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique identity identifier (max 255 characters) |
display_name | string | No | Human-readable name |
email | string | No | Email address |
metadata | object[] | No | Array of objects with custom key-value pairs (max 20 fields) |
logo_url | string | No | URL to a profile image |
tags | string[] | No | Classification tags for segmentation (max 10) |
Best practices
- Consistent IDs: Use predictable identity ID patterns (e.g.
user-{userId},tenant-{orgId}-{userId}) across the application. - Essential metadata only: Include only relevant metadata fields to minimize payload size.
- Tag strategy: Use tags for filtering and segmentation rather than storing detailed data.
- Privacy compliance: Ensure identity data handling meets applicable privacy requirements.
- Validation: Validate
idformat and length before sending requests.
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Identity not appearing in analytics | Missing or invalid identity.id | Ensure identity.id is provided and non-empty |
| Duplicate identities in the dashboard | Inconsistent ID format across requests | Standardize identity ID generation in one place |