mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(router): preserve Azure Entra ID params in reusable credentials (#40889)
CredentialLiteLLMParams omitted tenant_id, client_id, client_secret, azure_scope, azure_username and azure_password, so the strict dump used by credential reuse and Azure client init dropped them and the reused credential ended with no auth at all Co-authored-by: yassin <yassin@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
036bfc08fc
commit
8851148330
3 changed files with 65 additions and 0 deletions
|
|
@ -268,6 +268,12 @@ class CredentialLiteLLMParams(BaseModel):
|
|||
# callers see it, breaking Azure deployments configured with
|
||||
# ``azure_ad_token`` instead of a static ``api_key`` (#30235).
|
||||
azure_ad_token: str | None = None
|
||||
tenant_id: str | None = None
|
||||
client_id: str | None = None
|
||||
client_secret: str | None = None
|
||||
azure_scope: str | None = None
|
||||
azure_username: str | None = None
|
||||
azure_password: str | None = None
|
||||
## VERTEX AI ##
|
||||
vertex_project: str | None = None
|
||||
vertex_location: str | None = None
|
||||
|
|
|
|||
|
|
@ -5625,6 +5625,41 @@ def test_get_deployment_credentials_with_provider_preserves_aws_auth_params():
|
|||
assert credentials.get(key) == value, key
|
||||
|
||||
|
||||
def test_get_deployment_credentials_preserves_azure_entra_id_params():
|
||||
entra_params = {
|
||||
"tenant_id": "deployment-tenant",
|
||||
"client_id": "deployment-client",
|
||||
"client_secret": "deployment-client-secret",
|
||||
"azure_scope": "https://cognitiveservices.azure.us/.default",
|
||||
"azure_username": "deployment-user",
|
||||
"azure_password": "deployment-password",
|
||||
}
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "azure-entra-model",
|
||||
"litellm_params": {
|
||||
"model": "azure/gpt-5.4",
|
||||
"api_base": "https://example.openai.azure.com/",
|
||||
"api_version": "2024-10-21",
|
||||
**entra_params,
|
||||
},
|
||||
"model_info": {"id": "azure-entra-model-id"},
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
credentials = router.get_deployment_credentials(model_id="azure-entra-model-id")
|
||||
credentials_with_provider = router.get_deployment_credentials_with_provider(model_id="azure-entra-model-id")
|
||||
|
||||
assert credentials is not None
|
||||
assert credentials_with_provider is not None
|
||||
assert "api_key" not in credentials
|
||||
for key, value in entra_params.items():
|
||||
assert credentials.get(key) == value, key
|
||||
assert credentials_with_provider.get(key) == value, key
|
||||
|
||||
|
||||
def _team_wildcard_model(api_key: str, model_id: str = "team-wildcard-id") -> dict:
|
||||
return {
|
||||
"model_name": f"model_name_team-1_{model_id}",
|
||||
|
|
|
|||
24
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
24
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
|
|
@ -29639,6 +29639,12 @@ export interface components {
|
|||
aws_web_identity_token?: string | null;
|
||||
/** Azure Ad Token */
|
||||
azure_ad_token?: string | null;
|
||||
/** Azure Password */
|
||||
azure_password?: string | null;
|
||||
/** Azure Scope */
|
||||
azure_scope?: string | null;
|
||||
/** Azure Username */
|
||||
azure_username?: string | null;
|
||||
/** Bedrock Tags */
|
||||
bedrock_tags?: unknown[] | null;
|
||||
/** Budget Duration */
|
||||
|
|
@ -29687,6 +29693,10 @@ export interface components {
|
|||
cache_read_input_token_cost_ultrafast?: number | null;
|
||||
/** Citation Cost Per Token */
|
||||
citation_cost_per_token?: number | null;
|
||||
/** Client Id */
|
||||
client_id?: string | null;
|
||||
/** Client Secret */
|
||||
client_secret?: string | null;
|
||||
/** Complexity Router Config */
|
||||
complexity_router_config?: {
|
||||
[key: string]: unknown;
|
||||
|
|
@ -29900,6 +29910,8 @@ export interface components {
|
|||
tag_regex?: string[] | null;
|
||||
/** Tags */
|
||||
tags?: string[] | null;
|
||||
/** Tenant Id */
|
||||
tenant_id?: string | null;
|
||||
/** Tiered Pricing */
|
||||
tiered_pricing?: {
|
||||
[key: string]: unknown;
|
||||
|
|
@ -39841,6 +39853,12 @@ export interface components {
|
|||
aws_web_identity_token?: string | null;
|
||||
/** Azure Ad Token */
|
||||
azure_ad_token?: string | null;
|
||||
/** Azure Password */
|
||||
azure_password?: string | null;
|
||||
/** Azure Scope */
|
||||
azure_scope?: string | null;
|
||||
/** Azure Username */
|
||||
azure_username?: string | null;
|
||||
/** Bedrock Tags */
|
||||
bedrock_tags?: unknown[] | null;
|
||||
/** Budget Duration */
|
||||
|
|
@ -39889,6 +39907,10 @@ export interface components {
|
|||
cache_read_input_token_cost_ultrafast?: number | null;
|
||||
/** Citation Cost Per Token */
|
||||
citation_cost_per_token?: number | null;
|
||||
/** Client Id */
|
||||
client_id?: string | null;
|
||||
/** Client Secret */
|
||||
client_secret?: string | null;
|
||||
/** Complexity Router Config */
|
||||
complexity_router_config?: {
|
||||
[key: string]: unknown;
|
||||
|
|
@ -40102,6 +40124,8 @@ export interface components {
|
|||
tag_regex?: string[] | null;
|
||||
/** Tags */
|
||||
tags?: string[] | null;
|
||||
/** Tenant Id */
|
||||
tenant_id?: string | null;
|
||||
/** Tiered Pricing */
|
||||
tiered_pricing?: {
|
||||
[key: string]: unknown;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue