litellm/tests/unit/llms/azure/response
tavren27 6fc368a15c
fix(azure): send no api-version on Foundry project /openai/v1 Responses bases (#51767)
* fix(azure): send no api-version on Foundry project /openai/v1 Responses bases

Azure answers 400 "api-version query parameter is not allowed when using /v1 path" for every api-version on a Foundry project's /api/projects/<p>/openai/v1/responses route, so drop it there and keep it everywhere else

* fix(azure): send no api-version on Foundry project v1 chat and WebSocket, bill routed models

Chat completions on a Foundry project /openai/v1 base now use the v1 OpenAI client, so they send no
api-version, which that path rejects. The Responses WebSocket URL builder strips a bare /openai/v1 base
before adding /openai/v1/responses, so it no longer dials a doubled path. An azure/model-router call that
routes to a model priced only under azure_ai/ is billed from that row plus the router fee once

* fix(azure): keep the Azure client off chat-only paths, honor api_version none, drop api-version from v1 base queries

Only chat completions switch to the v1 OpenAI client on a Foundry project /openai/v1 base, so transcription and
azure_text keep the Azure client and no longer fail inside LiteLLM. A deployment with api_version none sends no
api-version on Responses and chat, for gateways that hide the project path. The v1 client now moves an api_base
query into default_query without api-version instead of gluing the route after it

* fix(azure): pick the v1 client for o-series chat, keep api_version none off a doubled /openai/responses path

* fix(azure): send no api-version on embeddings under api_version none, test async and streaming chat on v1 bases

* fix(azure): join openai/v1 once onto a v1 client base that ends in /openai

Chat and embeddings under api_version none, and chat under api_version v1, built /openai/openai/v1 from an api_base ending in /openai, while Responses on the same base already built /openai/v1. The v1 client now joins the route the same overlap-aware way

* fix(azure): keep a percent-encoded gateway path as typed on the v1 client base

Join openai/v1 by string instead of add_path_to_api_base, which decodes %2F, %25, %3F and %23 in the base path. Type the chat test helper's mode as a Literal with assert_never.

* test(azure): import assert_never from typing_extensions so the Azure tests load on Python 3.10

typing.assert_never needs Python 3.11, and the package supports 3.10

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-14 05:24:12 -05:00
..
__init__.py
test_azure_transformation.py fix(azure): send no api-version on Foundry project /openai/v1 Responses bases (#51767) 2026-11-14 05:24:12 -05:00