azure_llm = AzureOpenAILLM( model="gpt-4o-...
# ask-ai
l
azure_llm = AzureOpenAILLM( model="gpt-4o-mini", api_key=azure_api_key, azure_endpoint="https://res-azureopenai.openai.azure.com/", api_version="2024-12-01-preview" ) is this the correct format to integrate azure openai as the llm?
t
Thanks for reaching out, Computer. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! Just to make sure I understand correctly, is this integration meant to be used within a LiveKit application, or are you looking for a general Azure OpenAI integration? Knowing this will help me guide you in the best possible way. Sources: Azure OpenAI LLM plugin guide | LiveKit Docs | Azure AI Services and LiveKit | LiveKit Docs
l
this is to integrate into livekit, that is to use the llm from azure openai
t
I'm glad you're interested in integrating Azure OpenAI as the LLM in LiveKit! You can easily do this using the OpenAI plugin, which already supports Azure OpenAI. Let me walk you through the setup step-by-step: 1. Install the OpenAI Plugin:
Copy code
pip install livekit-plugins-openai
2. Set Environment Variables:
Copy code
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
OPENAI_API_VERSION=2024-10-01-preview
3. Use the
with_azure
Method:
Copy code
from livekit.plugins import openai

llm = openai.LLM.with_azure(
    model="gpt-4o",
    azure_deployment="your-deployment-name",
    azure_endpoint="https://your-endpoint.openai.azure.com/",
    api_version="2024-10-01-preview",
    api_key="your-api-key",
    temperature=0.7
)
Once you've set this up, you can use the LLM in an
AgentSession
or even as a standalone service. If you have any questions or run into any issues, please feel free to reach out—I’m here to help! Sources: Azure AI Services and LiveKit | LiveKit Docs | Azure OpenAI LLM plugin guide | LiveKit Docs | examples/voice_agents/realtime_load_chat_history.py | plugins/openai/src/llm.ts