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

# OpenAI LLM

[OpenAI](https://openai.com) provides industry-leading language models. The plugin supports the **Responses API** (for GPT-5+) and **ChatCompletionsLLM** (any OpenAI-compatible API). Requires separate STT/TTS.

<Info>
  Vision Agents requires a [Stream](https://getstream.io/try-for-free/) account
  for real-time transport. Most providers offer free tiers to get started.
</Info>

<Tip>
  OpenAI also provides [Realtime speech-to-speech](/integrations/realtime/openai) and [text-to-speech](/integrations/tts/openai).
</Tip>

## Installation

```sh theme={null}
uv add "vision-agents[openai]"
```

## LLM (Responses API)

Uses the Responses API (default for GPT-5+).

```python theme={null}
from vision_agents.core import Agent, User
from vision_agents.plugins import openai, deepgram, getstream

agent = Agent(
    edge=getstream.Edge(),
    agent_user=User(name="Assistant", id="agent"),
    instructions="You are a helpful assistant.",
    llm=openai.LLM(model="gpt-5.4"),
    stt=deepgram.STT(),
    tts=openai.TTS(),
)
```

| Name              | Type  | Default     | Description                                    |
| ----------------- | ----- | ----------- | ---------------------------------------------- |
| `model`           | `str` | `"gpt-5.4"` | Model (e.g., `"gpt-5.4"`)                      |
| `api_key`         | `str` | `None`      | API key (defaults to `OPENAI_API_KEY` env var) |
| `base_url`        | `str` | `None`      | Custom API endpoint                            |
| `max_tool_rounds` | `int` | `3`         | Maximum tool-call rounds per response          |

## ChatCompletionsLLM

Works with any OpenAI-compatible API (Together AI, Fireworks, DeepSeek, etc.).

```python theme={null}
from vision_agents.plugins import openai

llm = openai.ChatCompletionsLLM(
    model="deepseek-chat",
    base_url="https://api.deepseek.com",
    api_key="your_api_key"
)
```

| Name               | Type  | Default | Description                                    |
| ------------------ | ----- | ------- | ---------------------------------------------- |
| `model`            | `str` | --      | Model identifier                               |
| `api_key`          | `str` | `None`  | API key (defaults to `OPENAI_API_KEY` env var) |
| `base_url`         | `str` | `None`  | Custom API endpoint                            |
| `tools_max_rounds` | `int` | `3`     | Maximum tool-call rounds per response          |

## Function Calling

```python theme={null}
@agent.llm.register_function(description="Get weather for a location")
async def get_weather(location: str) -> dict:
    return {"temperature": "72°F", "condition": "Sunny"}
```

See the [Function Calling guide](/guides/mcp-tool-calling) for details.

## Events

The OpenAI plugin emits a low-level event for raw stream data. Most developers should use the core events ([LLMResponseCompletedEvent](/reference/events-reference#llmresponsecompletedevent), [RealtimeUserSpeechTranscriptionEvent](/reference/events-reference#realtimeuserspeechtranscriptionevent), etc.) instead.

```python theme={null}
from vision_agents.plugins.openai.events import OpenAIStreamEvent

@agent.events.subscribe
async def on_openai_stream(event: OpenAIStreamEvent):
    # Access raw OpenAI stream data
    print(f"Raw event: {event.event_type}, {event.event_data}")
```

## Next Steps

<CardGroup cols={2}>
  <Card title="OpenAI Realtime" icon="bolt" href="/integrations/realtime/openai">
    Speech-to-speech over WebRTC
  </Card>

  <Card title="OpenAI TTS" icon="volume-high" href="/integrations/tts/openai">
    Text-to-speech synthesis
  </Card>
</CardGroup>
