litellm/tests/unit/llms
ryan-crabbe-berri c29a4f56a3
fix(gemini)!: honor supports_sampling_params on the Gemini and Vertex path and flag Gemini 3.6 Flash, 3.5 Flash-Lite and later (#47645)
* fix(gemini)!: honor supports_sampling_params on the Gemini and Vertex path and flag Gemini 3.6 Flash, 3.5 Flash-Lite and later

Google ignores temperature, top_p and top_k on Gemini 3.6 Flash, Gemini 3.5
Flash-Lite and every later Gemini release, and says a later generation will
return 400 for them. The model map now carries supports_sampling_params: false
on those rows, and the Gemini and Vertex transformation reads the flag the way
the Anthropic and Bedrock paths already do, dropping the params under
drop_params and otherwise raising the client-side 400 that names drop_params

BREAKING CHANGE: a request that sends temperature, top_p or top_k to a flagged
Gemini model without drop_params now gets a 400 instead of a 200 whose
sampling params Google silently ignored

Fixes #47015

* fix(gemini): gate the passed-through top_k where the request body is built and keep allowed_openai_params working

top_k is a provider-specific kwarg that never reaches the OpenAI param mapping,
so the flag has to be applied while the Gemini request body is built, the same
boundary Anthropic uses. The mapping now skips a flagged sampling param instead
of raising, because the shared unsupported-param check already returns the 400
that names drop_params, and a param the caller lists in allowed_openai_params
is forwarded verbatim as that 400 promises

* fix(gemini): filter top_k out of the generation config instead of mutating optional_params

* test(gemini): type the sampling-flag twin test and keep its locals out of the loop body

* fix(vertex_ai): reject or drop sampling params on batch rows for flagged Gemini models

The batch JSONL wrapper calls map_openai_params directly and skips get_optional_params,
so a flagged model's temperature, top_p and top_k vanished from the uploaded row with no
400. Batch rows now get the same contract as a real-time call: a 400 naming drop_params,
or the knobs dropped when litellm.drop_params is on

* fix(vertex_ai): ignore null sampling knobs on batch rows for flagged Gemini models

A batch row carrying temperature: null, top_p: null or top_k: null means no
override, the same as on a real-time call, so the row is no longer refused
with a 400 and the null knobs are simply not forwarded
2026-10-20 23:51:55 +00:00
..
a2a
aiml
aiohttp_openai
anthropic
apiserpent
aws_polly
azure
azure_ai
base_llm
baseten
bedrock
bedrock_mantle
black_forest_labs
brave
bytez
cerebras
chat
chatgpt
clarifai
claude_code
cloudflare
codex
cohere
cometapi
compactifai
crusoe
custom_httpx
dashscope
databricks
dataforseo
datarobot
deepagents
deepgram
deepinfra
deepseek
docker_model_runner
duckduckgo
e2b
edenai
elevenlabs
exa_ai
fal_ai
fastcrw
featherless_ai
firecrawl
fireworks_ai
friendliai
gdc
gemini
gigachat
github_copilot
google_pse
gradient_ai
groq
heroku
hosted_vllm
huggingface
hyperbolic
inception
infinity
jina_ai
lambda_ai
langflow
langgraph
laya
lemonade
linkup
litellm_proxy
llamafile
lm_studio
manus
meta
meta_llama
microsoft_365_copilot
milvus
minimax
mistral
modelscope
mongodb
moonshot
nadir
nebius
neosantara
nimble
nlp_cloud
novita
nscale
nvidia_nim
nvidia_riva
oci
ocr
ollama
oobabooga
openai
openai_like
opencode
openrouter
opensandbox
ovhcloud
parallel_ai
parasail
pass_through
perplexity
pg_vector
pi
publicai
ragflow
recraft
reducto
replicate
runwayml
s3_vectors
sagemaker
sail
sambanova
sap
scaledown
scaleway
searchapi
searxng
serper
snowflake
soniox
stability
strands_decider
tavily
tencent
tinyfish
together_ai
tool_loop
topaz
triton
v0
valkey
vercel_ai_gateway
vertex_ai
vllm
volcengine
voyage
wandb
watsonx
xai
xinference
you_com
zai
__init__.py
test_cache_control_and_reasoning.py
test_custom_llm.py
test_file_content_block.py
test_file_search_responses.py
test_lifecycle_fix.py
test_oss_decision.py
test_polling_url_origin_match.py
test_predibase_transformation.py