llm
Azure OpenAI service implementation for the Pipecat AI framework.
- pipecat.services.azure.llm.V1_ENDPOINT_PATH = '/openai/v1'
Endpoint path suffix identifying Azure’s v1 API surface.
- pipecat.services.azure.llm.DATED_API_VERSION = '2025-04-01-preview'
Dated API version used for endpoints outside the v1 API surface.
Azure stopped issuing dated versions after this one; the v1 surface tracks new features in its place.
- class pipecat.services.azure.llm.AzureLLMSettings(model: str | None | NotGiven = <factory>, extra: dict[str, Any]=<factory>, system_instruction: str | None | NotGiven = <factory>, temperature: float | None | NotGiven | NotGiven = <factory>, max_tokens: int | None | NotGiven | NotGiven = <factory>, top_p: float | None | NotGiven | NotGiven = <factory>, top_k: int | None | NotGiven = <factory>, frequency_penalty: float | None | NotGiven | NotGiven = <factory>, presence_penalty: float | None | NotGiven | NotGiven = <factory>, seed: int | None | NotGiven | NotGiven = <factory>, filter_incomplete_user_turns: bool | None | NotGiven = <factory>, user_turn_completion_config: UserTurnCompletionConfig | None | NotGiven = <factory>, use_provider_thinking_default: bool | NotGiven = <factory>, max_completion_tokens: int | None | NotGiven | NotGiven = <factory>)[source]
Bases:
OpenAILLMSettingsSettings for AzureLLMService.
- class pipecat.services.azure.llm.AzureLLMService(*, endpoint: str, api_key: str | None = None, token_provider: Callable[[], Awaitable[str]] | None = None, model: str | None = None, api_version: str | None = None, settings: AzureLLMSettings | None = None, **kwargs)[source]
Bases:
OpenAILLMServiceA service for interacting with Azure OpenAI using the OpenAI-compatible interface.
This service extends OpenAILLMService to connect to Azure’s OpenAI endpoint while maintaining full compatibility with OpenAI’s interface and functionality.
The shape of
endpointselects the API surface. An endpoint ending in/openai/v1uses Azure’s v1 API, which tracks new features without a datedapi_version; any other endpoint routes through a dated version of the API. Both key-based and Microsoft Entra ID authentication work on either surface.Example:
service = AzureLLMService( api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint="https://my-resource.openai.azure.com/openai/v1", settings=AzureLLMService.Settings(model="my-deployment"), )
- Settings
alias of
AzureLLMSettings
- __init__(*, endpoint: str, api_key: str | None = None, token_provider: Callable[[], Awaitable[str]] | None = None, model: str | None = None, api_version: str | None = None, settings: AzureLLMSettings | None = None, **kwargs)[source]
Initialize the Azure LLM service.
- Parameters:
endpoint – The Azure endpoint URL. Ending it in
/openai/v1selects the v1 API surface, whereapi_versiondoes not apply.api_key – The API key for accessing Azure OpenAI. Required unless
token_provideris given.token_provider – Async callable supplying a Microsoft Entra ID bearer token, used instead of
api_keywhen given. Build one withazure.identity.aio.get_bearer_token_provider()and thehttps://ai.azure.com/.defaultscope.model –
The model identifier to use. Defaults to “gpt-4.1”.
Deprecated since version 0.0.105: Use
settings=AzureLLMService.Settings(model=...)instead. Will be removed in 2.0.0.api_version –
Azure API version applied to endpoints outside the v1 API surface. Defaults to
DATED_API_VERSION.Deprecated since version 1.8.0: Use an
endpointending in/openai/v1instead. Will be removed in 2.0.0.settings – Runtime-updatable settings. When provided alongside deprecated parameters,
settingsvalues take precedence.**kwargs – Additional keyword arguments passed to OpenAILLMService.
- Raises:
ValueError – If neither
api_keynortoken_provideris given.
- create_client(api_key=None, base_url=None, **kwargs)[source]
Create OpenAI-compatible client for Azure OpenAI endpoint.
- Parameters:
api_key – API key for authentication. Uses instance key if None.
base_url – Base URL for the client. Ignored for Azure implementation.
**kwargs – Additional keyword arguments. Ignored for Azure implementation.
- Returns:
Configured client for the API surface the endpoint selects.