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: OpenAILLMSettings

Settings 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: OpenAILLMService

A 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 endpoint selects the API surface. An endpoint ending in /openai/v1 uses Azure’s v1 API, which tracks new features without a dated api_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/v1 selects the v1 API surface, where api_version does not apply.

  • api_key – The API key for accessing Azure OpenAI. Required unless token_provider is given.

  • token_provider – 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.

  • 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 endpoint ending in /openai/v1 instead. Will be removed in 2.0.0.

  • settings – Runtime-updatable settings. When provided alongside deprecated parameters, settings values take precedence.

  • **kwargs – Additional keyword arguments passed to OpenAILLMService.

Raises:

ValueError – If neither api_key nor token_provider is 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.