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

# Quickstart

## Overview

**AssemblyAI's LLM Gateway** is a unified, Open AI sdk compatible, interface that allows you to connect across multiple LLMs through a single API with access to automatic fallbacks.
Use as a standalone service or make use of our easy integration with AssemblyAI speech-to-text products.

We focus on text to text LLM providers with regional compliance, security, and ZDR. Additionally, we have optional
but tight integration with other AssemblyAI products for a more seamless experience.

## Endpoints

All endpoints share the same base URL, authentication and regions.

| Endpoint | Path | Use it to |
| - | - | - |
| [Chat completions](https://assemblyai.com/docs/llm-gateway/chat-completions.md) | `POST /v1/chat/completions` | Generate text from a prompt or a conversation |
| [Decisions](https://assemblyai.com/docs/llm-gateway/decisions.md) | `POST /v1/decisions` | Get typed, calibrated answers to questions about an input |
| [Speech understanding](https://assemblyai.com/docs/llm-gateway/api-reference/create-speech-understanding.md) | `POST /v1/understanding` | Translate, summarize, format or identify speakers in a transcript |
| [Models](https://assemblyai.com/docs/llm-gateway/api-reference/list-available-models.md) | `GET /v1/models` | List available models, with pricing and benchmarks |
| [Saved prompts](https://assemblyai.com/docs/llm-gateway/saved-prompts.md) | `/v1/prompts` | Store chat completions requests and run them by name |

## Quickstart

This example sends a request to the chat completions endpoint.

> [tab] Python - AssemblyAI SDK
>
> ```python highlight={6} theme={null}
> import assemblyai as aai
>
> aai.settings.api_key = "<YOUR_API_KEY>"
>
> gateway = aai.LLMGateway()
> completion = gateway.chat.completions.create(
>     model="qwen3.5-4b-32k-fast",
>     messages=[{"role": "user", "content": "What is the capital of France?"}],
>     max_tokens=1000,
> )
> print(completion.choices[0].message.content)
> print(completion.usage.total_tokens, completion.request_id)
> ```

> [tab] Python - HTTP
>
> ```python highlight={11} theme={null}
> import requests
>
> headers = {
>   "authorization": "<YOUR_API_KEY>"
> }
>
> response = requests.post(
>     "https://llm-gateway.assemblyai.com/v1/chat/completions",
>     headers = headers,
>     json = {
>         "model": "qwen3.5-4b-32k-fast",
>         "messages": [
>             {"role": "user", "content": "What is the capital of France?"}
>         ],
>         "max_tokens": 1000
>     }
> )
>
> result = response.json()
> print(result["choices"][0]["message"]["content"])
> ```

> [tab] JavaScript
>
> ```javascript {10} theme={null}
> const response = await fetch(
>   "https://llm-gateway.assemblyai.com/v1/chat/completions",
>   {
>     method: "POST",
>     headers: {
>       authorization: "<YOUR_API_KEY>",
>       "content-type": "application/json",
>     },
>     body: JSON.stringify({
>       model: "qwen3.5-4b-32k-fast",
>       messages: [{ role: "user", content: "What is the capital of France?" }],
>       max_tokens: 1000,
>     }),
>   }
> );
>
> const result = await response.json();
> console.log(result.choices[0].message.content);
> ```

> [tab] Python - Open AI SDK
>
> ```python {11} theme={null}
> from openai import OpenAI
> import openai.types.chat.chat_completion as types
>
> client = OpenAI(
>     base_url="https://llm-gateway.assemblyai.com/v1",
>     api_key="<YOUR_API_KEY>",
> )
>
> import json
>
> messages = [{"role": "user", "content": "What is the capital of france"}]
> response = client.chat.completions.create(model="qwen3.5-4b-32k-fast", messages=messages)
> print(response.choices[0].message.content)
> ```

Simply change the `model` parameter to use any of the available models listed in the [Available models](https://assemblyai.com/docs/llm-gateway/available-models) page.

> [!NOTE]
>
> Want to compare models side-by-side? Try the [Model Comparison
> Tool](https://assemblyai-model-comparison-llmgw.lovable.app/), a Lovable
> application, to test different LLM models and see how they perform.

## Non-standard LLM enhancements

Here are some bonus features LLM Gateway provides over other routing options.

### Reliability

* Automatic retries
  * 5xx responses will automatically be retried on our side by default
  * configure with [fallback\_config](https://assemblyai.com/docs/api-reference/llm-gateway/create-chat-completion.md#body-fallback-config)
* Model Fallbacks
  * Configure alternative models/providers in case a model isn't working
  * Even change the prompt and/or params to better suit a different model
  * See [docs](https://assemblyai.com/docs/llm-gateway/fallback.md)

### Chat completions

* Automatically apply LLM Gateway requests on each real-time STT turn for reduced E2E latency
  * see [docs](https://assemblyai.com/docs/guides/real_time_llm_gateway.md)
* Post Processing
  * Automatically apply post processing to the LLM response
  * Repair broken JSON in tool calls and structured output with `json-repair`
  * see [docs](https://assemblyai.com/docs/llm-gateway/structured-outputs.md#post-processing)
* Inject Transcript Text
  * Call LLM Gateway with a `transcript_id` and we will handle fetching and adding the transcript text to the LLM message.
  * Useful if you don't want to store the transcript.
  * see [docs](https://assemblyai.com/docs/llm-gateway/chat-completions.md#inject-a-transcript-by-id)

## Regional compliance

| Region | Base URL |
| - | - |
| US (default) | `https://llm-gateway.assemblyai.com/v1` |
| EU | `https://llm-gateway.eu.assemblyai.com/v1` |

> [!NOTE]
>
> The LLM Gateway is available in both US and EU regions. Use the EU endpoint to
> process your data in the European Union. Currently, Anthropic Claude
> and most Google Gemini models are supported in the EU (except where otherwise noted). OpenAI models are only
> available in the US region. See [Cloud Endpoints and Data
> Residency](https://assemblyai.com/docs/llm-gateway/cloud-endpoints-and-data-residency.md) for more details.

The LLM Gateway provides access to 25+ models across major AI providers. Chat completions supports:

* **Basic Chat Completions** - Simple request/response interactions
* **Streamed Responses** - Stream output as it's generated (OpenAI models)
* **Multi-turn Conversations** - Maintain context across multiple exchanges
* **Structured Outputs** - Constrain responses to a specific JSON schema
* **Tool/Function Calling** - Enable models to execute custom functions
* **Agentic Workflows** - Multi-step reasoning with automatic tool chaining
* **Unified Interface** - One API for Claude, GPT, Gemini, Qwen, Kimi, and more
* **Post-processing** - Automatically repair malformed JSON responses with built-in JSON repair

### Global model routing

If your request/needs do not require region locked routing for either latency or compliance, you can opt to set the
`model_region` to `global` in the api request body for a discount.

See model [pricing](https://www.assemblyai.com/pricing) for which models have global discounts.

## Rate limits

LLM Gateway is rate limited per model, measured as requests within a 60-second window. For account-specific limits and how to request a higher limit, see [Rate limits](https://assemblyai.com/docs/llm-gateway/rate-limits.md).

## Logging and troubleshooting

Every LLM Gateway response includes a `request_id` field — a unique identifier for that request. Persist it (along with the model, the API region, and a timestamp) for every call you make, not just when something goes wrong. If you contact [support@assemblyai.com](mailto:support@assemblyai.com) about a specific request (latency spikes, unexpected output, rate-limit errors, content moderation surprises), this ID lets us locate the exact request in our logs immediately.

We recommend logging, at minimum:

* `request_id` from the response body
* The `model` parameter used
* The API region (US: `llm-gateway.assemblyai.com`, EU: `llm-gateway.eu.assemblyai.com`)
* A timestamp for when the request was sent
* The full error response body when a non-2xx status code is returned

For details on debugging specific status codes (400/401/403/429/5xx) and what information to include when filing a support request, see the [Troubleshooting](https://assemblyai.com/docs/llm-gateway/troubleshooting.md) page.

## Next steps

Models and reliability:

* [Choose a model](https://assemblyai.com/docs/llm-gateway/choose-a-model.md) - Pick the best model for your use case using benchmark data
* [Model fallbacks](https://assemblyai.com/docs/llm-gateway/fallback.md) - Retry failed requests on alternative models
* [Prompt Caching](https://assemblyai.com/docs/llm-gateway/prompt-caching.md) - Save money on similar calls with prompt caching

Chat completions:

* [Basic Chat Completions](https://assemblyai.com/docs/llm-gateway/chat-completions.md) - Learn how to send simple messages and receive responses
* [Multi-turn Conversations](https://assemblyai.com/docs/llm-gateway/conversations.md) - Maintain context across multiple exchanges
* [Structured Outputs](https://assemblyai.com/docs/llm-gateway/structured-outputs.md) - Constrain model responses to follow a specific JSON schema
* [Tool Calling](https://assemblyai.com/docs/llm-gateway/tool-calling.md) - Enable models to execute custom functions
* [Agentic Workflows](https://assemblyai.com/docs/llm-gateway/agentic-workflows.md) - Build multi-step reasoning applications
* [Post-processing](https://assemblyai.com/docs/llm-gateway/structured-outputs.md#post-processing) - Automatically repair malformed JSON in model responses

> [!NOTE]
>
> The LLM Gateway API is separate from the Speech-to-Text and Speech
> Understanding APIs. It provides a unified interface to work with large
> language models across multiple providers.
