Support Gemini 4 Hydrogen (`gemini-4-hydrogen`) on `GoogleModel`

Merged
DS
24d ago
+274-29

Why we make these changes

Google released Gemini 4 Hydrogen (gemini-4-hydrogen) on 2026-11-12 (announcement, what's new).

Hydrogen adds an xhigh thinking level, its deepest reasoning; high is its default and reasons less. Pydantic AI maps unified thinking='xhigh' and 'max' to HIGH on every Gemini model, so neither reaches it. Hydrogen also rejects MINIMAL, which thinking=False and 'minimal' send without a profile entry.

There is no issue for this. Mirrors #13057 (Gemini 4 Carbon).

[!WARNING]
Compatibility impact: GoogleThinkingLevel, the type of GoogleModelProfile.google_thinking_levels and GoogleRealtimeModelProfile.google_thinking_levels, gains 'XHIGH', and GOOGLE_THINKING_LEVEL_SCALE gains it as its top level. Code that matches GoogleThinkingLevel exhaustively (assert_never) stops type-checking. GOOGLE_THINKING_LEVELS keeps its value.

Why this can ship in a minor release: it only adds a level the Gemini API now accepts. Every value GoogleThinkingLevel accepted before is still accepted, and requests to models without XHIGH don't change. The API compatibility check is waived for the three changes in .github/api-compatibility-waivers/.

Migration: handle or skip 'XHIGH' in exhaustive matches over GoogleThinkingLevel.

New public surface

  • 'gemini-4-hydrogen' in LatestGoogleModelNames and KnownModelName (google:, google-cloud:, gateway/google:, gateway/google-cloud:).
  • 'XHIGH' in GoogleThinkingLevel and GOOGLE_THINKING_LEVEL_SCALE. GOOGLE_THINKING_LEVELS, the set assumed for a model without a documented level set, keeps its four levels.

User-visible behavior

Agent('google:gemini-4-hydrogen', model_settings={'thinking': 'xhigh'})
# before: sends thinkingLevel HIGH
# after:  sends thinkingLevel XHIGH; thinking='max' does the same. Models without XHIGH still send HIGH.

Agent('google:gemini-4-hydrogen', model_settings={'thinking': False})
# before: sends thinkingLevel MINIMAL: 400 "Thinking level MINIMAL is not supported for this model"
# after:  sends thinkingLevel LOW, as on gemini-4-argon and gemini-4-carbon
  • google-genai's ThinkingLevel enum doesn't list XHIGH in any release yet, so the SDK warns XHIGH is not a valid ThinkingLevel and sends it anyway. docs/models/google.md says so.
  • Docs: docs/models/google.md names Hydrogen in the thinking and long decode sections, and the Google row of docs/capabilities/thinking.md gives the xhigh mapping.

Verification

  • tests/test_thinking_wire_contract.py: recorded Gemini API cases google-gemini-4-hydrogen-xhigh (sends XHIGH, accepted) and google-gemini-3-flash-xhigh-snaps-to-high (sends HIGH), matched on the request body.
  • tests/test_thinking.py: test_thinking_xhigh_reaches_only_models_that_list_it.
  • tests/profiles/test_google.py: Hydrogen rows. tests/test_capability_spec.py, tests/models/test_model_names.py, tests/realtime/test_google.py -k thinking and tests/models/google/test_transport.py pass locally.
  • Live on the Gemini API (2026-11-12): gemini-4-hydrogen answers 400 Thinking level MINIMAL is not supported for this model and accepts LOW, MEDIUM, HIGH and XHIGH, as Google's thinking table lists. gemini-3-flash-preview and gemini-3.1-flash-lite-preview answer 400 Thinking level XHIGH is not supported for this model, which is why no other model gets it.
  • generateContent on gemini-4-hydrogen with function calling (AUTO, VALIDATED, ANY), code execution, URL context, sampling parameters and max_output_tokens=200000 succeeds. The free tier's daily request limit ran out before the end-to-end GoogleModel runs; #13301 repeats them.
  • An httpx request hook shows google-genai 2.30 sends "thinking_level": "XHIGH" despite its warning.
  • Google Cloud (Vertex) and Pydantic AI Gateway: not attempted. #13301 tracks checking both live.

What changes for existing users

Nothing on models without XHIGH: xhigh and max still resolve to HIGH. Code that matches exhaustively on GoogleThinkingLevel sees a new member.

Deliberately out of scope

  • GoogleInteractionsModel (#12636): Hydrogen support follows once it merges.
  • MAX: the Gemini API accepts thinkingLevel: MAX on every model probed, but Google doesn't document it, so nothing maps to it.
  • Docs aliases: at $7.50 per 1M output tokens, Hydrogen fits google:medium under docs/model_aliases/AGENTS.md, but genai-prices doesn't price it yet, so google:medium stays on gemini-3.8-flash, as #13057 kept Carbon out of google:large. #13301 repoints it.
  • OpenRouter doesn't list google/gemini-4-hydrogen yet, so _MANDATORY_REASONING_MODEL_PREFIXES is unchanged; #13301 checks reasoning.mandatory once it does.
PR decisions

2026-11-10 · Interactions API out of scope

  • Decision: Add the id on GoogleModel (generateContent) only; GoogleInteractionsModel support follows after #12636 merges
  • Why: Same scope David set for Carbon (#13057)
  • Session: d4f40277-53c9-4e44-ba50-af7e5b77afe1

2026-11-10 · Hydrogen thinking levels on both transports

  • Decision: The level entry applies on the Gemini API and Google Cloud alike
  • Why: Only the Gemini API was probed, but Vertex's thinking table lists the same LOW, MEDIUM, HIGH, XHIGH for Gemini 4 Hydrogen; a missing entry 400s thinking=False
  • Session: d4f40277-53c9-4e44-ba50-af7e5b77afe1

2026-11-12 · XHIGH for Hydrogen only

  • Decision: Unified 'xhigh' and 'max' map to XHIGH, and only gemini-4-hydrogen lists it; GOOGLE_THINKING_LEVELS stays the default set, so every other model still snaps to HIGH
  • Why: Gemini 3 models answer 400 to XHIGH
  • Session: d4f40277-53c9-4e44-ba50-af7e5b77afe1

2026-11-12 · SDK XHIGH warning documented, not suppressed

  • Decision: Leave google-genai's UserWarning; document it
  • Why: No release lists XHIGH (googleapis/python-genai#3357 ships it in 3.3, and the google extra caps google-genai<3, #12732); suppressing it needs warnings.catch_warnings() around an await, which isn't safe across tasks
  • Session: d4f40277-53c9-4e44-ba50-af7e5b77afe1

2026-11-12 · google:medium held until genai-prices prices Hydrogen

  • Decision: Leave docs/model_aliases/aliases.json unchanged
  • Why: Tiers are read from genai-prices, which has no gemini-4-hydrogen entry in its bundled or live data; same call as Carbon in #13057
  • Session: d4f40277-53c9-4e44-ba50-af7e5b77afe1

2026-11-10 · Vertex and Gateway verification is a follow-up

  • Decision: Keep the google-cloud: and gateway/ ids; check them live in #13301
  • Why: No Vertex project or Gateway key is available
  • Session: d4f40277-53c9-4e44-ba50-af7e5b77afe1

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.