litellm/tests/unit/llms/azure/chat
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
..
__init__.py
test_azure_base_model_routing.py refactor(llms): rename model-version transformation files to family names (#48509) 2026-10-26 18:53:16 -07:00
test_azure_chat_gpt_transformation.py fix(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151) 2026-11-24 04:02:51 -08:00
test_azure_chat_o_series_transformation.py fix(openai): send chat completions through client.post so the SDK's per-message param transform stops holding the event loop (#46967) 2026-10-16 18:06:01 -07:00
test_azure_gpt_reasoning_transformation.py fix(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151) 2026-11-24 04:02:51 -08:00