https://api.telnyx.com/v2/llm_token_gateway and authenticates with a Telnyx account API key:
404.
Conventions
Response envelope
Success bodies wrap the resource indata. List responses add meta with pagination state. Every response carries an X-Request-ID correlation header; keep it when reporting a problem. Responses are Cache-Control: no-store.
Idempotency
EveryPOST, PATCH, PUT and DELETE requires an Idempotency-Key header. Keys are scoped to account, method and path and retained for 24 hours.
- The same key with the same body returns the original outcome.
- The same key with a different body returns
409with codeidempotency_conflict. - A key whose original request is still in progress returns
409withRetry-After. - A replayed token-key create returns
200with metadata only; the secret is never redisclosed. A provider-key secret is never returned, including on replay.
ETag preconditions
Every resource carries an integerversion, returned as a quoted ETag header on GET, create and update responses. PATCH and DELETE require that value in If-Match:
End-user caps use
PUT as a full replacement: send If-None-Match: * to create and the current If-Match to replace.
PATCH semantics
- A field omitted from a
PATCHbody is preserved. - A nullable field set to
nullis cleared (for examplemax_budget: nullremoves a group or user cap). On a token key, a null limit is reset to its maximum instead; see Token keys. - Policy changes apply to new admissions. They do not erase spend history or unresolved exposure, and a request already admitted under the old policy may finish.
- A change can take a short time to propagate. During that window the management response is already committed, but inference may return
503with codeenforcement_unavailable. Do not treat a pending change as permission to rely on the old policy.
Pagination
List endpoints acceptpage[number], page[size] (1 to 100) and page[snapshot].
meta.snapshot bound to the account and filters and valid for 15 minutes. To fetch later pages, increment page[number] and pass page[snapshot]=<meta.snapshot> with the same filters. A missing, expired or mismatched snapshot returns 409.
Token groups
A group defines the model allowlist and shared limits for the keys inside it.
Read-only fields on the response:
id, version, spend, reserved_spend, budget_started_at, resets_at, created_at, updated_at.
Deleting a group revokes its keys and removes user memberships; spend history is retained.
Token users
A user represents an application actor that may belong to more than one group. Limits set on the user aggregate across all of its keys in every group.
Removing a group from
token_group_ids while the user still holds active keys in that group returns 409; revoke those keys first. Deleting a user revokes its keys and retains spend history.
Token keys
A key is the credential an application presents to the inference plane.
Key limits differ from group and user limits: a key is never uncapped and cannot be denied with a zero limit. A value of 0 or above the maximum returns
400 with code limit_out_of_range; a negative, fractional or non-numeric value, or a budget with more than six decimal places, returns 400 with code invalid_request. On a blocked key, a null limit is kept until the key is unblocked. To deny a key, set blocked: true or revoke it. See Token key limits.
The create response is the only place data.token appears. It matches ^ltg_sk_[A-Za-z0-9_-]+$. Store it immediately; a lost token cannot be recovered, only replaced.
DELETE revokes the key. Acknowledged revocation blocks new admissions; requests already admitted may complete.
End users
An end-user cap applies an account-scoped budget or block to a caller-asserted identifier: the value an application sends as OpenAIuser or Anthropic metadata.user_id. The identifier is the resource ID.
PUT is a full replacement and returns 200 for both create and replace. Send If-None-Match: * to create and the current If-Match to replace; a missing precondition returns 428.
End-user identifiers are assertions made by whoever holds the token key. Bind them to authenticated users in a trusted backend; see End-user identity.
Provider keys
A provider key stores your own OpenAI or Anthropic secret for bring your own key. Attach it to groups throughprovider_key_ids.
Read-only fields on the response:
id, version, created_at, updated_at.
Provider keys cannot be edited; PATCH returns 405. To change a secret, create a new provider key, attach it to the groups, then delete the old one.
DELETE requires the current ETag in If-Match, like other deletes. Deleting a provider key detaches it from every group that references it; requests already in progress complete.
Usage
GET /spend/events and GET /spend/summary report the requests attributed to these resources. See Usage reporting.