how do i use change the model for realtime.with_az...
# ask-ai
a
how do i use change the model for realtime.with_azure model?
t
Thanks for reaching out, Harshita. 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 question about how to change the model when using
realtime.with_azure
. You control the Azure model by setting the
azure_deployment
parameter when creating the RealtimeModel. That value should be the name of the deployment you created in your Azure OpenAI resource (for example, a deployment using a GPT-4o-based realtime-capable model). Example (Python):
Copy code
from livekit.plugins import openai

session = AgentSession(
    llm=openai.realtime.RealtimeModel.with_azure(
        azure_deployment="<your-deployment-name>",   # e.g., "gpt-4o-realtime"
        azure_endpoint="wss://<your-endpoint>.<http://openai.azure.com/|openai.azure.com/>",
        api_key="<your-api-key>",
        api_version="2024-10-01-preview",
    ),
)
Key points to check: • Deployment name: Use the exact deployment name you created in Azure — that’s what
azure_deployment
should match. • Model capability: Make sure the Azure deployment uses a model version that supports Realtime/Realtime audio (for example, a GPT-4o realtime-compatible deployment). • Endpoint & version: Use your Azure realtime WebSocket endpoint and the matching API version (example above shows
2024-10-01-preview
). If you’d like, tell me: • the deployment name you want to switch to (or the model name), and • whether you’re using the Python example above or another SDK/language, and I’ll give the exact code snippet or show how to change any other realtime options (voice, modalities, or turn_detection) to match that deployment. Sources: Azure OpenAI Realtime API and LiveKit | LiveKit Documentation