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

Creating an identity
Create identities via the API or SDK before attaching them to requests.See the API Reference for the full parameter specification.
Budget control
Set a spending budget on an identity to cap how much a user or team can spend within a period. When the identity’s spend reaches the limit, subsequent requests return429 Too Many Requests until the period resets.
Available periods: Daily, Weekly, Monthly, Yearly.

Attaching an identity to a request
Pass the identity’sexternal_id in the identity.id field on any AI Gateway request. If no identity with that external_id exists, one is created automatically.
identity on each request:
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.