witty-kangaroo-6889
08/20/2025, 3:26 AMtall-airline-16756
08/20/2025, 3:26 AMtall-airline-16756
08/20/2025, 3:27 AMpip install "livekit-agents[openai]~=1.0"
2. Next, set your environment variables:
◦ `AZURE_OPENAI_API_KEY`: Pop in your Azure OpenAI API key here.
◦ `AZURE_OPENAI_ENDPOINT`: This should look like https://{your-resource-name}.<http://openai.azure.com|openai.azure.com>
.
◦ `OPENAI_API_VERSION`: Use the API version for Azure OpenAI, like 2024-05-01-preview
.
1. Then, initialize your LLM with the Azure settings: from livekit.plugins.openai import LLM
azure_llm = LLM.with_azure(
model="gpt-4o-mini",
azure_deployment="your-gpt-4o-mini-deployment-name", # This should match your Azure deployment name
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"), # Optional if you’ve set the env variable
api_version=os.getenv("OPENAI_API_VERSION"), # Optional if you’ve set the env variable
api_key=os.getenv("AZURE_OPENAI_API_KEY"), # Optional if you’ve set the env variable
temperature=0.8,
)
2. Finally, plug it into your agent like this: session = AgentSession(
llm=azure_llm,
# ... and don’t forget your other parts like stt, tts, vad, etc.
)
Just double-check that the deployment name (azure_deployment
) exactly matches what you named your gpt-4o-mini
model in the Azure portal. If you hit any snags or want a hand with anything else, just give me a shout—I’m here to help!
Sources: OpenAI LLM integration guide | LiveKit Docs | OpenAI compatible LLMs | LiveKit Docs | Azure integration guide | LiveKit Docs | Large language model (LLM) integrations | LiveKit Docs