LiveKit docs › Partner spotlight › OpenAI › OpenAI LLM

---

# OpenAI LLM models

> How to use OpenAI models with LiveKit Agents.

- **[Use in Agent Builder](https://cloud.livekit.io/projects/p_/agents/builder/new?llm=openai%2Fgpt-4.1)**: Create a new agent in your browser using openai/gpt-4.1

## Overview

OpenAI models are available in LiveKit Agents through [LiveKit Inference](https://docs.livekit.io/agents/models/inference.md) and the [OpenAI plugin](#plugin). With LiveKit Inference, your agent runs on LiveKit's infrastructure to minimize latency. No separate provider API key is required, and usage and rate limits are managed through LiveKit Cloud. Use the plugin instead if you want to manage your own billing and rate limits. Pricing for LiveKit Inference is available on the [pricing page](https://livekit.com/pricing/inference#proprietary-llms).

## LiveKit Inference

Use [LiveKit Inference](https://docs.livekit.io/agents/models/inference.md) to access OpenAI models without a separate OpenAI API key.

| Model name | Model ID | Providers |
| ---------- | -------- | -------- |
| GPT-4.1 | `openai/gpt-4.1` | `azure`, `openai` |
| GPT-4.1 mini | `openai/gpt-4.1-mini` | `azure`, `openai` |
| GPT-4.1 nano | `openai/gpt-4.1-nano` | `azure`, `openai` |
| GPT-4o | `openai/gpt-4o` | `azure`, `openai` |
| GPT-4o mini | `openai/gpt-4o-mini` | `azure`, `openai` |
| GPT-5 | `openai/gpt-5` | `azure`, `openai` |
| GPT-5 mini | `openai/gpt-5-mini` | `azure`, `openai` |
| GPT-5 nano | `openai/gpt-5-nano` | `azure`, `openai` |
| GPT-5.1 | `openai/gpt-5.1` | `azure`, `openai` |
| GPT-5.1 Chat | `openai/gpt-5.1-chat-latest` | `azure`, `openai` |
| GPT-5.2 | `openai/gpt-5.2` | `azure`, `openai` |
| GPT-5.2 Chat | `openai/gpt-5.2-chat-latest` | `azure`, `openai` |
| GPT-5.3 Chat | `openai/gpt-5.3-chat-latest` | `azure`, `openai` |
| GPT-5.4 | `openai/gpt-5.4` | `azure`, `openai` |
| GPT-5.4 mini | `openai/gpt-5.4-mini` | `openai` |
| GPT-5.4 nano | `openai/gpt-5.4-nano` | `openai` |
| GPT-5.5 | `openai/gpt-5.5` | `azure`, `openai` |
| ChatGPT Latest | `openai/chat-latest` | `openai` |
| GPT OSS 120B | `openai/gpt-oss-120b` | `baseten`, (Cerebras coming soon), `groq` |

### Usage

To use OpenAI, use the `LLM` class from the `inference` module. You can use this LLM in the [Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md):

**Python**:

```python
from livekit.agents import AgentSession, inference

session = AgentSession(
    llm=inference.LLM(
        model="openai/gpt-5-mini", 
        provider="openai",
        extra_kwargs={
            "reasoning_effort": "low"
        }
    ),
    # ... tts, stt, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { AgentSession, inference } from '@livekit/agents';

const session = new AgentSession({
    llm: new inference.LLM({ 
        model: "openai/gpt-5-mini", 
        provider: "openai",
        modelOptions: { 
            reasoning_effort: "low" 
        }
    }),
    // ... tts, stt, vad, turnHandling, etc.
});

```

### Parameters

The following are parameters for configuring OpenAI models with LiveKit Inference. For model behavior parameters like `temperature` and `reasoning_effort`, see [model parameters](#model-parameters).

- **`model`** _(string)_: The model to use for the LLM. Must be a model from OpenAI. See model IDs in the [models list](#inference).

- **`provider`** _(string)_: Must be `openai` to use OpenAI models and other parameters.

- **`extra_kwargs`** _(dict)_ (optional): Additional parameters to pass to the OpenAI Chat Completions API. See [model parameters](#model-parameters) for supported fields.

In Node.js this parameter is called `modelOptions`.

#### Model parameters

Pass the following parameters inside `extra_kwargs` (Python) or `modelOptions` (Node.js). For more details about each parameter in the list, see [Inference parameters](https://docs.livekit.io/reference/agents/inference-llm-parameters.md).

| Parameter | Type | Default | Notes |
| temperature | `float` | `1` | Controls the randomness of the model's output. Valid range: `0`-`2`. Not supported by reasoning models. |
| top_p | `float` | `1` | Alternative to `temperature`. Valid range: `0`-`1`. Not supported by reasoning models. |
| max_tokens | `int` |  | Maximum tokens to generate. Use `max_completion_tokens` for newer models. |
| max_completion_tokens | `int` |  | Maximum tokens to generate, including reasoning tokens. Preferred over `max_tokens` for newer models. |
| reasoning_effort | `"low" | "medium" | "high"` |  | Controls reasoning depth. Only supported by reasoning models (o1, o3, o4, gpt-5 prefixes). |
| frequency_penalty | `float` | `0` | Reduces the model's likelihood to repeat the same line verbatim. Valid range: `-2.0`-`2.0`. Not supported by reasoning models. |
| presence_penalty | `float` | `0` | Increases the model's likelihood to talk about new topics. Valid range: `-2.0`-`2.0`. Not supported by reasoning models. |
| seed | `int` |  | Enables deterministic sampling. The system makes a best effort to return the same result for identical requests. |
| stop | `str | list[str]` |  | Sequences that stop generation. Up to 4 sequences. |
| n | `int` |  | Number of completions to generate. Not supported by reasoning models. |
| logprobs | `bool` |  | Returns log probabilities of each output token. Not supported by reasoning models. |
| top_logprobs | `int` |  | Number of most likely tokens to return at each position. Valid range: `0`-`20`. Requires `logprobs: true`. Not supported by reasoning models. |
| logit_bias | `dict[str, int]` |  | Adjusts likelihood of specified tokens appearing in the output. Not supported by reasoning models. |
| parallel_tool_calls | `bool` |  | Whether the model can make multiple tool calls in a single response. |
| tool_choice | `ToolChoice | Literal['auto', 'required', 'none']` | `"auto"` | Controls how the model uses tools. |

### String descriptors

As a shortcut, you can also pass a [model ID](#inference) descriptor string directly to the `llm` argument in your `AgentSession`:

**Python**:

```python
from livekit.agents import AgentSession

session = AgentSession(
    llm="openai/gpt-5.3-chat-latest",
    # ... tts, stt, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { AgentSession } from '@livekit/agents';

const session = new AgentSession({
    llm: "openai/gpt-5.3-chat-latest",
    // ... tts, stt, vad, turnHandling, etc.
});

```

## Plugin

LiveKit's plugin support for OpenAI lets you connect directly to OpenAI's API with your own API key.

Available in:
- [x] Node.js
- [x] Python

> ℹ️ **OpenAI Responses API (Recommended)**
> 
> The OpenAI plugin supports the **Responses API**, which provides support for OpenAI's provider tools (`WebSearch`, `FileSearch`, `CodeInterpreter`) and is the recommended approach for direct OpenAI usage. Use `openai.responses.LLM()` to access the Responses API. The Chat Completions API is available via `openai.LLM()` and is used for OpenAI-compatible endpoints (like `openai.LLM.with_deepseek()`). See [API modes](#api-modes) for more information.

### Installation

Install the plugin:

**Python**:

```shell
uv add "livekit-agents[openai]~=1.5"

```

---

**Node.js**:

```shell
pnpm add @livekit/agents-plugin-openai@1.x

```

### Authentication

The OpenAI plugin requires an [OpenAI API key](https://platform.openai.com/api-keys).

Set `OPENAI_API_KEY` in your `.env` file.

### Usage

Use OpenAI within an `AgentSession` or as a standalone LLM service. For example, you can use this LLM in the [Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md).

**Python**:

```python
from livekit.plugins import openai

# Use Responses API (recommended)
session = AgentSession(
    llm=openai.responses.LLM(
        model="gpt-4.1"
    ),
    # ... tts, stt, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { voice } from '@livekit/agents';
import * as openai from '@livekit/agents-plugin-openai';

const session = new voice.AgentSession({
    llm: new openai.responses.LLM({
        model: "gpt-4.1"
    }),
    // ... tts, stt, vad, turnHandling, etc.
});

```

### API modes

The OpenAI plugin supports two API modes: **Responses API** and **Chat Completions API**.

#### Responses API (Recommended)

The Responses API is the recommended mode. It provides:

- Support for OpenAI's provider tools (`WebSearch`, `FileSearch`, `CodeInterpreter`)
- Better performance and features
- Access to the latest OpenAI capabilities
- Lower costs

Use `openai.responses.LLM()` to access the Responses API:

**Python**:

```python
from livekit.plugins import openai

# Use Responses API (recommended)
session = AgentSession(
    llm=openai.responses.LLM(model="gpt-4.1"),
    # ... tts, stt, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { voice } from '@livekit/agents';
import * as openai from '@livekit/agents-plugin-openai';

// Use Responses API (recommended)
const session = new voice.AgentSession({
    llm: new openai.responses.LLM({ model: "gpt-4.1" }),
    // ... tts, stt, vad, turn_detection, etc.
});

```

#### Chat Completions API

The Chat Completions API is available via `openai.LLM()`. This API mode is used for:

- **OpenAI-compatible endpoints**: Providers like Cerebras, Fireworks, Groq, etc. use `openai.LLM.with_*()` methods which rely on the Chat Completions API format (see [OpenAI-compatible endpoints](#openai-compatible-endpoints))
- **Legacy code compatibility**: Existing code that uses `openai.LLM()` directly

> ℹ️ **For direct OpenAI usage**
> 
> For direct OpenAI platform usage, use `openai.responses.LLM()` instead of `openai.LLM()`. The Responses API provides better features and performance.

To use Chat Completions mode directly with OpenAI (not recommended for new projects):

**Python**:

```python
from livekit.plugins import openai

# Chat Completions API (use openai.responses.LLM() for new projects)
session = AgentSession(
    llm=openai.LLM(model="gpt-4.1"),
    # ... tts, stt, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { voice } from '@livekit/agents';
import * as openai from '@livekit/agents-plugin-openai';

// Chat Completions API (use openai.responses.LLM() for new projects)
const session = new voice.AgentSession({
    llm: new openai.LLM({ model: "gpt-4.1" }),
    // ... tts, stt, vad, turnHandling, etc.
});

```

#### OpenAI-compatible endpoints

When using OpenAI-compatible endpoints with providers using Chat Completions mode, you should use `openai.LLM()` with the provider's `with_*()` method. These providers include:

- Fireworks: `openai.LLM.with_fireworks()`
- Groq: `openai.LLM.with_groq()`
- Perplexity: `openai.LLM.with_perplexity()`
- Telnyx: `openai.LLM.with_telnyx()`
- Together AI: `openai.LLM.with_together()`
- xAI: `openai.LLM.with_x_ai()`
- DeepSeek: `openai.LLM.with_deepseek()`

These providers are built on the Chat Completions API format, so they use `openai.LLM()` (not `openai.responses.LLM()`). The `with_*()` methods automatically configure the correct API mode. See the individual provider documentation for specific usage examples.

### Parameters

This section describes some of the available parameters. See the plugin reference links in the [Additional resources](#additional-resources) section for a complete list of all available parameters.

- **`model`** _(string)_ (optional) - Default: `gpt-4.1`: The model to use for the LLM. For more information, see the [OpenAI documentation](https://developers.openai.com/docs/models).

- **`temperature`** _(float)_ (optional) - Default: `0.8`: Sampling temperature that controls the randomness of the model's output. Higher values make the output more random, while lower values make it more focused and deterministic. Range of valid values can vary by model.

Valid values are between `0` and `2`.

- **`tool_choice`** _(ToolChoice | Literal['auto', 'required', 'none'])_ (optional) - Default: `auto`: Controls how the model uses tools. String options are as follows:

- `'auto'`: Let the model decide.
- `'required'`: Force tool usage.
- `'none'`: Disable tool usage.

- **`verbosity`** _(Literal['low', 'medium', 'high'])_ (optional): Constrains the verbosity of the model's response. Lower values produce more concise responses while higher values produce more verbose responses.

- **`service_tier`** _("auto" | "default" | "flex" | "scale" | "priority")_ (optional): Specifies the processing tier for the request. Routes the call to a specific OpenAI capacity and billing tier.

In Node.js this parameter is called `serviceTier`.

- **`timeout`** _(httpx.Timeout | None)_ (optional) - Default: `httpx.Timeout(connect=15.0, read=5.0, write=5.0, pool=5.0)`: Available in:
- [ ] Node.js
- [x] Python

Configures connect, read, write, and pool timeouts on the underlying HTTP client. Ignored when `client` parameter is set.

### Provider tools

Available in:
- [ ] Node.js
- [x] Python

OpenAI supports the following [provider tools](https://docs.livekit.io/agents/logic/tools.md#provider-tools) that enable the model to use built-in capabilities executed on the model server. These tools can be used alongside function tools defined in your agent's codebase. Provider tools require the [Responses API](#responses-api).

| Tool | Description | Parameters |
| `WebSearch` | Search the web for up-to-date information. | `search_context_size` (`low`, `medium`, `high`), `user_location`, `filters` |
| `FileSearch` | Search uploaded document collections via [vector stores](https://developers.openai.com/docs/guides/tools-file-search). | `vector_store_ids` (required), `filters`, `max_num_results`, `ranking_options` |
| `CodeInterpreter` | Execute Python code in a sandboxed environment. | `container` |

```python
from livekit.plugins import openai

agent = MyAgent(
    llm=openai.responses.LLM(model="gpt-4.1"),
    tools=[openai.tools.WebSearch()],  # replace with any supported provider tool
)

```

## Additional resources

The following resources provide more information about using OpenAI with LiveKit Agents.

- **[OpenAI docs](https://developers.openai.com/docs)**: OpenAI platform documentation.

- **[Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md)**: Get started with LiveKit Agents and OpenAI.

- **[OpenAI ecosystem overview](https://docs.livekit.io/agents/integrations/openai.md)**: Overview of the entire OpenAI and LiveKit Agents integration.

---

This document was rendered at 2026-06-07T11:35:24.489Z.
For the latest version of this document, see [https://docs.livekit.io/agents/models/llm/openai.md](https://docs.livekit.io/agents/models/llm/openai.md).

To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).