litellm/tests/unit/llms/openai
linhqm 21450cdefc
fix(anthropic): map /v1/messages fields onto OpenAI Responses equivalents or reject them (#54173)
* fix(anthropic): map /v1/messages fields onto OpenAI Responses equivalents or reject them

The Responses bridge for /v1/messages dropped several Anthropic fields and still answered 200. disable_parallel_tool_use now sets parallel_tool_calls false, speed fast asks for the priority service tier, mcp_servers become Responses mcp tools with their toolset allowlist, web_search keeps its domain filters, user_location, and max_uses, a json_schema output format goes up strict, and a 1h cache_control mark asks OpenAI for its 12h breakpoint TTL

A field with no Responses equivalent (container, allowed_callers, an unknown speed, a toolset denylist, defer_loading, max_uses next to another built-in tool) answers 400 UnsupportedParamsError naming every such field, and drop_params drops them instead

strict_json_schema moves to base_utils so the Codex harness, the chat-completions bridge, and the Responses bridge share one walker, which now leaves property names and enum, const, and examples values alone

* fix(openai): keep the 1h cache ttl to the Responses API, since Chat Completions rejects a breakpoint ttl

* test(openai): expect the 12h breakpoint ttl a 1h cache mark now sends on the Responses wire

* refactor(anthropic): read the new /v1/messages fields through typed views

* fix(anthropic): keep schema refs and maps in strict output, and answer 400 for a container id

The bridge goes back to the strict-schema helper from #51337, so a root $ref keeps its $defs and a map keeps its
value schema on every provider. A container id string and a malformed mcp_servers entry now answer 400, or are
dropped under drop_params, instead of a 500

* fix(anthropic): leave out speed and container when additional_drop_params lists them

* fix(anthropic): reject or map the remaining /v1/messages fields on the OpenAI bridge and redact the MCP authorization

top_k and inference_geo have no Responses equivalent, so they now answer 400 like container unless drop_params
or additional_drop_params drops them, instead of a silent 200. An mcp_toolset that names no mcp_servers entry
answers 400 the same way. The error says to set drop_params: true in the model's litellm_params or under
litellm_settings.

A forwarded service_tier of auto no longer beats speed fast, since auto asks for nothing specific. A top-level
cache_control marks the last block of the conversation the way Anthropic caches it, and an mcp_call output comes
back as mcp_tool_use and mcp_tool_result blocks that replay on the next turn.

The server token goes out as the Responses mcp tool's authorization field, so both redactors now scrub a value
under a quoted authorization key in JSON or a Python repr. A value litellm already masked, like the Authorization
header in the JSON debug log, keeps its hint, and an Authorization header name is left alone.

* fix(anthropic): leave the top-level cache mark off when the deployment drops cache_control

* fix(proxy): count mcp_servers by name in the /v1/messages tool allowlist

* fix(logging): redact MCP server tokens from logged model parameters

The standard logging payload copied tools and mcp_servers into
model_parameters as sent, so an MCP server's authorization or
authorization_token reached every logging callback in plain text.

* fix(anthropic): keep the Messages container field read-only

Mark AnthropicMessagesRequestOptionalParams.container ReadOnly and pass it when the Responses adapter builds its request instead of setting it afterwards

* fix(anthropic): send open schemas non-strict, guard MCP blocks, and narrow the authorization log pattern

OpenAI strict structured outputs reject a map or a free-form object, so a
Messages output schema that leaves an object open now goes to the Responses
API with strict false instead of answering 400.

Guardrails on /v1/messages now read mcp_tool_use input and mcp_tool_result
text in requests and replies, and write a masked result back, the way they
already handle tool_use and tool_result. That covers replayed history too.

The quoted authorization log pattern now needs a word boundary and skips
null, None and booleans, so keys like requires_authorization log as sent.

* fix(anthropic): pair a replayed MCP result with its use by id and keep a top-level cache mark before a prefill

* fix(redaction): redact an MCP authorization value that only starts with null or a boolean

The exception for a literal null, None, true or false authorization value now needs the whole value to be that literal, so a token such as null-<rest> is redacted in Python and Rust

* fix(anthropic): send a structured output schema non-strict when OpenAI strict mode would reject it

* fix(anthropic): resend a web search without domain filters when OpenAI refuses them under drop_params

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-25 19:30:01 +00:00
..
chat fix(llms): send later system messages as user turns for models declared system-first (#54347) 2026-11-25 11:48:27 +00:00
completion fix(openai): relay param and plain message from OpenAI-compatible backend errors (#53217) 2026-11-20 15:53:54 -08:00
decisions fix(decisions): match OpenAI format answers to questions by name (#52597) 2026-11-18 12:55:45 -08:00
embeddings fix(gemini): support explicit text in embedding inputs (#53135) 2026-11-20 11:05:11 -08:00
evals fix(llms): join api_base and route with one shared helper (#47535) 2026-10-21 06:59:32 +00:00
image_generation refactor(images): remove dall-e-2 and dall-e-3 code paths (#48703) 2026-10-28 17:48:09 -07:00
image_variations fix(openai): keep the upstream error body on e.response for OpenAI and Azure errors (#49079) 2026-10-29 23:30:02 -07:00
live feat(realtime)!: serve GPT-Live over WebRTC with sideband attach, and bill WebRTC calls from a proxy sideband (#53282) 2026-11-21 22:49:26 -08:00
realtime feat(realtime)!: support latest OpenAI audio models (#35600) 2026-11-03 07:27:52 +00:00
responses fix(anthropic): map /v1/messages fields onto OpenAI Responses equivalents or reject them (#54173) 2026-11-25 19:30:01 +00:00
speech
transcriptions test(groq): tell cost lookups the Whisper row changed in the catalog rate test (#54252) 2026-11-24 21:10:12 +00:00
vector_store_files
vector_stores
videos feat(videos): add first-class OpenRouter video request fields (#50319) 2026-11-06 16:50:48 -08:00
__init__.py
test_cost_calculation.py feat(fal_ai): bill fal video clips by duration and resolution (#51679) 2026-11-13 12:55:55 -08:00
test_data_residency.py feat(openai): bill gov.api.openai.com FedRAMP endpoint with 1.1x uplift (#49951) 2026-11-04 08:57:42 -08:00
test_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
test_is_model_gpt_5_model.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_o_series_transformation.py fix(openai): drop or refuse an o-series reasoning_effort level the model map turns off (#54066) 2026-11-24 06:42:03 -08:00
test_openai.py fix(openai): preserve omitted headers for chat and embeddings (#53132) 2026-11-20 10:29:22 -08:00
test_openai_audio_speech.py fix(cost): bill OpenAI token-priced aac and flac speech on the length of the returned audio (#53308) 2026-11-21 19:53:23 +00:00
test_openai_authentication_error.py
test_openai_common_utils.py fix(router,files,batches)!: never resend a file or batch create the provider may already have (#51315) 2026-11-25 07:20:51 +00:00
test_openai_empty_response.py
test_openai_file_content_streaming.py
test_openai_image_edit_transformation.py fix(images): send image_edit markup as a multipart file part (#53815) 2026-11-25 04:14:57 +00:00
test_openai_workload_identity.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_organization_costs.py
test_use_chat_completions_api_no_leak.py