Prerequisites
- A Telnyx API key from the portal.
- A model name from the available models. This guide uses
Kimi-K3. The inferenceGET /v1/modelsendpoint is scoped to a token key, so it cannot be used to discover models before a key exists. curl,jqanduuidgen(or another way to generate a UUID for theIdempotency-Keyheader).
1
Create a token group
A token group defines which models its keys may call and the limits they share. Keep Every mutation requires an
name and allowed_models are required. An empty allowed_models list permits no inference.This example sets a USD 10 budget per anchored one-day period and 60 requests per minute.data.id; the next step needs it and the group is what you retire at the end.Idempotency-Key. If a request times out, retry it with the same key and body; a new key starts a different operation and can create a second resource.2
Issue a token key
A token key is the credential the application uses. Store the token in your secret store now, then export it and the key ID for the remaining steps:To issue a key for a specific application user instead, first
token_user_id: null creates a service key owned by the group alone. Null allowed_models inherits the group’s list. Key limits that are omitted are set to their maximums: USD 1,000 lifetime budget, 6,000 requests and 10,000,000 tokens per minute. See Token key limits.POST /token_users with name and token_group_ids: [GROUP_ID], then pass the returned ID as token_user_id. Key ownership cannot be changed later; issue a replacement key instead.3
Discover models and make a request
The inference plane authenticates with the token key, not the account API key. Send a Chat Completions request with one of those models:Inference requests are not idempotent. The examples disable SDK retries so that a timeout cannot silently trigger a second billed request. Set
GET /v1/models returns only the models this key may use.max_tokens on every request: a request without it reserves the model’s full output allowance against budgets and tpm_limit. See Inference API for streaming and request size limits.4
Inspect usage
Spend events are queried over a half-open UTC date range When
[start_date, end_date) of at most 31 days, using ISO dates rather than timestamps. Filter by the key you just used:meta.has_more is true, request the next page[number] with the same filters and page[snapshot]=<meta.snapshot>. See Usage reporting for summaries grouped by group, user, key or end user.5
Revoke the key
DELETE requires the resource’s current ETag in If-Match. Read the key first; the metadata GET never reveals the token.204 means the key is revoked: new requests with that token are rejected, while requests already admitted may finish. Spend history is retained. On 412, the resource changed since the read; fetch it again rather than forcing the write.The group stays available for new keys. To retire it as well, DELETE /token_groups/{id} with a fresh ETag and idempotency key. Deleting a group cascades to its keys.Next: use your own provider key
To run OpenAI or Anthropic models on your own provider account, store the provider key once, attach it to a group and allow a bring-your-own-key model. Applications keep using the same token key. See Bring your own key.Next steps
Inference API
Available models, streaming, request limits and the supported request fields.
Management API
Users, end users, PATCH semantics and pagination.
Budgets and rate limits
What each limit does and how it is enforced.
Errors
Status codes and structured error codes on both planes.
Bring your own key
Attach your own OpenAI or Anthropic key to a group.