Skip to content

fix(azure): forward api_version to aembedding() for Azure AI Foundry v1 endpoints - #24911

Merged
krrish-berri-2 merged 1 commit into
BerriAI:litellm_oss_staging_04_01_2026from
Sameerlite:litellm_azure-v1-async-embed-fix
Apr 2, 2026
Merged

fix(azure): forward api_version to aembedding() for Azure AI Foundry v1 endpoints#24911
krrish-berri-2 merged 1 commit into
BerriAI:litellm_oss_staging_04_01_2026from
Sameerlite:litellm_azure-v1-async-embed-fix

Conversation

@Sameerlite

Copy link
Copy Markdown
Contributor

What

Fixes a silent parameter drop in the async embedding path for Azure AI Foundry.

Root Cause

In BaseAzureLLM.embedding(), when aembedding=True, the call to self.aembedding() was missing api_version=api_version. This meant get_azure_openai_client() received None instead of "v1", causing _is_azure_v1_api_version() to return False and AsyncAzureOpenAI to be selected instead of AsyncOpenAI. The wrong client constructs Azure-specific URLs that don't exist on AI Foundry endpoints, resulting in a 404 ResourceNotFound.

The sync path was unaffected — it passed api_version directly to get_azure_openai_client(). Only the async path (which the proxy always uses) had this bug.

Fix

One-line fix in litellm/llms/azure/azure.py: add api_version=api_version to the self.aembedding() call.

Tests

Added tests/litellm/llms/azure/test_azure_embedding.py with:

  • Regression test verifying api_version is forwarded through embedding()aembedding()
  • Tests verifying get_azure_openai_client() returns AsyncOpenAI (not AsyncAzureOpenAI) for api_version="v1"
  • Tests verifying the /openai/v1/ base URL is used for v1 clients
  • Parametrized test covering all v1 variants ("v1", "latest", "preview")

Fixes #24848

…v1 endpoints

When aembedding=True, api_version was not passed to self.aembedding(), causing
get_azure_openai_client() to receive None instead of "v1". This made
_is_azure_v1_api_version() return False, so AsyncAzureOpenAI was selected
instead of AsyncOpenAI, constructing the wrong request URL and returning 404.

Fixes BerriAI#24848

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 1, 2026 10:57am

Request Review

@codspeed-hq

codspeed-hq Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing Sameerlite:litellm_azure-v1-async-embed-fix (f9e643a) with main (33c3f13)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent parameter drop in the async embedding path for Azure AI Foundry: api_version was not being forwarded from embedding() to aembedding(), causing get_azure_openai_client() to receive None and select AsyncAzureOpenAI instead of AsyncOpenAI for v1 endpoints, resulting in 404 errors on AI Foundry. The fix is a single-line addition of api_version=api_version to the self.aembedding() call.

  • Core fix (litellm/llms/azure/azure.py): Adds the missing api_version=api_version kwarg to the self.aembedding() dispatch, ensuring _is_azure_v1_api_version() returns the correct value and the right client type is chosen for the async path.
  • Tests (tests/litellm/llms/azure/test_azure_embedding.py): Four mock-only unit tests covering the regression directly, correct client-type selection, base URL format, and all v1 api_version variants (\"v1\", \"latest\", \"preview\"). No real network calls are made, satisfying the CI test policy.
  • Minor: The sys.path.insert in the new test file uses 5 .. segments (landing one level above the repo root) instead of the correct 4; tests still pass in practice due to pytest's rootdir detection, but the path is technically wrong.

Confidence Score: 5/5

Safe to merge — the fix is minimal, correct, and well-tested with mock-only unit tests.

Only a single P2 finding (incorrect sys.path depth in the test file) remains, which does not affect test execution or production behavior. The bug fix itself is a straightforward one-liner with proper regression coverage.

No files require special attention.

Important Files Changed

Filename Overview
litellm/llms/azure/azure.py One-line fix: adds api_version=api_version to the self.aembedding() call so the async embedding path selects the correct OpenAI client for Azure AI Foundry v1 endpoints. Change is correct and minimal.
tests/litellm/llms/azure/test_azure_embedding.py New mock-only test file with 4 tests covering the regression, client type selection, base URL, and all v1 api_version variants. Minor issue: sys.path insert uses 5 .. instead of the correct 4.
tests/litellm/llms/azure/init.py Empty package init file, no issues.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Embed as embedding()
    participant AEmbed as aembedding()
    participant GetClient as get_azure_openai_client()
    participant IsV1 as _is_azure_v1_api_version()

    Caller->>Embed: "aembedding=True, api_version=v1"
    Note over Embed: BEFORE FIX: api_version was dropped
    Embed->>AEmbed: "...args, api_version=v1 (fix)"
    AEmbed->>GetClient: "api_version=v1, _is_async=True"
    GetClient->>IsV1: "api_version=v1"
    IsV1-->>GetClient: "True"
    GetClient-->>AEmbed: "AsyncOpenAI (not AsyncAzureOpenAI)"
    AEmbed-->>Caller: "EmbeddingResponse"
Loading

Reviews (1): Last reviewed commit: "fix(azure): forward api_version to aembe..." | Re-trigger Greptile

Comment on lines +7 to +9
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../.."))
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 sys.path depth is one level too deep

The path insert navigates 5 levels up from the file's directory (tests/litellm/llms/azure/), landing in the parent of the repo root rather than the repo root itself. Comparing with tests/litellm/llms/openai_like/test_assemblyai_provider.py — which sits at the same nesting depth and correctly uses "../../../.." (4 levels) — this should also use 4 .. segments:

Suggested change
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../.."))
)
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../.."))
)

In practice pytest's rootdir detection keeps the tests passing regardless, but the intent is wrong and could confuse future readers or fail in unusual invocation contexts.

@krrish-berri-2
krrish-berri-2 changed the base branch from main to litellm_oss_staging_04_01_2026 April 2, 2026 03:14
@krrish-berri-2
krrish-berri-2 merged commit 012f470 into BerriAI:litellm_oss_staging_04_01_2026 Apr 2, 2026
55 of 60 checks passed
Sameerlite added a commit that referenced this pull request Apr 16, 2026
…v1 endpoints (#24911)

When aembedding=True, api_version was not passed to self.aembedding(), causing
get_azure_openai_client() to receive None instead of "v1". This made
_is_azure_v1_api_version() return False, so AsyncAzureOpenAI was selected
instead of AsyncOpenAI, constructing the wrong request URL and returning 404.

Fixes #24848

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sameerlite added a commit that referenced this pull request May 1, 2026
…v1 endpoints (#24911)

When aembedding=True, api_version was not passed to self.aembedding(), causing
get_azure_openai_client() to receive None instead of "v1". This made
_is_azure_v1_api_version() return False, so AsyncAzureOpenAI was selected
instead of AsyncOpenAI, constructing the wrong request URL and returning 404.

Fixes #24848

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
yugborana pushed a commit to yugborana/litellm that referenced this pull request Jun 2, 2026
…v1 endpoints (BerriAI#24911)

When aembedding=True, api_version was not passed to self.aembedding(), causing
get_azure_openai_client() to receive None instead of "v1". This made
_is_azure_v1_api_version() return False, so AsyncAzureOpenAI was selected
instead of AsyncOpenAI, constructing the wrong request URL and returning 404.

Fixes BerriAI#24848

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…v1 endpoints (BerriAI#24911)

When aembedding=True, api_version was not passed to self.aembedding(), causing
get_azure_openai_client() to receive None instead of "v1". This made
_is_azure_v1_api_version() return False, so AsyncAzureOpenAI was selected
instead of AsyncOpenAI, constructing the wrong request URL and returning 404.

Fixes BerriAI#24848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Async embedding requests to Azure AI Foundry (v1 API) fail with ResourceNotFound

2 participants