litellm/tests/unit/llms/openai_like
tavren27 339280356f
fix(responses): reject background on bridged chat completions unless the provider streams it live (#54357)
* fix(responses): reject background on chat completions bridged to the Responses API

A background run answers with a queued response and no output, so the chat bridge
failed with a 500 after OpenAI had already started a billed run, and retries started
more. The bridge now answers 400 UnsupportedParamsError before any upstream call,
unless drop_params, litellm.drop_params, or additional_drop_params drops it, and it
never sends background upstream.

* fix(responses): keep background on streamed chat completions bridged to the Responses API

OpenAI streams a background run's events and the chat bridge turns them into chunks, so a streamed request with background worked before. The background check now applies only to non-streamed requests, where the run's output never reaches the caller.

* fix(responses): reject background on bridged chat completions unless the provider streams it live

A faked stream (fake_stream, or a model without native streaming) still sends a non-streamed request upstream, so background there starts a run /chat/completions cannot retrieve. Treat it like a non-streamed call: drop under drop_params, answer 400 otherwise.

* fix(responses): keep background on providers that strip it and send background false as set

ChatGPT and Bedrock Runtime drop background before the upstream call, so the
chat bridge now asks each provider's Responses config whether it forwards
background and skips the check when it does not. background: false reaches the
provider unchanged, extra_body stream decides whether the run streams live, and
the 400 names additional_drop_params.

* fix(responses): check background with the dispatch's own Responses config

The guard now asks the same resolver the Responses dispatch uses, so a
deployment that passes /v1/responses through is guarded and an azure_ai
base that does not serve the OpenAI v1 API keeps its chat fallback

* fix(responses): let providers that answer background inline keep it, and read faked streams from the dispatch config

OpenRouter, refuseless, openinfer and zerogpu answer a background: true
Responses call in the same reply, so bridged chat completions there keep
sending it instead of getting a 400. The fake-stream check now resolves the
same Responses config the dispatch uses, so a pass-through deployment on a
model without native streaming is refused when it streams with background.

* refactor(responses): run the background check inside the bridge params helper

* fix(responses): check background on Eden AI only where its upstream starts a run

* fix(responses): refuse background only on servers known to start a run

The check now refuses a bridged chat completion with background only where the
server is known to start a run, which is OpenAI and Azure hosts plus the
providers that were seen to queue one. Any other server gets background as it
did before. When such a server answers with an unfinished run, the call ends
in one 400 after that single run, so the Router does not retry it into more.

drop_params and additional_drop_params drop background on every bridged call
that does not stream live. Streams are judged by the Responses config that
serves the call, also when the call is bridged late for its tools, and the
fake-stream timeout goes back to the behavior on main

* fix(responses): judge background by the server a supplied OpenAI client points at

A caller that passes client=OpenAI(base_url=...) sends the request to that base URL, so the background check now reads it instead of OpenAI's default host

* fix(responses): count Azure cognitiveservices hosts as servers that start background runs

An openai/ or custom_openai/ deployment on a *.cognitiveservices.azure.com Azure OpenAI v1 host started one billed run before the 400, so the check now knows that host too

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-12-01 03:01:25 +00:00
..
chat fix(openai_like): end an async stream cleanly when the connection drops after the finish (#54565) 2026-11-26 07:48:41 +00:00
embedding test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
messages feat(providers): add Sarvam Token Factory v2 models (#49792) 2026-11-18 13:19:05 +00:00
responses test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
__init__.py test: add package initializers to migrated unit test directories 2026-09-20 11:52:07 +00:00
test_abliteration_provider.py feat(abliteration): add model pricing and capabilities (#48498) 2026-10-26 18:08:29 -07:00
test_aiand_provider.py fix(aiand)!: show ai&'s name and logo, and sync ai&'s model list (#49158) 2026-10-30 10:55:26 -07:00
test_assemblyai_provider.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_charity_engine.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_cognition_provider.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_coralbricks_provider.py feat(providers): add CoralBricks as a native provider (#44700) 2026-10-12 21:56:59 +00:00
test_cortecs_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_dynamic_config.py fix(responses): reject background on bridged chat completions unless the provider streams it live (#54357) 2026-12-01 03:01:25 +00:00
test_empiriolabs_provider.py feat: update EmpirioLabs models in model_prices_and_context_window.json (#49980) 2026-11-04 20:11:52 +00:00
test_hostinger_router_provider.py feat!: add Hostinger Router as an OpenAI-compatible provider (#44863) 2026-10-31 00:38:45 -07:00
test_huawei_maas_provider.py feat(huawei_maas): add Huawei Cloud MaaS provider and cost map rows (#54225) 2026-11-24 18:24:05 -08:00
test_inferenceapis_provider.py feat(providers): add Inference APIs as OpenAI-compatible provider (#41669) 2026-10-15 08:17:36 -07:00
test_json_loader.py fix(crusoe): update base URL to current endpoint (#33121) 2026-10-15 19:10:58 -07:00
test_json_providers.py feat(provider)!: add ResetData and stop sending OPENAI_API_KEY to keyless JSON-configured providers (#50819) 2026-11-20 22:20:25 -08:00
test_kyma_provider.py fix(cost): split a provider-reported total between input and output by the cost map rate ratio (#49357) 2026-10-31 09:04:50 -07:00
test_libertai_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_meta_provider.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_model_info.py fix(openrouter): report the context window and output cap from OpenRouter's catalog (#54046) 2026-11-24 04:37:30 -08:00
test_openinfer_provider.py refactor(cost-map): drop the legacy max_tokens field in favor of max_input_tokens and max_output_tokens (#48471) 2026-10-26 17:03:05 -07:00
test_perplexity_orchestrator_provider.py feat(perplexity): add the Perplexity Orchestrator provider with cost tracking (#53583) 2026-11-23 07:17:47 +00:00
test_pinstripes_provider.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_prism_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_provider_affinity_forwarding.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_refuseless_provider.py feat(refuseless): add provider and model pricing (#48497) 2026-10-26 18:08:42 -07:00
test_reka_provider.py feat: generate provider_endpoints_support.json from the cost map (#48619) 2026-10-27 12:06:55 -07:00
test_resetdata_provider.py feat(provider)!: add ResetData and stop sending OPENAI_API_KEY to keyless JSON-configured providers (#50819) 2026-11-20 22:20:25 -08:00
test_sarvam_provider.py feat(providers): add Sarvam Token Factory v2 models (#49792) 2026-11-18 13:19:05 +00:00
test_scx_ai_provider.py feat(cost-map): add scx-ai DeepSeek-V4.1-flash, GLM-5.3 and Kimi-K3 (#46496) 2026-10-14 20:22:16 -07:00
test_streamlake_provider.py feat!: add StreamLake provider metadata (#41006) 2026-10-28 20:19:06 -07:00
test_tensormesh_provider.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vispark_provider.py feat(litellm): add Vispark provider with Vision Small/Medium/Large (#41192) 2026-11-17 00:48:52 -08:00
test_wally_provider.py feat(providers): add Wally as an OpenAI-compatible provider (#45662) 2026-11-04 00:21:25 +00:00
test_xiaomi_mimo.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_zerogpu_provider.py feat(providers): add ZeroGPU as an OpenAI-compatible provider (#43874) 2026-10-28 12:40:32 -07:00