Repository navigation
service_level = "priority" does not work with VertexAI聽#7263
Description
馃敶 Required Information
Describe the Bug:
The following configuration for an agent works with an API Key, but not with VertexAI
pim_agent = Agent(
model=Gemini(
model="gemini-3.8-flash"
),
name="root_agent",
description="...",
instruction=instruction,
generate_content_config=types.GenerateContentConfig(
temperature=0.5,
max_output_tokens=8192,
safety_settings=[
types.SafetySetting(
category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH,
)
],
),
)
Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:
With ADK 2.9.1, configure the agent according the provided snippet and run adk web
Setup the environment variables with GOOGLE_CLOUD_PROJECT=... and GOOGLE_GENAI_USE_VERTEXAI=1
Expected Behavior:
When
GOOGLE_GENAI_USE_VERTEXAI=0
The agent works fine with the priority service level
Observed Behavior:
but with VERTEXAI=1 it produces the following error:
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Invalid value at \'service_tier\' (type.googleapis.com/google.cloud.aiplatform.v1beta1.ServiceTier), "priority"', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'service_tier', 'description': 'Invalid value at \'service_tier\' (type.googleapis.com/google.cloud.aiplatform.v1beta1.ServiceTier), "priority"'}]}]}}
Environment Details:
- ADK Library Version (pip show google-adk): 2.9.1
- Desktop OS:** [e.g., macOS, Linux, Windows]: Windows with WSL2
- Python Version (python -V): 3.14
Model Information:
- Are you using LiteLLM: No
- Which model is being used: gemini-3.8-flash
馃煛 Optional Information
Providing this information greatly speeds up the resolution process.
Regression:
Did this work in a previous version of ADK? If so, which one?
2.8 had the same behavior
Additional Context:
Similar issue in genai:
googleapis/python-genai#2433
How often has this issue occurred?:
- Always (100%)
Activity
llalitkumarrr commentedon Sep 28, 2026
Hello @SaeeSaadat,
We tried to reproduce this issue using version
2.9.2but we did not get any errors. Could you please try this version and share your observations? For your reference the code we used for the reproduction is provided below.Response:
SaeeSaadat commentedon Sep 28, 2026
@llalitkumarrr Hi. did you use VertexAI authentication? Or API KEY? It works fine with API KEY but not with VertexAI.
llalitkumarrr commentedon Sep 28, 2026
Hi @SaeeSaadat, We used VertexAI for this reproduction.
GWeale commentedon Oct 26, 2026
hi @SaeeSaadat, thanks for sticking with this, and sorry about the earlier confusion: our first repro didn't set service_tier, which is why we missed it. vertex reads the tier from request headers and rejects the body value that google-genai sends. since adk just forwards service_tier straight to google-genai, the fix needs to happen over in googleapis/python-genai#2847. in the meantime, you can work around it by setting
X-Vertex-AI-LLM-Request-Type: sharedandX-Vertex-AI-LLM-Shared-Request-Type: priorityingenerate_content_config.http_options.headers. i'll close this issue so we can keep the tracking in one place.