Overview
AzureLLMService provides access to Azure OpenAI’s language models through an OpenAI-compatible interface. It inherits from OpenAILLMService and supports streaming responses, function calling, and context management with enterprise-grade security and compliance.
Azure LLM API Reference
Pipecat’s API methods for Azure OpenAI integration
Example Implementation
Complete example with function calling
Azure OpenAI Documentation
Official Azure OpenAI documentation and setup
Azure Portal
Create OpenAI resources and get credentials
Installation
To use Azure OpenAI services, install the required dependency:Prerequisites
Azure OpenAI Setup
Before using Azure OpenAI LLM services, you need:- Azure Account: Sign up at Azure Portal
- OpenAI Resource: Create an Azure OpenAI resource in your subscription
- Model Deployment: Deploy your chosen model (GPT-4, GPT-4o, etc.)
- Credentials: Get your endpoint and deployment name, plus either:
- An API key for key-based authentication, or
- Microsoft Entra ID credentials for token-based authentication
Environment Variables
AZURE_CHATGPT_ENDPOINT: Your Azure OpenAI endpoint URLAZURE_CHATGPT_MODEL: Your model deployment nameAZURE_CHATGPT_API_KEY: Your Azure OpenAI API key (required unless usingtoken_provider)
Configuration
str
required
Azure OpenAI endpoint URL. Ending it in
/openai/v1 selects the v1 API
surface (recommended), where api_version does not apply. Example:
"https://my-resource.openai.azure.com/openai/v1".str | None
default:"None"
Azure OpenAI API key for key-based authentication. Required unless
token_provider is given.AzureTokenProvider | None
default:"None"
Async callable supplying a Microsoft Entra ID bearer token, used instead of
api_key when given. Build one with
azure.identity.aio.get_bearer_token_provider() and the
https://ai.azure.com/.default scope.str
default:"None"
deprecated
Deprecated in v0.0.105. Use
settings=AzureLLMService.Settings(model=...)
instead.str | None
default:"None"
deprecated
Deprecated in v1.8.0. Use an
endpoint ending in /openai/v1 instead.
Azure API version applied to endpoints outside the v1 API surface. Defaults to
2025-04-01-preview.AzureLLMService inherits from OpenAILLMService, it also accepts the following parameters:
InputParams
default:"None"
deprecated
Deprecated in v0.0.105. Use
settings=AzureLLMService.Settings(...)
instead.float
default:"5.0"
Request timeout in seconds. Used when
retry_on_timeout is enabled to
determine when to retry.bool
default:"False"
Whether to retry the request once if it times out. The retry attempt has no
timeout limit.
Settings
Runtime-configurable settings passed via thesettings constructor argument using AzureLLMService.Settings(...). These can be updated mid-conversation with LLMUpdateSettingsFrame. See Service Settings for details.
AzureLLMService uses the same settings as OpenAILLMService. See the OpenAI LLM Settings section for the full parameter reference.
Usage
Basic Setup
With Microsoft Entra ID Authentication
With Custom Settings
Updating Settings at Runtime
Model settings can be changed mid-conversation usingLLMUpdateSettingsFrame:
Notes
- Deployment name vs model name: The
modelparameter should be your Azure deployment name, not the underlying model name (e.g., use"my-gpt4-deployment"instead of"gpt-4"). - v1 API surface: Endpoints ending in
/openai/v1use Azure’s v1 API, which tracks new features without requiring a datedapi_version. This is the recommended surface. Endpoints without this suffix route through the dated API version2025-04-01-preview(the last version Azure issued). - Authentication options: Both key-based authentication (
api_key) and Microsoft Entra ID token-based authentication (token_provider) are supported. Eitherapi_keyortoken_providermust be provided. - Full OpenAI compatibility: Since
AzureLLMServiceinherits fromOpenAILLMService, it supports all the same features including function calling, vision input, and streaming responses.
Event Handlers
AzureLLMService supports the same event handlers as OpenAILLMService, inherited from LLMService: