Repository navigation
feat(gemini): support gemini-decision-1 on /v1/decisions and /v1/systemone (#51220) [lts/1.108.x] - #53696
Conversation
…/decisions and /v1/systemone (BerriAI#46539) Backport of BerriAI#46539 to lts/1.108.x (prerequisite of BerriAI#51220). Cherry-picked from caad4d6 (main). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Backport of BerriAI#47508 to lts/1.108.x (prerequisite of BerriAI#51220). Cherry-picked from 81d8c9a (main). Minimal hand-port of response validation, omitting unrelated pricing and observability changes. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…I#48261) Backport of BerriAI#48261 to lts/1.108.x (prerequisite of BerriAI#51220). Cherry-picked from cb65a21 (main). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…emone (BerriAI#51220) * feat(gemini): add Decisions API support Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(gemini): add Decisions quotas and test package marker Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(gemini): bound decisions image downloads * fix(gemini): preserve image order and bounded cache reuse * test(gemini): cover cached image budgets and text messages * refactor(gemini): iterate bounded image downloads * fix(gemini): require explicit keys for decisions base overrides * refactor(gemini): infer downloaded image types * test(proxy): accept either metrics startup failure on occupied ports * fix(llms-types): remove duplicate compact beta match arm * fix(gemini): validate caller credentials before merging deployment keys --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Backport of BerriAI#51220 to lts/1.108.x. Cherry-picked from 7461a99 (main). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Canonicalize caller connection overrides before reading deployment defaults, retaining the pre-merge credential guard in both router paths. Cover both URL parameter names and both Decisions surfaces in sync and async calls. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The Gemini Decisions model introduced by the backport uses the decisions mode already accepted on main. Extend the LTS schema validator to match. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…rt_51220_lts_1_108_x # Conflicts: # litellm/llms/openrouter/decisions/transformation.py # tests/unit/decisions/test_main.py
(cherry picked from commit 6b83e79)
… on main Drop the Router override that let a caller base_url replace a deployment's own api_base. Main's prepare_call reads base_url only when no api_base is set, and the router now merges the caller kwargs the same way, so the LTS line matches main's precedence. Also drop the list-form score legend normalization from the BerriAI#47508 port. It came from BerriAI#46523 on main, and neither LTS provider that reaches it (Gemini, TypeSafe) sends a list legend. Cover the sync Router credential guard for both URL parameter names.
…rt_51220_lts_1_108_x Keeps main's DecisionsResponseValidationError beside the line's input_json, safety_identifier and missing-confidence handling, and ports BerriAI#52805's Gemini hunk so Gemini skips input_json parts the line now has
Gemini's systemone answers carry no model, so a direct call and a litellm_proxy hop answered model null while the decisions shape answered gemini/gemini-decision-1. A Gemini systemone call now fills in the provider and model it was sent to when the answer leaves it out (cherry picked from commit b828c1b)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…backport_51220_lts_1_108_x
…rt_51220_lts_1_108_x # Conflicts: # litellm/litellm_core_utils/prompt_templates/image_handling.py
…rt_51220_lts_1_108_x
|
|
PR overviewThe PR adds support for gemini-decision-1 on the /v1/decisions and /v1/systemone endpoints, with changes touching image handling. One issue remains open in the asynchronous image reader: compressed responses can expand in memory before the response-size budget is enforced. A small compressed response was demonstrated to cause allocations well beyond that budget before rejection, creating a potential resource-exhaustion path when compressed image responses are processed. No issues have been addressed yet. Open issues (1)
Fixed/addressed: 0 · PR risk: 5/10 Reviews
|
| follow_redirects=follow_redirects, | ||
| timeout=USE_CLIENT_DEFAULT if timeout is None else timeout, | ||
| ) as response: | ||
| return _with_body_prefix(response, await anext(response.aiter_bytes(max_response_bytes), b"")) |
There was a problem hiding this comment.
Medium: Compressed images bypass the memory budget
aiter_bytes(max_response_bytes) caps yielded chunk size, not decompression: HTTPX expands each raw chunk before slicing it, and this reader still accepts compressed responses (a streaming check expanded a 32 KB gzip response to 32 MiB, with roughly 128 MiB peak allocations, before the 20 MiB budget check rejected it). Request Accept-Encoding: identity and reject non-identity Content-Encoding before reading, as the sync reader does, or use a bounded decoder.
There was a problem hiding this comment.
Valid, and main has the same reader. The fix is tracked to land on main first and then this line, keeping both in step
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
[Medium impact] No new blocking issue remains beyond the two explicitly deferred findings
|
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 707fe7b. Configure here.
…on 1 (#3321) The backport (BerriAI/litellm#53696) shipped gemini-decision-1 in v1.108.16 on the 1.108.x LTS line, but the availability table and the Gemini setup section only named v1.111.0-rc.1. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Backport of #51220 to lts/1.108.x, so LTS users can call
gemini/gemini-decision-1on /v1/decisions and /v1/systemone with its cost computed. Today the LTS proxy answers 400 with "Unknown Decisions provider 'gemini'"Details
TLDR
Problem this solves:
gemini/is not a decisions provider on 1.108, so both routes return 400How it solves it:
5c40308de4drops the listlegendhandling it carried from feat: add Nace Drex decisions provider #46523e18b03d84cRouterruns the same check before deployment credentials merge, sync and async3b493090dcresolves its conflict inlitellm/decisions/call.pyby reading a callerbase_urlas an alias ofapi_base, the part of fix(decisions): honor base_url for custom backends #48505 that feat(gemini): support gemini-decision-1 on /v1/decisions and /v1/systemone #51220 builds onc43fbfb62btests both names, sync and async.5c40308de4drops theRouteroverride it first added0016853f53addsdecisionsto the LTS pricing-schema validator, matching main5efdf6d8c8,75d469b96a,c43d64e87dand707fe7bfafmerge the line tip. Their conflicts (OpenRouter's cost helper,test_main.py,call.py, the base transformation,image_handling.py) keep the line's code plus this PR'susage is Noneguards to the cost helper and Vercel AI Gateway, since fix(decisions): preserve missing native usage (#48147) #48261 makes usage optional. The second also moves the missing confidence error to main's error class and carries fix(decisions): accept OpenAI input_json content parts on /v1/decisions #52805's Gemini part, left out of fix(decisions): accept OpenAI input_json content parts on /v1/decisions #52807 because the line had no Gemini config739be2b9eepicks fix(decisions): keep systemone confidence, extra fields and proxy cost on litellm_proxy calls #53195's Gemini commit, left out of fix(decisions): support the litellm_proxy provider (#51611, #53195) [lts/1.108.x] #53196 for the same reason, so a Gemini /v1/systemone answer names its model.1e31c3a084takes in2cfaab9930, another merge with the same result830405d886picks feat(gemini): support gemini-decision-1 on /v1/decisions and /v1/systemone #51220's Prometheus test repair. Its Rust lint fix is skipped, since the line lacks the duplicate arm it removesIntentional product changes, all matching main:
base_urlnow redirects every Decisions provider the way a callerapi_basealready did on the line, so a deployment opted intobase_urlalone honors it. A deployment's ownapi_basestill wins. The proxy still refuses both unlessallow_client_side_credentialsor a per-deployment opt-in allows themusage: nullon /v1/systemone instead of zeros when it sends no usage. Those calls get no cost headers. /v1/decisions still reports zerosUser Flow
Before: a developer with a
gemini/gemini-decision-1deployment on 1.108 cannot use itUnknown Decisions provider 'gemini', same for /v1/systemoneAfter: the same request returns a calibrated answer
Linear ticket
Resolves LIT-10909
Pre-Submission checklist
Screenshots / Proof of Fix
Both proxies ran the config below with
--num_workers 2, no database, and real Gemini and TypeSafe keys.$LPORTis a local listener that mimics both and logs each path and key, printing only synthetic keys.allow_client_side_credentialsis off, so only opted-in deployments take a caller URLProxy config
api_keyapi_base, callerbase_urland keyusage: null, no costinput_jsoninput_jsoninput_json,drop_paramsCaller URL rows ran with
api_baseand withbase_urlBefore, commands and raw output
After, commands and raw output
Tip-only cases, commands and raw output
These rows ran only at the tip, since the line answers 400 to every Gemini call. The last allows the listener host in
user_url_allowed_hostsapi_base, callerapi_baseand keyTests and gates
The 37 are listed with both reruns in affected_unit_tests.txt
Other open lts/1.108.x PRs, #52147 and #53585 the closest, share
router.py,utils.pyor the cost maps. None of them ships Gemini Decisions/live-pr-risk on the non-pick commits (75d469b, 5c40308, c43fbfb, c43d64e) at 707fe7b
c43d64e87dresolvesimage_handling.pyas main has it, the line's uncompressed-only download plus this PR's size budget. Breaking: none found. Backward incompatible: none from these commits. The three changes under Intentional product changes come from the picks and are on main through #48261, #47508 and #48505Same rig as above plus a
litellm_proxyhop to the same proxy, a group with Gemini andopenai/gpt-6-luna, and agemini/gemini-3.8-flashchat deployment reading clips and images from a local media server, both legs with real keys. Raw output, before and afterinput_jsonwithdrop_paramsusage: null(#48261)input_json, 6 callsapi_baseand keyapi_baseor notdrop_paramsdrop_paramsRegression risk: a
use_litellm_proxyGemini deployment was not run live. Not verified: spend rows, since the rig had no database. These commits do not touch themType
🆕 New Feature
Caveats (if any)
High
Medium
use_litellm_proxydeployment whose model prefix has no Decisions support answers 400 instead of forwarding when the caller sendsapi_base. Same on main, fix tracked there firstapi_baseand its key only inGEMINI_API_KEYanswers 400 on every callapi_key: os.environ/GEMINI_API_KEYor usingGEMINI_API_BASEavoids itapi_base, a callerbase_urlis ignored, yet the Gemini check still wantsapi_key, which then goes to the deployment host. Same on mainLow
legendis a list still answers 500 on the line, while main accepts it since feat: add Nace Drex decisions provider #46523. Neither Gemini nor TypeSafe sends onex-litellm-model-api-baseshows Gemini's generateContent URL instead of /v1beta/decisions. Same on mainDecisions
UnsupportedDecisionsRequestbranch in_logged_request_bodycannot run. It stays because the line'sir_to_systemone_requestreturns that unionbase_urlworks for every Decisions provider, as on main since fix(decisions): honor base_url for custom backends #48505, instead of only for Gemini. A Gemini-only alias would makecall.pydiffer from main, so later picks would conflict there, and the proxy gate on both names is the same either wayBugbot summary