how to use new production ready openai realtime mo...
# ask-ai
c
how to use new production ready openai realtime model?
t
Thanks for reaching out, ZaidKaraymeh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want to get started with the new production-ready OpenAI real-time model using LiveKit, here’s a friendly step-by-step guide to help you out: 1. Installation: First, install the LiveKit Agents OpenAI plugin by running:
Copy code
pip install "livekit-agents[openai]~=1.2"
2. Authentication: Next, pop your OpenAI API key into the
.env
file like this:
Copy code
OPENAI_API_KEY=your_api_key_here
3. Usage: Now, create a
RealtimeModel
instance and pass it to an
AgentSession
. Here’s a quick example:
Copy code
from livekit.agents import AgentSession
from livekit.plugins import openai

session = AgentSession(
  llm=openai.realtime.RealtimeModel()
)
If you’re working with Node.js, you can do it like this:
Copy code
import { RealtimeModel } from '@livekit/agents-plugin-openai';

const session = new AgentSession({
  llm: new RealtimeModel(),
});
4. Configuration: Feel free to tweak parameters like model, voice, temperature, and turn detection to fit your needs. Here’s an example:
Copy code
session = AgentSession(
  llm=openai.realtime.RealtimeModel(
    model="gpt-4o-realtime-preview",
    voice="shimmer",
    temperature=0.7
  )
)
And if you’re using Azure OpenAI, just use the
with_azure
method and set up your Azure-specific environment variables. Want to dive deeper? Check out the OpenAI Realtime API integration guide for all the details. Happy coding! Sources: Azure AI Services and LiveKit | LiveKit Docs | OpenAI and LiveKit partner to turn Advanced Voice into an API | OpenAI Realtime API integration guide | LiveKit Docs | Realtime model integrations | LiveKit Docs | examples/src/realtime_turn_detector.ts