Migrate from Gemini 3.8 Flash to Gemini 4 Hydrogen
Moving from gemini-3.8-flash to gemini-4-hydrogen: default thinking level becomes high, xhigh is new, minimal is rejected, and output price changes.
gemini-4-hydrogen became generally available on November 12, 2026, and the docs call it the recommended upgrade from Gemini 3.8 Flash. Swapping the model string keeps the request shape, but the default thinking level and the price differ, so a few places in your code need a look.
If you are coming from Gemini 4 Carbon instead, the checklist there (output limit of 32,768, the 12/01 price increase) is in Update your code for Gemini 4 Carbon: 4 changes. This post covers only what is different on Hydrogen.
[1] Change the model ID. The first item in the docs' checklist is to change gemini-3.8-flash to gemini-4-hydrogen. Find where it is hardcoded.
$ grep -rnE "gemini-3\.8-flash|gemini-3-flash|gemini-2\.5" --include="*.py" --include="*.js" --include="*.ts" --include="*.json" --include="*.yaml" .[2] Decide whether you accept the new default thinking level, high. On 3.8 Flash the default is medium; on Hydrogen it is high. A request that never sets thinking_level will think harder the moment you switch models. The docs describe high as "Balanced intelligence and speed" and recommend it for most tasks. To keep latency and tokens close to what you had, set it explicitly.
interaction = client.interactions.create( model="gemini-4-hydrogen", input="...", generation_config={"thinking_level": "medium"},)Not confirmed here: the docs give no figure for how many more tokens high uses than medium. Measure it on your own evaluation set. The docs' method is to run all four levels and pick the lowest one that meets your quality bar; the migration item says to test medium and high to balance speed and cost.
[3] Search for minimal. The docs say Hydrogen rejects minimal with an error, and the table in the thinking guide lists minimal as not supported on Gemini 4 models or gemini-3.8-flash. It was already unavailable on 3.8 Flash, so this bites code that came from 3.6 Flash or the Flash-Lite models.
$ grep -rnE "thinking_?[lL]evel|thinkingLevel" --include="*.py" --include="*.js" --include="*.ts" --include="*.json" .| Supported values (thinking guide table) | Default |
|---|---|
gemini-4-hydrogen: low, medium, high, xhigh | high |
gemini-4-carbon and gemini-4-argon: low, medium, high | medium |
gemini-3.8-flash: low, medium, high | medium |
gemini-3.6-flash: minimal, low, medium, high | medium |
[4] Turn on xhigh only where it is needed. It is a new level, and the docs say to reserve it for hard, multi-step coding and agentic problems where high falls short. It raises latency and token use and can cause "overthinking" on simple prompts. The thinking guide goes further: on simple requests such as text or JSON extraction it can exhaust max_output_tokens. Do not make it a global default; attach it to the hard calls.
generation_config={"thinking_level": "xhigh"}[5] Check the output limit. 3.8 Flash has separate 1M input and 64K output budgets. Hydrogen shares one 1,048,576-token window across input, thinking, and output. The docs say the 65,536 single-request default and cap stay in place for both streaming and non-streaming calls. The fix they give is to remove hardcoded low caps (8,192 is their example) or raise max_output_tokens to 65,536. The value caps thinking and answer tokens combined, so a low cap leaves only what thinking did not use for the answer.
$ grep -rnE "max_output_tokens|maxOutputTokens" --include="*.py" --include="*.js" --include="*.ts" --include="*.json" .For answers longer than 65,536 tokens, set background to true and max_output_tokens above 65,536 (the docs' examples use 131,072 or 262,144, up to 1,048,576 minus your input tokens).
[6] Remove explicit caching and sampling parameters. Like Carbon, Hydrogen does not support cachedContents or caches.create; the docs say to remove cached_content fields from requests. Implicit caching runs by default on prompts of at least 4,096 tokens and discounts cached input by 95% on a hit. The docs also say to remove temperature, top_p, and top_k: "The server ignores custom values if sent". Details are in Gemini 4 ignores temperature and top_p.
$ grep -rnE "cachedContents|caches\.create|cached_content|temperature|top_?p|top_?k|topP|topK" --include="*.py" --include="*.js" --include="*.ts" --include="*.json" .If you used explicit caching on 3.8 Flash, the cost structure changes too. The pricing page lists a cache storage charge for 3.8 Flash ($0.50 per 1M tokens per hour, $1.00 from 2027-01-01). The Hydrogen cache row reads "Implicit caching only (explicit caching is not supported)" and has no storage line.
[7] Check how you call tools. The docs tell you not to prompt the model through system instructions to emit raw-text JSON tool calls with zero declared tools, which can return MALFORMED_FUNCTION_CALL. Declare tools natively with function calling, or constrain JSON with structured outputs. For conversation state, use previous_interaction_id in the Interactions API. If you manage generateContent history yourself, return prior model turns and thought signatures unchanged on every turn, and do not copy a thought signature across parallel functionCall parts.
[8] Redo the cost math. The numbers are as written on the pricing page and the what's-new page.
| Per 1M tokens | 3.8 Flash through 2026-12-31 | 3.8 Flash from 2027-01-01 | Hydrogen |
|---|---|---|---|
| Input | $0.75 | $1.50 | $1.50 |
| Output (including thinking tokens) | $3.75 | $7.50 | $7.50 |
| Cached input | $0.075 | $0.15 | $0.075 (implicit only) |
Hydrogen is flat standard pricing across the full 1M context window. 3.8 Flash is on introductory pricing through December 31, 2026, so switching now doubles the output rate ($3.75 to $7.50), and the two match from January 1, 2027. For a month with 50,000,000 output tokens, the rate alone takes $187.50 to $375. How much the new default thinking level from [2] changes the token count is a separate question. On the free tier Hydrogen is free of charge, and the pricing table says data is used to improve Google products there and not on the paid tier.
[9] For call errors such as 429 and 503, which do not depend on the model, see Gemini API 429 RESOURCE_EXHAUSTED backoff and 503 model is overloaded. The free tier is rate-limited, so read the docs' rate limits page before sending bulk traffic.