can you please provide a code example of how i can...
# ask-ai
h
can you please provide a code example of how i can use the gpt-realtime-1.5 modal
✅ 1
t
Thanks for reaching out, Ahmed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your request for a code example showing how to use the
gpt-realtime-1.5
model. Node.js example (TypeScript)
Copy code
import { voice } from '@livekit/agents';
import * as openai from '@livekit/agents-plugin-openai';

// create an AgentSession that uses the gpt-realtime-1.5 model
const session = new voice.AgentSession({
  llm: new openai.realtime.RealtimeModel({
    model: "gpt-realtime-1.5",
    voice: "marin",
    temperature: 0.8,
    modalities: ["text", "audio"],
  }),
});

// start the session (example API may vary by SDK version)
await session.start();
await session.sendUserMessage("Hello — please summarize the meeting notes.");
const reply = await session.receiveAssistantMessage();
console.log("Assistant reply:", reply.text);
Python example
Copy code
from livekit.plugins import openai
from livekit.agents import AgentSession

session = AgentSession(
  llm=openai.realtime.RealtimeModel(
    model="gpt-realtime-1.5",
    voice="marin",
    temperature=0.8,
    modalities=["text", "audio"],
  ),
)

# start the session (API may vary by SDK version)
await session.start()
await session.send_user_message("Hello — please summarize the meeting notes.")
reply = await session.receive_assistant_message()
print("Assistant reply:", reply.text)
Notes • Set your OpenAI API key (e.g.,
OPENAI_API_KEY
) so the OpenAI plugin can authenticate. • If you only want text responses, use
modalities: ["text"]
. • If the model name isn’t accepted, try
gpt-realtime
or confirm
gpt-realtime-1.5
is available in your OpenAI account. Would you like a short example that streams audio output to a LiveKit room or an example that only uses text? , with interactive elements