acceptable-bird-64568
03/04/2026, 4:48 PMtall-airline-16756
03/04/2026, 4:48 PMtall-airline-16756
03/04/2026, 4:48 PMopenai.responses.LLM() in an AgentSession. This class uses the OpenAI Responses API (which communicates over WebSockets) and is separate from the Realtime API (which uses RealtimeModel for low‑latency audio streaming).
Quick setup steps
1. Install the OpenAI plugin:
◦ Python:
uv add "livekit-agents[openai]~=1.4"
• Node.js:
pnpm add "@livekit/agents-plugin-openai@1.x"
1. Add your OpenAI API key (example .env):
OPENAI_API_KEY=your_api_key
1. Create an AgentSession that uses the Responses API:
◦ Python example:
from livekit.plugins import openai
from livekit.agents import AgentSession
session = AgentSession(
llm=openai.responses.LLM(
model="gpt-4.1"
),
# Optional: add stt, tts, vad if needed
)
• Node.js example:
import * as openai from '@livekit/agents-plugin-openai';
import { AgentSession } from '@livekit/agents';
const session = new AgentSession({
llm: new openai.responses.LLM({
model: "gpt-4.1"
}),
// Optional: add stt, tts, vad if needed
});
Key differences & recommendations
• The Responses API (used via openai.responses.LLM) is recommended for direct OpenAI usage and supports provider tools like WebSearch, FileSearch, and CodeInterpreter.
• The Realtime API is a different path intended for real‑time, bidirectional audio streaming — do not use RealtimeModel if you need the Responses API behavior.
• Use the Responses API when you want advanced OpenAI capabilities and WebSocket-based responses without the realtime audio streaming flow.
If you want, I can:
• Show a minimal end-to-end example of sending a prompt and receiving a response with the Responses LLM.
• Help you add STT/TT S or tools (WebSearch, FileSearch) into the AgentSession.
Which would you like next?
Sources: OpenAI LLM plugin guide | LiveKit Documentation