litellm/tests/unit/llms/azure_ai
tavren27 a705537692
fix(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151)
* fix(openai): treat chat-latest and gpt-chat-latest as gpt-5 family models

OpenAI's chat-latest alias and Azure / Foundry gpt-chat-latest deployments reject max_tokens,
temperature other than 1, top_p, stop, the penalties, logit_bias and logprobs, which is the gpt-5
reasoning family's parameter shape. The shared name check only matched gpt-5 and gpt-6, so these
names forwarded max_tokens and the provider answered 400

The family check now also matches a last path segment equal to chat-latest or containing
gpt-chat-latest, and Azure's max_completion_tokens rename reuses the same helper. gpt-5-chat-latest
keeps its exclusion from issue 13781

Two side effects of moving these names onto the gpt-5 config are fixed too. The gpt-5 config read
tool_choice support off the bare name, which dropped it for azure_ai/gpt-chat-latest, so it now
reads the provider's map row. Azure gpt-5 deployments off the OpenAI catalog lost the user param,
which Azure accepts, so the Azure gpt-5 config adds it back next to tool_choice

The azure_ai/gpt-chat-latest map row gets reasoning_effort_levels ["medium"] like its azure and
openai twins, so /v1/messages lowers xhigh and max to medium instead of high, which Foundry rejects

* fix(openai): enforce a map row's reasoning_effort_levels on the gpt-5 effort checks

* fix(openai): import declared_reasoning_efforts_for_map_key from its litellm_core_utils home

* fix(openai): keep chat-latest tool_choice and user scoped and read effort levels off the catalog row

A router deployment's model_info.reasoning_effort_levels is copied onto the shared
map key, so reading levels from litellm.model_cost let one deployment gate its
siblings. The gate now reads catalog_with_runtime_registrations(), which leaves
router registrations out

chat-latest names keep tool_choice on every provider as they did before they
joined the gpt-5 config, and Azure adds user back only for chat-latest names, so
other off-catalog Azure gpt-5 deployments keep dropping it as on main

* fix(openai): gate custom chat-latest deployment names by the chat-latest row and keep main's tool_choice lookup

* fix(openai): keep chat-latest names on main's handling outside OpenAI, Azure and Foundry, and read base_model on azure_ai

* fix(openai): keep chat-latest names OpenAI doesn't serve on main's handling, and let a Foundry gpt-5 base_model set the param list

* fix(azure_ai,router): keep known Foundry names' params and drop effort levels a chat-latest row refuses

A gpt-5 base_model now stands in for a Foundry deployment name only when the
name is neither gpt-5 family nor a known azure_ai catalog model, with any
provider prefix stripped, so model-router, Phi-4 and gpt-5.6-terra keep main's
params. The complexity router's classifier and tier params drop a
reasoning_effort level a gpt-5 row lists its levels without, unless the
deployment's own model_info lists it

* fix(azure_ai): route custom Foundry names with a gpt-5 base_model to Responses for tools with reasoning

A custom-named Foundry deployment whose base_model is gpt-5.6 or later now
bridges function tools with an active reasoning effort to /v1/responses, the
same as the deployment named after that model, instead of 400ing on chat

* fix(anthropic): keep signed thinking for custom Foundry names that a gpt-5 base_model routes to Responses

* fix(azure_ai,cost): price nested base_model forms and refuse n and seed when a gpt-5 base_model bridges a custom Foundry name

A base_model written as azure_ai/openai/gpt-5.6-terra priced at $0 on every path. Chat only looked priced because Foundry's chat response names the served model, while Foundry's Responses API echoes the deployment name, so bridged and direct /v1/responses calls recorded $0. The cost lookup now drops a nested provider segment from a base_model that has no rates of its own, so it prices like azure_ai/gpt-5.6-terra, and a nested name with its own cost-map row keeps that row

A custom azure_ai name that its gpt-5 base_model sends to the Responses API now answers 400 for n above 1 or any seed, since Responses has neither field, unless drop_params is set. Names LiteLLM already knows and every other provider keep their current behavior

* fix(azure_ai): refuse n and seed only when the gpt-5 base_model sent the request to Responses

The explicit azure_ai/responses/ prefix and a pinned mode: responses already chose Responses before the
base_model was read, so those routes keep main's handling and no longer get a 400 that blames the base_model

* fix(azure_ai): let the /v1/messages adapter see a request-level base_model and name the proxy drop_params setting

A custom azure_ai deployment whose gpt-5 base_model sends it to the Responses API now keeps its reasoning summary on /v1/messages whether the base_model sits in model_info or litellm_params, with a non-empty litellm_params value winning as it does in completion(). The n and seed refusal names the proxy drop_params setting, and tests pin seed=0, n=1, a responses/ name and a gpt-5.6 deployment name keeping its own rules

* test(anthropic): use gpt-5-chat-latest as the chat model that takes no reasoning effort

chat-latest now takes the gpt-5 shape with a medium effort, so main's new
bare-effort test needs a model whose chat config still refuses reasoning_effort

* fix(openai): type OpenAIConfig's supported params as a list of strings

* fix(router): match openai/chat-latest and read litellm_params base_model first in the router's param check

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-24 04:02:51 -08: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(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151) 2026-11-24 04:02:51 -08:00
claude fix(anthropic)!: send extra_body fields at the top level of the Messages request (#48373) 2026-11-20 06:52:56 -08:00
embed fix(azure_ai): use the v1 chat path for Azure OpenAI resource bases (#52759) 2026-11-19 20:12:55 -08: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(proxy): size budget reservation from route output cap fields (#51752) 2026-11-20 16:25:09 -08: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