Skip to content

Missing Support for ON_DEMAND_FLEX #2058

@ewjoachim

Description

@ewjoachim

Following the creation of the new Flex VertexAI pricing, we get a warning when using the new flex price:

/Users/joachim/src/pydantic-ai/.venv/lib/python3.12/site-packages/google/genai/_common.py:651: UserWarning: ON_DEMAND_FLEX is not a valid TrafficType
  warnings.warn(f'{value} is not a valid {cls.__name__}')

Which as far as I can tell, comes from ON_DEMAND_FLEX being absent from TrafficTypes (generated from the API doc).

Environment details

  • Programming language: Python
  • OS: MacOS
  • Language runtime version: 3.12
  • Package version: 1.56.0

Steps to reproduce

from google import genai

client = genai.Client(vertexai=True, location='global')
response = client.models.generate_content(
    model='gemini-3-flash-preview',
    contents='Say hello',
    config={'http_options': {'headers': {'X-Vertex-AI-LLM-Shared-Request-Type': 'flex'}}},
)
print(response.usage_metadata.traffic_type)  # Triggers warning

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions