> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Gateway Overview

> Give applications scoped, budgeted access to language models through OpenAI- and Anthropic-compatible APIs, with Telnyx-hosted models or your own provider keys. Create groups, users and token keys, apply model allowlists, budgets and rate limits, then inspect usage per resource.

AI Gateway issues **scoped inference credentials** for applications. Instead of sharing a Telnyx account API key with every service, create a token group, issue a token key inside it and hand that key to the application. The gateway enforces the model allowlist, budget and rate limits attached to the key, and records every request in a usage ledger attributed to the key, its user, its group and the end user it served.

Applications call the gateway with the official OpenAI SDKs by changing the base URL and the API key. No request rewriting is required. Anthropic models used with your own Anthropic key can also be called with the official Anthropic SDKs.

## Capabilities

| Capability           | Behavior                                                                                                                                               |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Token groups         | Define model access, group budgets and rate limits.                                                                                                    |
| Token users          | Associate an application actor with one or more groups; aggregate its limits across all of its keys.                                                   |
| Token keys           | Issue scoped inference credentials for a user or a service; narrow model access, set limits and expiry, revoke access.                                 |
| End users            | Apply account-scoped budget caps and blocks to a caller-asserted application user identifier.                                                          |
| Provider keys (BYOK) | Store an OpenAI or Anthropic key once and attach it to groups; your provider bills requests on bring-your-own-key models.                              |
| Inference            | OpenAI Chat Completions, Anthropic Messages (Anthropic BYOK models), [model discovery](/docs/inference/ai-gateway/inference-api#models) and streaming. |
| Usage                | Durable request accounting with reservations, corrections and dimensional summaries.                                                                   |

## Two planes, two credentials

The gateway exposes a **management plane** for provisioning and reporting, and an **inference plane** that applications call. They use different hostnames and different credentials.

| Plane                                                  | Base URL                                      | Credential                                                          |
| ------------------------------------------------------ | --------------------------------------------- | ------------------------------------------------------------------- |
| Management                                             | `https://api.telnyx.com/v2/llm_token_gateway` | Telnyx account API key: `Authorization: Bearer $TELNYX_API_KEY`     |
| OpenAI-compatible inference                            | `https://llm.telnyx.com/v1`                   | AI Gateway token key: `Authorization: Bearer $AI_GATEWAY_TOKEN_KEY` |
| Anthropic-compatible inference (Anthropic BYOK models) | `https://llm.telnyx.com` as the SDK base URL  | Same token key via `x-api-key`; the SDK appends `/v1/messages`      |

Token keys start with `ltg_sk_`. The inference plane rejects Telnyx account API keys and provider secrets; the management plane rejects token keys. Keep every credential in a trusted backend or secret store, never in browser code, source control or logs.

## How it works

1. **Create a token group** with an explicit `allowed_models` list and optional budget and rate limits. To use your own OpenAI or Anthropic account, attach a [provider key](/docs/inference/ai-gateway/byok) to the group.
2. **Issue a token key** in that group, optionally bound to a token user. The secret is returned once, on the create response.
3. **Call models** from the application with an OpenAI SDK (or, for Anthropic BYOK models, an Anthropic SDK) pointed at the inference base URL and authenticated with the token key.
4. **Inspect usage** with the spend events and spend summary endpoints, filtered by group, user, key or end user.
5. **Revoke** the key when the application no longer needs it. New admissions stop immediately; spend history is retained.

Telnyx owns authorization, admission, revocation and the authoritative usage ledger. Applications never hold provider credentials or configure model providers directly.

Usage of Telnyx-hosted models is billed to your Telnyx account at standard Telnyx AI Inference pricing for each model. Requests on bring-your-own-key models are billed by your provider on your provider account. Budgets and reported `cost` values use a flat reference rate for enforcement and attribution; see [Budgets](/docs/inference/ai-gateway/controls#budgets).

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" href="/docs/inference/ai-gateway/quickstart">
    Create a group, issue a token key, make a request and revoke the key.
  </Card>

  <Card title="Inference API" href="/docs/inference/ai-gateway/inference-api">
    Telnyx-hosted and BYOK models, OpenAI and Anthropic SDK configuration, streaming, request limits and supported fields.
  </Card>

  <Card title="Management API" href="/docs/inference/ai-gateway/management-api">
    Groups, users, keys, end users and provider keys, with idempotency and ETag rules.
  </Card>

  <Card title="Budgets and rate limits" href="/docs/inference/ai-gateway/controls">
    How each control is enforced and what happens at the limit.
  </Card>

  <Card title="Bring your own key" href="/docs/inference/ai-gateway/byok">
    Use your own OpenAI or Anthropic key; your provider bills those requests.
  </Card>

  <Card title="Usage reporting" href="/docs/inference/ai-gateway/usage">
    Spend events, dimensional summaries and snapshot pagination.
  </Card>

  <Card title="Errors" href="/docs/inference/ai-gateway/errors">
    Status codes, structured error codes and how to handle them.
  </Card>
</CardGroup>
