how to use the websocket open responses api not th...
# ask-ai
a
how to use the websocket open responses api not the realtime api
t
Thanks for reaching out, Arun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I understand you want to use the WebSocket Open Responses API (the OpenAI Responses API) — not the Realtime API. Below I’ll show what to use in LiveKit and give concise examples for Python and Node.js so you can get started. What to use • Use the LiveKit OpenAI plugin’s Responses LLM via
openai.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:
Copy code
uv add "livekit-agents[openai]~=1.4"
• Node.js:
Copy code
pnpm add "@livekit/agents-plugin-openai@1.x"
1. Add your OpenAI API key (example
.env
):
Copy code
OPENAI_API_KEY=your_api_key
1. Create an AgentSession that uses the Responses API: ◦ Python example:
Copy code
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:
Copy code
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