@staticmethod def with_azure( *, ...
# ask-ai
h
@staticmethod def with_azure( *, model: str | ChatModels = "gpt-4o", azure_endpoint: str | None = None, azure_deployment: str | None = None, api_version: str | None = None, api_key: str | None = None, azure_ad_token: str | None = None, azure_ad_token_provider: AsyncAzureADTokenProvider | None = None, organization: str | None = None, project: str | None = None, base_url: str | None = None, user: NotGivenOr[str] = NOT_GIVEN, safety_identifier: NotGivenOr[str] = NOT_GIVEN, prompt_cache_key: NotGivenOr[str] = NOT_GIVEN, temperature: NotGivenOr[float] = NOT_GIVEN, parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN, tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN, timeout: httpx.Timeout | None = None, reasoning_effort: NotGivenOr[ReasoningEffort] = NOT_GIVEN, top_p: NotGivenOr[float] = NOT_GIVEN, ) can you explain this parameters wwhat is the difference between azure_ad_token: str | None = None, azure_ad_token_provider: AsyncAzureADTokenProvider | None = None,
t
Thanks for reaching out, Sahil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for your question! Let me help clarify the difference between
azure_ad_token
and
azure_ad_token_provider
when it comes to Azure Active Directory (AAD) authentication: •
azure_ad_token
: This is where you provide a pre-acquired Azure Active Directory token as a string. It’s used directly for authentication with Azure OpenAI services, and if you don’t provide it explicitly, it can be automatically picked up from the environment variable
AZURE_OPENAI_AD_TOKEN
. Pretty handy! •
azure_ad_token_provider
: This one is a bit more dynamic. It accepts a callable (specifically, an
AsyncAzureADTokenProvider
) that fetches an AAD token whenever it’s needed. This is great for more advanced scenarios, like when tokens need to be refreshed or retrieved asynchronously, such as with managed identity or service principal flows. So, to sum it up:
azure_ad_token
is a static token string you provide upfront, while
azure_ad_token_provider
offers a flexible, programmatic way to get tokens on the fly for Azure authentication. I hope this helps clear things up! If you have any more questions, feel free to ask. Sources: Azure OpenAI TTS plugin guide | LiveKit Docs | Azure OpenAI STT plugin guide | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real...