Skip to content

fix(vertex_ai): send service_tier to Vertex Gemini as tier headers (#34959) [lts/1.108.x] - #53428

Merged
mateo-berri merged 15 commits into
BerriAI:lts/1.108.xfrom
martenj4:litellm_backport_34959_lts_1_108_x
Nov 23, 2026
Merged

mateo-berri merged 15 commits into
BerriAI:lts/1.108.xfrom
martenj4:litellm_backport_34959_lts_1_108_x

Conversation

@martenj4

@martenj4 martenj4 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

On the 1.108 LTS line, Vertex Gemini answers 400 to every service_tier value, since litellm sends a body serviceTier field that Vertex rejects

This brings the same fix as #34959 to the line

Details

TLDR

Problem this solves:

  • Vertex Gemini answers 400 to every service_tier value, since litellm sends a body serviceTier field that Vertex rejects
  • On Vertex, auto turned into priority, and SERVICE_TIER_FLEX style values reached Vertex unchanged

How it solves it:

  • Vertex gets priority and flex as the X-Vertex-AI-LLM-Shared-Request-Type header, so Provisioned Throughput is used first
  • AI Studio (gemini/) keeps the serviceTier body field, and auto still maps to priority there, as before
  • On Vertex, auto, default and standard send no tier, and standard_only means standard
  • Vertex responses and every stream chunk report the served tier from usageMetadata.trafficType
  • A tier header the caller set, in any letter case, wins over service_tier
  • An unknown tier such as scale answers 400 unless drop_params is set, and so does priority or flex on a Vertex batch row
  • A batch row's or deployment's drop_params now drops an unknown tier and hosted MCP tools, as on main
Backport checklist
  • fix(vertex_ai): send service_tier to Vertex Gemini as tier headers #34959 is in review on main. The line picks each of its 9 branch commits with cherry-pick -x, as the table below lists. Every pick changes the same lines as its main commit except 60716324b5 and acc59f5e6a. In 60716324b5 the line lacked main's deployment drop_params plumbing for batch rows (_map_openai_to_vertex_params(deployment_drop_params=...) and the partial that passes it), so the pick brings that plumbing over as main has it, and leaves out two main-only tests for thinking levels and TTS voice keys. In acc59f5e6a the batch row builder keeps the line's openai_request_body name, and _map_traffic_type_to_service_tier keeps the line's object parameter type
  • Two commits are not picks. The line's batch row builder passed drop_params=False to map_openai_params, so a row's or deployment's drop_params never reached the tier check or the hosted MCP tool filter, and cfef3edae2 passes the resolved value, as fix(vertex_ai): send service_tier to Vertex Gemini as tier headers #34959 does on main. The line's stream wrapper built the finish_reason chunk without the tier the earlier chunks carried, and 11b09d19ff takes the last tier the stream reported, as main does. The line's /v1/files upload with a model also kept the deployment's drop_params out of the request, and 11b09d19ff merges it in, as main does since feat(vertex-ai)!: support gemini 3.1 flash tts #31915. d48a603fba, 6ac64d9a8b, 3941eae668 and 2f66d37300 merge the line, the last at 9fca0777db, and three of them resolve a small conflict each
  • The picked tests pass on the line (822 passed in the four picked test files, and 551 in the two cost calculator test files, which cover the shared trafficType table, at acc59f5e6a), and the new cases fail without the fix. At cfef3edae2 the 12 unit test files that import the changed module pass, run with the batch and Vertex Gemini test folders (3518 passed), and its 3 new batch row cases fail without it. At 11b09d19ff the 517 affected test files pass, apart from 29 flakes that pass alone and one clock-dependent test that fails on the line too, and its 6 new stream cases and 2 upload cases fail without it. At 2f66d37300 the PR's test folders pass (3788 passed)
  • No dependency moves
  • No enterprise/ or litellm-proxy-extras/ change, so no package bump
  • /gauntlet-mini ran on the line at 63bb90b5c2 and 90922104c2. Its findings were fixed on main and are in the later picks
  • cfef3edae2 and 11b09d19ff pass /live-pr-risk
Main commit LTS commit
4f4c0ba0bf e1e7a6f81b
e1aed51992 e1e01b619d
81756c0c98 6a979084db
68348e680e d834a09ef9
cd73861826 90922104c2
044c09d9a6 4204f74fcd
f9d363b18b 60716324b5
96fd436be3 8daaaaf428
1e00622b2d acc59f5e6a

User Flow

Before: a developer asking Vertex Gemini for the priority tier gets a 400 instead of an answer

  1. The admin adds vertex_ai/gemini-3.8-flash to config.yaml and starts the proxy
  2. The developer sends POST http://localhost:4000/v1/chat/completions with "service_tier": "priority"
  3. The proxy answers 400 Invalid value at 'service_tier'

After: the same request is served at the asked tier, and the response says which tier

  1. The admin adds vertex_ai/gemini-3.8-flash to config.yaml and starts the proxy
  2. The developer sends the same POST http://localhost:4000/v1/chat/completions with "service_tier": "priority"
  3. The proxy answers 200 with "service_tier": "priority", and the x-litellm-response-cost header shows the priority rate
  4. auto answers 200 with "service_tier": "default" at the standard rate, and "scale" answers 400 listing the allowed values

Relevant issues

Backport of #34959 for #34914

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

One live smoke per fix, with real calls to Vertex AI (global) and Google AI Studio on gemini-3.8-flash, 2 uvicorn workers per proxy and no database. Before is lts/1.108.x at 2e46e4c77f, and After is acc59f5e6a. The line is now at 9fca0777db, merged in 2f66d37300, and the newest stream legs include its #53441 stream fix. Each sent: line is what a recorder in front of Google saw

Case Before After
Vertex priority 400 200 priority, priority rate
Vertex flex 400 200 flex, flex rate
Vertex auto 400 200 default, standard rate
Vertex standard_only 400 200 default
Vertex scale 400 from Vertex 400 from litellm
Vertex stream priority, flex 400 200, content and usage chunks carry the tier
Caller flex header, priority 400 200 flex, flex rate
AI Studio auto 200 priority 200 priority
AI Studio default sends standard sends standard
Batch chat or /v1/responses row priority uploads serviceTier: priority 400
Batch chat or /v1/responses row, drop_params uploads serviceTier: priority uploads, no tier, job completes
Batch row standard uploads serviceTier: standard uploads, no tier, job completes
Batch row scale uploads serviceTier: scale 400
Batch row scale, drop_params uploads serviceTier: scale uploads, no tier
Batch row hosted MCP tool, drop_params 400 uploads, MCP tool dropped
Smoke at the line tip `9fca0777db` (Before) and the merge `2f66d37300` (After), same proxy setup and helpers as below, plus `chat_tier`

The Before tier_chunks leg prints empty lists because Vertex answered 400, which its streamGenerateContent sent: line shows

Both legs load the same Rust bridge build from an earlier line commit. The line's newer Rust change is in the Vertex /v1/messages transform, which none of these cases call

chat_tier() {
  curl -sS "$BASE/v1/chat/completions" -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d "{\"model\":\"$1\",$say${2:+,\"service_tier\":\"$2\"}}" \
    | jq -c '{service_tier: (.service_tier // null), tokens: (.usage.total_tokens // null), error: (.error.message // null | if . then .[0:160] else null end)}'
}
upload_delete() {
  local out id
  out=$(upload_for $1 $2); print -r -- "$out"
  id=$(print -r -- "$out" | jq -r '.id // empty')
  [[ -n $id ]] && print -r -- "cleanup: $(delete_file $id)"
}
label=smoke4before tree=/Users/mateo/Development/litellm-worktrees/work-1363dde9-base commit=9fca0777db staged= port=21013
workers: 3 children of proxy pid 57307
$ chat_tier vertex-flash priority
{"service_tier":null,"tokens":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.googleapis.c"}

$ chat_tier vertex-flash flex
{"service_tier":null,"tokens":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.googleapis.c"}

$ chat_tier vertex-flash auto
{"service_tier":null,"tokens":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.googleapis.c"}

$ chat_tier vertex-flash
{"service_tier":null,"tokens":51,"error":null}

$ chat_tier studio-flash auto
{"service_tier":"priority","tokens":53,"error":null}

$ tier_chunks vertex-flash priority
{"finish_chunk_tier":[],"tier_per_chunk":[],"usage_tokens":null}

$ upload_delete lpr-scale.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvZ29vZ2xlL21vZGVscy9nZW1pbmktMy44LWZsYXNoL2ZiNWQ0Nzk5LWE5OTUtNGJmMS1hZDIzLWVlMGFmOTcwZWFhNjttb2RlbCx2ZXJ0ZXgtYmF0Y2gtZHJvcA","error":null}
cleanup: {"deleted":true,"error":null}
sent: gemini-3.8-flash:generateContent header=None body serviceTier=priority -> 400
sent: gemini-3.8-flash:generateContent header=None body serviceTier=flex -> 400
sent: gemini-3.8-flash:generateContent header=None body serviceTier=priority -> 400
sent: gemini-3.8-flash:generateContent header=None body serviceTier=None -> 200
sent: gemini-3.8-flash:streamGenerateContent header=None body serviceTier=priority -> 400
sent: gemini-3.8-flash:generateContent header=None body serviceTier=priority -> 200

label=smoke4after tree=/Users/mateo/Development/litellm-worktrees/work-1363dde9-head commit=2f66d37300 staged= port=31570
workers: 3 children of proxy pid 44896
$ chat_tier vertex-flash priority
{"service_tier":"priority","tokens":51,"error":null}

$ chat_tier vertex-flash flex
{"service_tier":"flex","tokens":51,"error":null}

$ chat_tier vertex-flash auto
{"service_tier":"default","tokens":52,"error":null}

$ chat_tier vertex-flash
{"service_tier":"default","tokens":53,"error":null}

$ chat_tier studio-flash auto
{"service_tier":"priority","tokens":54,"error":null}

$ tier_chunks vertex-flash priority
{"finish_chunk_tier":["priority"],"tier_per_chunk":["priority","priority","priority"],"usage_tokens":53}

$ upload_delete lpr-scale.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvZ29vZ2xlL21vZGVscy9nZW1pbmktMy44LWZsYXNoLzY0MzlkZWQwLWQ5ZGMtNDQ2NC1hMjYyLTgzZDIxODE5MDMyNjttb2RlbCx2ZXJ0ZXgtYmF0Y2gtZHJvcA","error":null}
cleanup: {"deleted":true,"error":null}
sent: gemini-3.8-flash:generateContent header=[['x-vertex-ai-llm-shared-request-type', 'priority']] body serviceTier=None -> 200
sent: gemini-3.8-flash:generateContent header=[['x-vertex-ai-llm-shared-request-type', 'flex']] body serviceTier=None -> 200
sent: gemini-3.8-flash:generateContent header=None body serviceTier=None -> 200
sent: gemini-3.8-flash:generateContent header=None body serviceTier=None -> 200
sent: gemini-3.8-flash:streamGenerateContent header=[['x-vertex-ai-llm-shared-request-type', 'priority']] body serviceTier=None -> 200
sent: gemini-3.8-flash:generateContent header=None body serviceTier=priority -> 200
Batch rows read back from GCS at the line tip `9fca0777db` (Before) and the merge `2f66d37300` (After)

Each upload names vertex-batch or vertex-batch-drop (drop_params: true on the deployment). lpr-priority.jsonl is one chat row with "service_tier": "priority", lpr-priority-drop.jsonl adds "drop_params": true to the row, and lpr-standard.jsonl asks for standard. rows.py reads the uploaded object from GCS with the same service account and prints the row's top-level keys. Before, every row keeps serviceTier, even under drop_params, so the row reaches the job with the field. #34959's batch job leg shows such a row failing inside Vertex with unknown enum value. After, priority without drop_params is a 400 at upload, and the other rows carry no tier

upload_readback() {
  local out id gs
  out=$(upload_for $1 $2); print -r -- "$out"
  id=$(print -r -- "$out" | jq -r '.id // empty')
  [[ -z $id ]] && return
  gs=$(print -r -- "${id#file-}" | python3 -c 'import base64,sys; s=sys.stdin.read().strip(); print(base64.urlsafe_b64decode(s+"="*(-len(s)%4)).decode().removeprefix("litellm:").split(";")[0])')
  print -r -- "row: $(python -I rows.py $gs)"
  print -r -- "cleanup: $(delete_file $id)"
}
import json, sys, urllib.parse, urllib.request
import google.auth, google.auth.transport.requests
creds, _ = google.auth.default(scopes=["https://www.googleapis.com/auth/devstorage.read_only"])
creds.refresh(google.auth.transport.requests.Request())
for gs in sys.argv[1:]:
    bucket, _, name = gs.removeprefix("gs://").partition("/")
    req = urllib.request.Request(
        f"https://storage.googleapis.com/storage/v1/b/{bucket}/o/{urllib.parse.quote(name, safe='')}?alt=media",
        headers={"Authorization": f"Bearer {creds.token}"},
    )
    r = json.loads(urllib.request.urlopen(req).read().decode().splitlines()[0])["request"]
    tools = r.get("tools")
    print(json.dumps({"keys": sorted(r), "serviceTier": r.get("serviceTier"), "tools": tools}))
label=rb5before tree=/Users/mateo/Development/litellm-worktrees/work-1363dde9-base commit=9fca0777db staged= port=32080
workers: 3 children of proxy pid 15408
$ upload_readback lpr-priority.jsonl vertex-batch
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels", "serviceTier"], "serviceTier": "priority", "tools": null}
cleanup: {"deleted":true,"error":null}

$ upload_readback lpr-priority-drop.jsonl vertex-batch
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels", "serviceTier"], "serviceTier": "priority", "tools": null}
cleanup: {"deleted":true,"error":null}

$ upload_readback lpr-priority.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels", "serviceTier"], "serviceTier": "priority", "tools": null}
cleanup: {"deleted":true,"error":null}

$ upload_readback lpr-standard.jsonl vertex-batch
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels", "serviceTier"], "serviceTier": "standard", "tools": null}
cleanup: {"deleted":true,"error":null}

done rb5before
label=rb5after tree=/Users/mateo/Development/litellm-worktrees/work-1363dde9-head commit=2f66d37300 staged= port=21034
workers: 3 children of proxy pid 15395
$ upload_readback lpr-priority.jsonl vertex-batch
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Vertex AI batch requests do not support `service_tier`, since batch jobs run on the batch tier. To drop this param, set `litell"}

$ upload_readback lpr-priority-drop.jsonl vertex-batch
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
cleanup: {"deleted":true,"error":null}

$ upload_readback lpr-priority.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
cleanup: {"deleted":true,"error":null}

$ upload_readback lpr-standard.jsonl vertex-batch
{"id":"file-bGl0ZWxsbTp…","error":null}
row: {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
cleanup: {"deleted":true,"error":null}

done rb5after

Before (2e46e4c)

Chat

  1. Run each request below against the Before proxy
Output
$ tier vertex-flash priority
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.go"}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "priority", "upstream_status": 400, "upstream_tier_header": null}

$ tier vertex-flash flex
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.go"}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "flex", "upstream_status": 400, "upstream_tier_header": null}

$ tier vertex-flash auto
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.go"}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "priority", "upstream_status": 400, "upstream_tier_header": null}

$ tier vertex-flash standard_only
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.go"}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "standard_only", "upstream_status": 400, "upstream_tier_header": null}

$ tier vertex-flash scale
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.go"}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "scale", "upstream_status": 400, "upstream_tier_header": null}

$ tier_header vertex-flash "x-vertex-ai-llm-shared-request-type: flex" priority
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.BadRequestError: Vertex_aiException BadRequestError - {\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid value at 'service_tier' (type.go"}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [["x-vertex-ai-llm-shared-request-type", "flex"]], "body_serviceTier": "priority", "upstream_status": 400, "upstream_tier_header": null}

$ tier studio-flash auto
HTTP/1.1 200 OK  cost=0.00031319999999999997  {"service_tier":"priority","usage":{"prompt_tokens":7,"completion_tokens":45},"error":null}
sent: {"full_path": "/models/gemini-3.8-flash:generateContent", "path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "priority", "upstream_status": 200, "upstream_tier_header": "priority"}

$ tier studio-flash default
HTTP/1.1 200 OK  cost=0.0001815  {"service_tier":"default","usage":{"prompt_tokens":7,"completion_tokens":47},"error":null}
sent: {"full_path": "/models/gemini-3.8-flash:generateContent", "path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "standard", "upstream_status": 200, "upstream_tier_header": "standard"}

$ tier studio-flash
HTTP/1.1 200 OK  cost=0.0001815  {"service_tier":"default","usage":{"prompt_tokens":7,"completion_tokens":47},"error":null}
sent: {"full_path": "/models/gemini-3.8-flash:generateContent", "path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": "standard"}

Batch upload

  1. Upload each batch file with POST /v1/files and custom-llm-provider: vertex_ai
Output
$ upload_batch batch-priority.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/dd1e52b5-210a-4738-93c6-91a07927dddb","error":null}

$ upload_batch batch-priority-drop.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/d7caeb42-1da8-42a4-9953-a88c82d2dea4","error":null}

$ upload_batch batch-standard.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/87afa473-240f-4edd-9edf-fb52f796e923","error":null}

$ upload_batch batch-responses-priority.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/668acce6-16ee-4242-8c12-5346e47f86a2","error":null}

$ upload_batch batch-responses-priority-drop.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/123e1287-a4f8-4110-8f10-64d5b96f5e33","error":null}

After (acc59f5)

Chat

  1. Run the same requests against the After proxy
Output
$ tier studio-flash auto
HTTP/1.1 200 OK  cost=0.00031995  {"service_tier":"priority","usage":{"prompt_tokens":7,"completion_tokens":46},"error":null}
sent: {"full_path": "/models/gemini-3.8-flash:generateContent", "path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "priority", "upstream_status": 200, "upstream_tier_header": "priority"}

$ tier studio-flash default
HTTP/1.1 200 OK  cost=0.000174  {"service_tier":"default","usage":{"prompt_tokens":7,"completion_tokens":45},"error":null}
sent: {"full_path": "/models/gemini-3.8-flash:generateContent", "path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": "standard", "upstream_status": 200, "upstream_tier_header": "standard"}

$ tier studio-flash
HTTP/1.1 200 OK  cost=0.000174  {"service_tier":"default","usage":{"prompt_tokens":7,"completion_tokens":45},"error":null}
sent: {"full_path": "/models/gemini-3.8-flash:generateContent", "path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": "standard"}

$ tier vertex-flash priority
HTTP/1.1 200 OK  cost=0.00031184999999999996  {"service_tier":"priority","usage":{"prompt_tokens":6,"completion_tokens":45},"error":null}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [["x-vertex-ai-llm-shared-request-type", "priority"]], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": null}

$ tier vertex-flash flex
HTTP/1.1 200 OK  cost=9.0375e-05  {"service_tier":"flex","usage":{"prompt_tokens":6,"completion_tokens":47},"error":null}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [["x-vertex-ai-llm-shared-request-type", "flex"]], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": null}

$ tier vertex-flash auto
HTTP/1.1 200 OK  cost=0.000177  {"service_tier":"default","usage":{"prompt_tokens":6,"completion_tokens":46},"error":null}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": null}

$ tier vertex-flash
HTTP/1.1 200 OK  cost=0.00018075  {"service_tier":"default","usage":{"prompt_tokens":6,"completion_tokens":47},"error":null}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": null}

$ tier vertex-flash scale
HTTP/1.1 400 Bad Request  cost=0  {"service_tier":null,"usage":null,"error":"litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'priority', 'standard', 'standard_only', '"}

$ tier vertex-flash standard_only
HTTP/1.1 200 OK  cost=0.00018075  {"service_tier":"default","usage":{"prompt_tokens":6,"completion_tokens":47},"error":null}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": null}

$ tier_header vertex-flash "x-vertex-ai-llm-shared-request-type: flex" priority
HTTP/1.1 200 OK  cost=9.0375e-05  {"service_tier":"flex","usage":{"prompt_tokens":6,"completion_tokens":47},"error":null}
sent: {"path": "gemini-3.8-flash:generateContent", "tier_headers": [["x-vertex-ai-llm-shared-request-type", "flex"]], "body_serviceTier": null, "upstream_status": 200, "upstream_tier_header": null}

Batch upload

  1. Upload the same batch files
Output
$ upload_batch batch-priority.jsonl
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Vertex AI batch requests do not support `service_tier`, since batch jobs run on the batch tier. To drop this param, set `litell"}

$ upload_batch batch-priority-drop.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/d610ce09-9d8b-48d3-b2d2-83be1e5ce2f7","error":null}

$ upload_batch batch-standard.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/0573b05d-08fa-4547-8584-0cea3a351ef5","error":null}

$ upload_batch batch-responses-priority.jsonl
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Vertex AI batch requests do not support `service_tier`, since batch jobs run on the batch tier. To drop this param, set `litell"}

$ upload_batch batch-responses-priority-drop.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/3c808fc5-8736-47f3-bbf5-3ad95740d34e","error":null}

Then a batch job from each uploaded file, through POST /v1/batches and GET /v1/batches/<id>. All three complete. The line's GET /v1/files/<id>/content refuses raw Cloud Storage ids, so the rows are not read back here, and #34959 shows them on main

$ create_batch gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/d610ce09-9d8b-48d3-b2d2-83be1e5ce2f7 /v1/chat/completions
{"id":"8910493221348442112","status":"validating","error":null}
$ create_batch gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/0573b05d-08fa-4547-8584-0cea3a351ef5 /v1/chat/completions
{"id":"3902490435712450560","status":"validating","error":null}
$ create_batch gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/3c808fc5-8736-47f3-bbf5-3ad95740d34e /v1/responses
{"id":"5748966282934353920","status":"validating","error":null}
$ batch_status 8910493221348442112
{"id":"8910493221348442112","status":"completed","output_file_id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/prediction-model-2026-11-21T01:10:10.018791Z/predictions.jsonl","error_file_id":null,"request_counts":null}
$ batch_status 3902490435712450560
{"id":"3902490435712450560","status":"completed","output_file_id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/prediction-model-2026-11-21T01:10:10.567081Z/predictions.jsonl","error_file_id":null,"request_counts":null}
$ batch_status 5748966282934353920
{"id":"5748966282934353920","status":"completed","output_file_id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/prediction-model-2026-11-21T01:10:11.093674Z/predictions.jsonl","error_file_id":null,"request_counts":null}

Non-pick commit (cfef3ed)

Before is the merge base 7ab941f451, or acc59f5e6a for the hosted MCP rows, which passes drop_params=False there too. After is cfef3edae2. Uploaded rows are read back from Cloud Storage with rows.py below, since the line's /v1/files/<id>/content refuses raw ids

Setup (config.yaml, proxy start, curl helpers)

Env vars: GOOGLE_APPLICATION_CREDENTIALS, VERTEXAI_PROJECT, GEMINI_API_KEY, LITELLM_MASTER_KEY, GCS_BATCH_BUCKET_NAME, and REC_BASE / REC_STUDIO_BASE for the recorders. vertex-batch comes first so /v1/files with custom-llm-provider: vertex_ai uses a deployment with no recorder in front of Cloud Storage

model_list:
  - model_name: vertex-batch
    litellm_params:
      model: vertex_ai/gemini-3.8-flash
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
      vertex_credentials: os.environ/GOOGLE_APPLICATION_CREDENTIALS
  - model_name: vertex-flash
    litellm_params:
      model: vertex_ai/gemini-3.8-flash
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
      vertex_credentials: os.environ/GOOGLE_APPLICATION_CREDENTIALS
      api_base: os.environ/REC_BASE
  - model_name: studio-flash
    litellm_params:
      model: gemini/gemini-3.8-flash
      api_key: os.environ/GEMINI_API_KEY
      api_base: os.environ/REC_STUDIO_BASE
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  forward_client_headers_to_llm_api: true
cd <tree> && PYTHONPATH=$PWD PYTHON_DOTENV_DISABLED=1 LITELLM_LOCAL_MODEL_COST_MAP=True VERTEXAI_LOCATION=global \
  python -P -m litellm.proxy.proxy_cli --config config.yaml --port $PORT --num_workers 2
export BASE=http://127.0.0.1:$PORT
say='"messages":[{"role":"user","content":"Say hello in one word."}],"max_tokens":50'
tier_stream() {
  local model=$1 t=$2
  curl -sS -N "$BASE/v1/chat/completions" \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d "{\"model\":\"$model\",$say,\"stream\":true,\"stream_options\":{\"include_usage\":true},\"service_tier\":\"$t\"}" \
    | sed -n -e 's/^data: //p' -e '/^{/p' | grep -v '^\[DONE\]$' \
    | jq -sc 'if (.[0].error) then {error: (.[0].error.message[0:150])} else {chunks: length, service_tier_per_chunk: (map(.service_tier) | unique), usage: (.[-1].usage | {prompt_tokens, completion_tokens})} end'
}
upload_batch() {
  curl -sS "$BASE/v1/files" -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'custom-llm-provider: vertex_ai' \
    -F purpose=batch -F file=@$1 | jq -c '{id: (.id // null), error: (.error.message // null | if . then .[0:230] else null end)}'
}

Each batch file is one row, {"custom_id":"r-1","method":"POST","url":"/v1/chat/completions","body":{"model":"gemini-3.8-flash","messages":[{"role":"user","content":"Say hello in one word."}],"max_tokens":20,...}}, with the extra fields its name says. The /v1/responses rows send input and max_output_tokens instead. The MCP rows send a get_time function tool and {"type":"mcp","server_label":"deepwiki","server_url":"https://mcp.deepwiki.com/mcp","require_approval":"never"}

# rows.py <gs://...>...
import json, sys, urllib.parse, urllib.request
import google.auth, google.auth.transport.requests
creds, _ = google.auth.default(scopes=["https://www.googleapis.com/auth/devstorage.read_only"])
creds.refresh(google.auth.transport.requests.Request())
for gs in sys.argv[1:]:
    bucket, _, name = gs.removeprefix("gs://").partition("/")
    req = urllib.request.Request(
        f"https://storage.googleapis.com/storage/v1/b/{bucket}/o/{urllib.parse.quote(name, safe='')}?alt=media",
        headers={"Authorization": f"Bearer {creds.token}"},
    )
    r = json.loads(urllib.request.urlopen(req).read().decode().splitlines()[0])["request"]
    print(json.dumps({"keys": sorted(r), "serviceTier": r.get("serviceTier"), "tools": r.get("tools")}))

Stream

Before (7ab941f)
$ tier_stream vertex-flash priority
{"error":"b'{\\n  \"error\": {\\n    \"code\": 400,\\n    \"message\": \"Invalid value at \\'service_tier\\' (type.googleapis.com/google.cloud.aiplatform.v1.ServiceTier), \""}

$ tier_stream vertex-flash flex
{"error":"b'{\\n  \"error\": {\\n    \"code\": 400,\\n    \"message\": \"Invalid value at \\'service_tier\\' (type.googleapis.com/google.cloud.aiplatform.v1.ServiceTier), \""}

The recorder saw body_serviceTier priority and flex, no tier header, and a 400 from Vertex

After (cfef3ed)
$ tier_stream vertex-flash priority
{"chunks":6,"service_tier_per_chunk":[null,"priority"],"usage":{"prompt_tokens":6,"completion_tokens":46}}

$ tier_stream vertex-flash flex
{"chunks":8,"service_tier_per_chunk":[null,"flex"],"usage":{"prompt_tokens":6,"completion_tokens":46}}

The recorder saw x-vertex-ai-llm-shared-request-type priority and flex, no body serviceTier, and a 200 from Vertex. The null is the finish_reason chunk, which 11b09d19ff fills

Batch rows with scale

Before (7ab941f)
$ upload_batch batch-scale.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/d01402f1-fbec-4f6b-b441-2b5f8ebf020a","error":null}

$ upload_batch batch-scale-drop.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/018120bf-52db-4098-aac7-2e6f3ecb4ac3","error":null}

$ python rows.py <both ids>
{"keys": ["contents", "generationConfig", "labels", "serviceTier"], "serviceTier": "scale", "tools": null}
{"keys": ["contents", "generationConfig", "labels", "serviceTier"], "serviceTier": "scale", "tools": null}
After (cfef3ed)
$ upload_batch batch-scale.jsonl
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'priority', 'standard', 'standard_only', 'unspecifi"}

$ upload_batch batch-scale-drop.jsonl
{"id":"gs://litellm_bucket-16/litellm-vertex-files/publishers/google/models/gemini-3.8-flash/9ff1b14d-1fbe-441b-b89f-2bdc33dd15b1","error":null}

$ python rows.py <the id>
{"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}

Batch rows that reach the changed call (/live-pr-risk)

Only the four drop_params rows differ, and every other row answers the same on both

Output, Before (acc59f5) then After (cfef3ed)
$ upload_batch lpr-mcp.jsonl
before: 400 litellm.UnsupportedParamsError: gemini-3.8-flash on vertex_ai cannot run the hosted MCP tool `deepwiki` (`type
after:  400 litellm.UnsupportedParamsError: gemini-3.8-flash on vertex_ai cannot run the hosted MCP tool `deepwiki` (`type

$ upload_batch lpr-mcp-drop.jsonl
before: 400 litellm.UnsupportedParamsError: gemini-3.8-flash on vertex_ai cannot run the hosted MCP tool `deepwiki` (`type
after:  uploaded ccb12351-e00d-4d89-88f9-400a5a9f3184

$ upload_batch lpr-resp-mcp-drop.jsonl
before: 400 litellm.UnsupportedParamsError: gemini-3.8-flash on vertex_ai cannot run the hosted MCP tool `deepwiki` (`type
after:  uploaded c7556af6-a12f-417f-be1c-64cc3f3bce9b

$ upload_batch lpr-scale-drop.jsonl
before: 400 litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'p
after:  uploaded 162a92f9-1fe0-43de-98ed-c94b51988780

$ upload_batch lpr-resp-scale-drop.jsonl
before: 400 litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'p
after:  uploaded d0c41c12-a1f3-445f-a400-47f15ac7c861

$ upload_batch lpr-scale.jsonl
before: 400 litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'p
after:  400 litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'p

$ upload_batch lpr-drop-false.jsonl
before: 400 litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'p
after:  400 litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'p

$ upload_batch lpr-priority-drop.jsonl
before: uploaded bc63ad9c-236e-429b-8f13-e8c261cd7096
after:  uploaded e8424a14-74b5-4776-b3b1-800a5e95a166

$ upload_batch lpr-priority.jsonl
before: 400 litellm.UnsupportedParamsError: Vertex AI batch requests do not support `service_tier`, since batch jobs run o
after:  400 litellm.UnsupportedParamsError: Vertex AI batch requests do not support `service_tier`, since batch jobs run o

$ upload_batch lpr-standard.jsonl
before: uploaded cd31bf1a-593e-42ef-a030-3d3389b9e480
after:  uploaded 05a299c0-33cb-411a-90c4-b6a1a1fef05b

Rows read back from Cloud Storage, After

lpr-mcp-drop {"keys": ["contents", "generationConfig", "labels", "tools"], "serviceTier": null, "tools": [{"function_declarations": [{"name": "get_time", "description": "Get the time", "parameters": {"type": "object"}}]}]}
lpr-resp-mcp-drop {"keys": ["contents", "generationConfig", "labels", "tools"], "serviceTier": null, "tools": [{"function_declarations": [{"name": "get_time", "description": "Get the time", "parameters": {"type": "object"}}]}]}
lpr-scale-drop {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
lpr-resp-scale-drop {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
lpr-priority-drop {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
lpr-standard {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}

Deployment drop_params on batch rows

Output, Before (acc59f5) then After (11b09d1)

The upload names its deployment with -F model=, and the rows carry no drop_params of their own. vertex-batch-drop is vertex-batch with drop_params: true, and the setup is in the next section

Before

$ upload_for lpr-scale.jsonl vertex-batch-drop
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'priority', 'standard', 'standard_only', 'unspecifi"}

$ upload_for lpr-mcp.jsonl vertex-batch-drop
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: gemini-3.8-flash on vertex_ai cannot run the hosted MCP tool `deepwiki` (`type: \"mcp\"`). To have LiteLLM run the MCP server for"}

$ upload_for lpr-scale.jsonl vertex-batch
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'priority', 'standard', 'standard_only', 'unspecifi"}

After

$ upload_for lpr-scale.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvZ29vZ2xlL21vZGVscy9nZW1pbmktMy44LWZsYXNoLzUwYjEyZThiLTE5OGQtNDRiZC04YzJmLWU2OTcwMzhhMjA3Mzttb2RlbCx2ZXJ0ZXgtYmF0Y2gtZHJvcA","error":null}

$ upload_for lpr-mcp.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvZ29vZ2xlL21vZGVscy9nZW1pbmktMy44LWZsYXNoL2NkMjYxNGVmLWMxNzktNDVjMS04ZTZkLTljM2Q5MTY2NTg5Yjttb2RlbCx2ZXJ0ZXgtYmF0Y2gtZHJvcA","error":null}

$ upload_for lpr-scale.jsonl vertex-batch
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'priority', 'standard', 'standard_only', 'unspecifi"}

Rows read back from Cloud Storage, After

lpr-scale {"keys": ["contents", "generationConfig", "labels"], "serviceTier": null, "tools": null}
lpr-mcp {"keys": ["contents", "generationConfig", "labels", "tools"], "serviceTier": null, "tools": [{"function_declarations": [{"name": "get_time", "description": "Get the time", "parameters": {"type": "object"}}]}]}

OpenAI file uploads through a deployment with drop_params: true (openai-batch-drop) answer the same, Before (d48a603)

$ upload_delete openai-batch.jsonl openai-batch-drop
{"id":"file-bGl0ZWxsbTpmaWxlLU1reUhqTUhxNUFITWt5YmhiSllxNE07bW9kZWwsb3BlbmFpLWJhdGNoLWRyb3A","error":null}
cleanup: {"deleted":true,"error":null}

$ upload_delete openai-batch.jsonl openai-sol
{"id":"file-bGl0ZWxsbTpmaWxlLUtHNkpuaGRaR2txMTk2YVdSZThYRnA7bW9kZWwsb3BlbmFpLXNvbA","error":null}
cleanup: {"deleted":true,"error":null}

After

$ upload_delete openai-batch.jsonl openai-batch-drop
{"id":"file-bGl0ZWxsbTpmaWxlLVJmb29lQ2IzalM5U0dmNGI1a0Y4TU47bW9kZWwsb3BlbmFpLWJhdGNoLWRyb3A","error":null}
cleanup: {"deleted":true,"error":null}

$ upload_delete openai-batch.jsonl openai-sol
{"id":"file-bGl0ZWxsbTpmaWxlLURUZEZlaFo0TUdRVjhWcExEZTVTdWs7bW9kZWwsb3BlbmFpLXNvbA","error":null}
cleanup: {"deleted":true,"error":null}

Vertex Claude rows (vertex-claude-batch-drop) on the line at 67c4edeaa8, Before (6ac64d9a8b without the upload change)

$ upload_delete claude-scale.jsonl vertex-claude-batch-drop
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: vertex_ai does not support parameters: ['service_tier'], for model=claude-sonnet-5-5. To drop these, set `litellm.drop_params=T"}

$ upload_delete claude-xbody.jsonl vertex-claude-batch-drop
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: extra_body can't set stream, since litellm builds them from the request. Send them as request fields, or set drop_params to drop them"}

$ upload_delete lpr-scale.jsonl vertex-batch-drop
{"id":null,"error":"Batch input file line 1 could not be converted to a Vertex AI request: litellm.UnsupportedParamsError: Invalid `service_tier`: 'scale'. Must be one of: 'auto', 'default', 'flex', 'priority', 'standard', 'standard_only', 'unspecifi"}

After (6ac64d9a8b)

$ upload_delete claude-scale.jsonl vertex-claude-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvYW50aHJvcGljL21vZGVscy9jbGF1ZGUtc29ubmV0LTUtNS8wN2I2ZGM3Zi01MGEzLTRiOTUtOTAxMi1mZjA4YjZkMzczOTc7bW9kZWwsdmVydGV4LWNsYXVkZS1iYXRjaC1kcm9w","error":null}
cleanup: {"deleted":true,"error":null}

$ upload_delete claude-xbody.jsonl vertex-claude-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvYW50aHJvcGljL21vZGVscy9jbGF1ZGUtc29ubmV0LTUtNS8yNjgzN2YwMS1jMmE2LTRjNGQtYWFkMC0wYzcyMWMyZmUzM2U7bW9kZWwsdmVydGV4LWNsYXVkZS1iYXRjaC1kcm9w","error":null}
cleanup: {"deleted":true,"error":null}

$ upload_delete lpr-scale.jsonl vertex-batch-drop
{"id":"file-bGl0ZWxsbTpnczovL2xpdGVsbG1fYnVja2V0LTE2L2xpdGVsbG0tdmVydGV4LWZpbGVzL3B1Ymxpc2hlcnMvZ29vZ2xlL21vZGVscy9nZW1pbmktMy44LWZsYXNoL2FmMWFjNWY4LTA0ZTMtNDc3MS1iZDRkLTZlZTYyNTk0OWYzYzttb2RlbCx2ZXJ0ZXgtYmF0Y2gtZHJvcA","error":null}
cleanup: {"deleted":true,"error":null}

Non-pick commit (11b09d1)

Before is d48a603fba and After is 11b09d19ff

Stream Before, last chunk After, last chunk
Vertex priority null priority
Vertex, no tier null default
AI Studio, OpenAI, Anthropic, fake_stream same same
Setup added to the config and helpers above

Env vars OPENAI_API_KEY and ANTHROPIC_API_KEY too

  - model_name: vertex-batch-drop
    litellm_params:
      model: vertex_ai/gemini-3.8-flash
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
      vertex_credentials: os.environ/GOOGLE_APPLICATION_CREDENTIALS
      drop_params: true
  - model_name: vertex-claude-batch-drop
    litellm_params:
      model: vertex_ai/claude-sonnet-5-5
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
      vertex_credentials: os.environ/GOOGLE_APPLICATION_CREDENTIALS
      drop_params: true
  - model_name: openai-batch-drop
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: os.environ/OPENAI_API_KEY
      drop_params: true
  - model_name: openai-sol
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: os.environ/OPENAI_API_KEY
  - model_name: anthropic-sonnet
    litellm_params:
      model: anthropic/claude-sonnet-5-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: vertex-flash-fake
    litellm_params:
      model: vertex_ai/gemini-3.8-flash
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
      vertex_credentials: os.environ/GOOGLE_APPLICATION_CREDENTIALS
      api_base: os.environ/REC_BASE
      fake_stream: true
  - model_name: openai-sol-fake
    litellm_params:
      model: openai/gpt-6.2-sol
      api_key: os.environ/OPENAI_API_KEY
      fake_stream: true
say='"messages":[{"role":"user","content":"Say hello in one word."}],"max_tokens":50'
tier_chunks() {
  local model=$1 t=${2:-}
  curl -sS -N "$BASE/v1/chat/completions" \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d "{\"model\":\"$model\",$say,\"stream\":true,\"stream_options\":{\"include_usage\":true}${t:+,\"service_tier\":\"$t\"}}" \
    | sed -n -e 's/^data: //p' | grep -v '^\[DONE\]$' \
    | jq -sc 'if (.[0].error) then {error: (.[0].error.message[0:150])} else {finish_chunk_tier: (map(select(.choices[0].finish_reason != null)) | map(.service_tier)), tier_per_chunk: map(.service_tier), usage_tokens: (.[-1].usage.total_tokens)} end'
}
upload_for() {
  curl -sS "$BASE/v1/files" -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
    -F purpose=batch -F model=$2 -F file=@$1 | jq -c '{id: (.id // null), error: (.error.message // null | if . then .[0:230] else null end)}'
}
delete_file() {
  curl -sS -X DELETE "$BASE/v1/files/$1" -H "Authorization: Bearer $LITELLM_MASTER_KEY" | jq -c '{deleted: (.deleted // null), error: (.error.message // null | if . then .[0:150] else null end)}'
}
upload_delete() {
  local out id
  out=$(upload_for $1 $2); print -r -- "$out"
  id=$(print -r -- "$out" | jq -r '.id // empty')
  [[ -n $id ]] && print -r -- "cleanup: $(delete_file $id)"
}
Output, Before (d48a603)
$ tier_chunks vertex-flash priority
{"finish_chunk_tier":[null],"tier_per_chunk":["priority",null,"priority"],"usage_tokens":53}

$ tier_chunks vertex-flash
{"finish_chunk_tier":[null],"tier_per_chunk":["default","default",null,"default"],"usage_tokens":52}

$ tier_chunks studio-flash priority
{"finish_chunk_tier":[null],"tier_per_chunk":[null,null,null,null],"usage_tokens":53}

$ tier_chunks openai-sol
{"finish_chunk_tier":["default"],"tier_per_chunk":["default","default","default","default","default"],"usage_tokens":17}

$ tier_chunks anthropic-sonnet
{"finish_chunk_tier":[null],"tier_per_chunk":[null,null,null],"usage_tokens":22}

$ tier_chunks vertex-flash-fake priority
{"finish_chunk_tier":["priority"],"tier_per_chunk":["priority","priority","priority"],"usage_tokens":53}

$ tier_chunks openai-sol-fake
{"finish_chunk_tier":["default"],"tier_per_chunk":["default","default","default"],"usage_tokens":17}
Output, After (11b09d1)
$ tier_chunks vertex-flash priority
{"finish_chunk_tier":["priority"],"tier_per_chunk":["priority","priority","priority"],"usage_tokens":53}

$ tier_chunks vertex-flash
{"finish_chunk_tier":["default"],"tier_per_chunk":["default","default","default"],"usage_tokens":52}

$ tier_chunks studio-flash priority
{"finish_chunk_tier":[null],"tier_per_chunk":[null,null,null,null],"usage_tokens":53}

$ tier_chunks openai-sol
{"finish_chunk_tier":["default"],"tier_per_chunk":["default","default","default","default","default"],"usage_tokens":17}

$ tier_chunks anthropic-sonnet
{"finish_chunk_tier":[null],"tier_per_chunk":[null,null,null],"usage_tokens":22}

$ tier_chunks vertex-flash-fake priority
{"finish_chunk_tier":["priority"],"tier_per_chunk":["priority","priority","priority"],"usage_tokens":53}

$ tier_chunks openai-sol-fake
{"finish_chunk_tier":["default"],"tier_per_chunk":["default","default","default"],"usage_tokens":17}

Type

🐛 Bug Fix

Caveats (if any)

Copied from #34959

Medium

  • Vertex SERVICE_TIER_FLEX and SERVICE_TIER_PRIORITY answered 200 at the standard tier before. They now run on Flex or Priority, so the bill changes, and Vertex answers 400 where the region or model lacks the tier, past drop_params. Use the global endpoint or default

Low

  • Vertex batch rows with priority or flex now answer 400 at upload unless drop_params is set, where before each row failed inside the job
  • Vertex responses, stream chunks, batch rows, Prometheus and OpenTelemetry report the tier default where they said null or None
  • A model group that mixes gemini/ and vertex_ai/ deployments bills auto at priority on AI Studio and at standard on Vertex
  • A dedicated Request-Type header with a service_tier is untested live, since it needs Provisioned Throughput
  • /v1/responses and /v1/messages return service_tier: null on every Gemini route, as before
  • An empty service_tier now answers 400 unless drop_params is set, as OpenAI does
  • The tests monkeypatch litellm.drop_params, a module global with no injection point
Decisions
  • auto on Vertex sends no tier, so Vertex serves its standard tier. On AI Studio auto still sends priority, since litellm's Gemini docs promise that and a change would silently move AI Studio callers to the standard rate. Rejected: one meaning for both routes
  • Only X-Vertex-AI-LLM-Shared-Request-Type is sent, so a project with Provisioned Throughput uses it first and spills over to the asked tier. Rejected: also sending X-Vertex-AI-LLM-Request-Type: shared, which skips Provisioned Throughput the customer already pays for. A caller who wants pay-as-you-go only can send that header, and litellm keeps it
  • An unknown tier such as scale answers 400 unless drop_params is set, per litellm's drop_params rule. Rejected: treating it as standard
  • A tier Vertex does not offer for the project, region, or model is Vertex's 400 to give, as OpenAI answers 400 to flex on a model without it. Google's docs say Flex runs only on the global endpoint and on some models, and Priority on global, us, and eu. Rejected: a litellm copy of that matrix, which goes stale as Google adds regions and models, and sending standard instead, which bills a tier the caller did not ask for
  • priority or flex on a Vertex batch row answers 400 unless drop_params is set, since batch jobs run on the batch tier and take no tier header, while standard, default, and auto upload with no tier, as on real-time Vertex calls. Rejected: dropping every tier silently
  • Vertex responses report the served tier from trafficType through the table cost uses, so ON_DEMAND, Provisioned Throughput and any unknown value report default, the tier cost bills. Rejected: null for Provisioned Throughput, which left the response and the Prometheus label apart from the bill, and leaving service_tier null for every Vertex response
  • On AI Studio, default sends serviceTier: "standard", as it did before this PR. Rejected: sending no tier, which changed what AI Studio got for no fix

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
Bugbot summary

[!NOTE]
Medium Risk
Changes how Vertex routes tiered traffic and maps served tiers to cost keys—live billing can shift for previously misrouted tier aliases, and batch uploads now fail earlier on unsupported tiers.

Overview
Fixes Vertex Gemini rejecting service_tier by stopping body serviceTier on Vertex routes and sending priority / flex via X-Vertex-AI-LLM-Shared-Request-Type instead; Google AI Studio (gemini/) still maps tiers into the request body. Request handling is tightened with alias tables (auto/default/standard_only, prefixed SERVICE_TIER_*), validation that 400s unknown tiers unless drop_params, and caller tier headers win over mapped service_tier.

Responses and billing: served tier is derived from x-gemini-service-tier and usageMetadata.trafficType (shared GEMINI_TRAFFIC_TYPE_SERVICE_TIERS); streaming finish chunks now carry the last tier seen in the stream.

Batch / proxy: Vertex batch JSONL rows reject priority/flex service_tier unless dropped; batch conversion respects per-row and deployment drop_params (proxy file upload merges deployment_drop_params).

Reviewed by Cursor Bugbot for commit 2f66d37. Bugbot is set up for automated code reviews on this repo. Configure here.

TobiMayr and others added 9 commits November 20, 2026 13:18
…ement

The serviceTier body field is accepted by Vertex AI (no 400) but does not
activate tier routing. The X-Vertex-AI-LLM-Shared-Request-Type header is
what actually routes to shared rate-limit pools with priority/flex enforcement.

Changes:
- validate_environment(): inject X-Vertex-AI-LLM-Request-Type and
  X-Vertex-AI-LLM-Shared-Request-Type headers when service_tier is
  priority or flex (Vertex AI only, not Google AI Studio)
- _transform_request_body(): skip serviceTier in body for Vertex AI
  (keep for Google AI Studio gemini/ where body field works)
- _map_service_tier_param(): normalize prefixed values (SERVICE_TIER_FLEX
  -> flex), skip non-routing tiers (auto, default, scale, unspecified)

See: BerriAI#34914
(cherry picked from commit 4f4c0ba)
Vertex rejects a lowercase serviceTier body field with a 400, so priority
and flex now go out as the X-Vertex-AI-LLM-Request-Type and
X-Vertex-AI-LLM-Shared-Request-Type headers. AI Studio keeps the body
field. auto, default, scale and unspecified send no tier instead of
turning into priority, and an unknown tier answers 400 unless drop_params
is set.

(cherry picked from commit 68348e6)
…p standard_only to standard

(cherry picked from commit cd73861)
The tier tests now seed the Vertex credential cache instead of patching
VertexBase, and they cover an upper-case caller tier header and the
SERVICE_TIER_STANDARD_ONLY spelling

(cherry picked from commit 044c09d)
…rtex tier, reject batch tiers

AI Studio keeps sending auto as priority, as its docs promise. Vertex sends only the shared request type header so provisioned throughput is used first, reads the served tier from trafficType, answers 400 to unknown tiers like scale, and batch rows with a tier answer 400 unless drop_params is set

(cherry picked from commit f9d363b)
…n responses rows

A Vertex batch row now answers 400 only for priority and flex, the tiers
real-time Vertex sends as a header, so standard uploads with no tier like
default and auto. A /v1/responses batch row keeps its drop_params when it
is bridged to a chat body, so drop_params drops the tier there too

(cherry picked from commit 96fd436)
… AI Studio default, and report Provisioned Throughput as default

(cherry picked from commit 1e00622)
@martenj4
martenj4 requested a review from a team November 21, 2026 21:32
@veria-ai

veria-ai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with no new actionable findings

Summary

This backport sends Vertex Gemini tier choices through headers while keeping AI Studio’s body field

  • Vertex Gemini sends requested tiers through the shared request header.
  • Gemini responses report the tier that served the request.
  • Vertex batch uploads check tiers and honor drop_params.

The earlier batch drop-setting finding is fixed. The description now includes live streaming proof and reproducible helpers. The earlier test-annotation finding was correctly withdrawn because the cited requirement did not apply to that test file

The previous-review and current commits have different merge bases with the target commit, so this review covered the full PR changes

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/lts..." · Reviewed by Greptile

… MCP tools in batch rows

The line's batch row builder passed drop_params=False to map_openai_params, so a
row's or deployment's drop_params never reached the service_tier check or the
hosted MCP tool filter. Pass the resolved value, as main does.
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…rt_34959_lts_1_108_x

# Conflicts:
#	litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py
… keep deployment drop_params on file uploads
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…rt_34959_lts_1_108_x

# Conflicts:
#	litellm/llms/gemini/chat/transformation.py
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…rt_34959_lts_1_108_x

# Conflicts:
#	tests/unit/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 2f66d37. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 4bf8330 into BerriAI:lts/1.108.x Nov 23, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants