Skip to content

Fix azure_ad_token_provider initialization for azure openai #10532

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GeminiLight
Copy link

Title

Fix azure_ad_token_provider initialization in initialize_azure_sdk_client.

Relevant issues

Fixes #6790

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

This PR addresses a bug where azure_ad_token_provider was not being correctly assigned during the initialization of the client in the initialize_azure_sdk_client function. The root cause was that the value of azure_ad_token_provider defaulted to None, instead of retrieving the correct value from the litellm_params.

Fix
The fix ensures that azure_ad_token_provider is now correctly fetched from litellm_params if available. If it is not found, it will still default to None.

Updated code snippet:

azure_ad_token_provider: Optional[Callable[[], str]] = litellm_params.get("azure_ad_token_provider", None)

Copy link

vercel bot commented May 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2025 4:18pm

@CLAassistant
Copy link

CLAassistant commented May 3, 2025

CLA assistant check
All committers have signed the CLA.

@GeminiLight GeminiLight changed the title fix azure_ad_token_provider for azure openai Fix azure_ad_token_provider initialization for azure openai May 3, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if azure_ad_token_provider is set - line 339 should also handle this

We also need a unit test for this flow in test_azure_common_utils.py -

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your assistance! It is helpful for enterprise-level users to use Azure OpenAI via LiteLLM.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Azure ad token provider does not work
3 participants