litellm/tests/unit/llms/azure_ai
zoveki 87aed7c37b
fix(azure_ai)!: call Responses natively for a model router on a Foundry project or resource base (#52474)
* fix(azure_ai): call Responses natively for a model router on a Foundry project base

A model_router entry whose api_base is a Foundry project path on an Azure OpenAI v1 host now uses
AzureAIResponsesAPIConfig instead of bridging to chat, so POST /v1/responses goes to
<host>/api/projects/<project>/openai/v1/responses with the deployment name as the body model.
Resource v1 bases, non-v1 hosts, the default route, and Foundry agents are unchanged, and the
chat-to-Responses bridge check still keeps chat on chat for router entries

The non-streaming response records the routed model in the hidden model-router key the same way
chat does, so the spend log shows the routed model, and cost stays routed model price plus the
router flat fee once

A streamed call on that route streams natively. The deployment name has no cost-map row, so the
inherited supports_native_streaming lookup would have faked the stream and held every token until
the answer finished

* fix(azure_ai): send the bare deployment name when compacting through a model router

On a Foundry project base a model router entry now has a Responses config, so /v1/responses/compact reaches the project instead of failing with "not supported". The compact body carried model_router/<deployment>, which Azure answers with 404 DeploymentNotFound, so compact now strips the name the same way create does

* fix(azure_ai): call Responses natively for a model router on a Foundry project base behind any host

* fix(azure_ai): drop custom tools for a model router under drop_params

* fix(azure_ai): send a resource-base model router to Responses, convert custom tool history, and record the streamed routed model

* fix(azure_ai): keep a model router on a /models or deployments base on chat, and drop a tool_choice naming a custom tool

* fix(azure_ai): send a model router's custom tools as function tools, answer its calls as custom tool calls, and accept a full Responses URL base

* fix(azure_ai): keep a model router on an openai.azure.com or cognitiveservices resource base on the chat bridge

Those hosts already served router Responses through the chat bridge in released versions, so running conversations, store: false follow-ups, and litellm-managed file_search keep working there. Only a Foundry project base or a services.ai.azure.com resource base goes native. The test helpers also get full types.

* fix(azure_ai): keep a model router on a gateway project base on the chat bridge and match custom calls by namespace

A router behind a gateway project base used the chat bridge in released
versions, so only a services.ai.azure.com base now goes native. A top-level
function that shares its name with a namespaced custom tool no longer comes
back as a custom call, since custom calls are matched by namespace and name.

* fix(azure_ai): keep a bridged turn's follow-ups on the chat bridge and keep replayed call namespaces

A model router follow-up whose previous_response_id names a turn the chat bridge answered now stays on the bridge, the turn's spend row flushes at once, and an MCP first round does not chain through Azure. Replayed custom tool calls keep their namespace.

* fix(azure_ai): keep only model router follow-ups to a bridged turn on the chat bridge

A follow-up whose previous_response_id names a chat-bridged turn now stays on the bridge only for an
azure_ai model router on a services.ai.azure.com v1 base, the one entry this PR moves to native
Responses. Other deployments send such a follow-up as before, so a plain Foundry deployment still
answers Azure's 400 instead of a reply that silently drops the earlier turns when prompts are not stored

* fix(azure_ai): write a native model router turn's spend row at once

Every router turn used to go over the chat bridge, whose rows skip the batch write. A native router
turn now writes at once too, so a follow-up that lands on a router entry in the same group that still
bridges, an openai.azure.com base say, can replay it right away instead of answering without it

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-18 16:36:46 +00:00
..
agents refactor(typing): clear 1141 basedpyright Any errors across 182 files (#50711) 2026-11-11 22:11:47 +00:00
anthropic feat(messages): serve azure ai foundry messages on rust only (#51721) 2026-11-14 13:40:38 -08:00
chat fix(azure_ai)!: call Responses natively for a model router on a Foundry project or resource base (#52474) 2026-11-18 16:36:46 +00:00
claude fix(vertex_ai,azure_ai)!: auto-add the compaction, thinking display, and tool change betas on Claude routes (#44747) 2026-10-30 09:28:19 -07:00
embed test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
image_edit feat(azure_ai): support gpt-image edits on Azure AI Foundry (#49650) 2026-11-12 00:52:55 +00:00
image_generation refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
passthrough fix(cohere): price native Cohere embed calls on Foundry relays and the Cohere passthrough (#48978) 2026-10-29 05:17:11 -07:00
rerank chore(cost-map): remove the 52 rows whose provider retired them before 2026 (#49974) 2026-11-03 16:23:06 -08:00
responses fix(azure_ai)!: call Responses natively for a model router on a Foundry project or resource base (#52474) 2026-11-18 16:36:46 +00:00
vector_stores refactor(typing): clear 1141 basedpyright Any errors across 182 files (#50711) 2026-11-11 22:11:47 +00:00
__init__.py test(unit): add package markers to migrated unit test directories 2026-09-20 11:53:14 +00:00
test_azure_ai_agents_handler.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_azure_ai_cost_calculator.py fix(azure_ai)!: call Responses natively for a model router on a Foundry project or resource base (#52474) 2026-11-18 16:36:46 +00:00
test_azure_ai_entra_auth.py fix(azure)!: answer 401 when Entra rejects the deployment's credential (#49863) 2026-11-04 20:44:55 +00:00
test_azure_ai_foundry_catalog_model_metadata.py feat(cost-map): rolling registry update (claude-mythos-5-2, Azure Mythos 5.2, Friendli GLM-5.1 date, GovCloud Fable 5.2 token counting) (#50777) 2026-11-10 13:31:56 +00:00
test_azure_ai_fw_models_metadata.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_azure_ai_kimi_k26_metadata.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00