Title card: Gemini 4 Neon Part 2 - 1M context, implicit caching and long decode

In Part 1 we met Gemini 4 Neon, Google’s mid-tier Gemini 4 model, and made a first API call. This Part 2 looks at the three things that change most when you move a real app to Neon: its shared 1M-token context window, implicit-only context caching, and long decode for answers longer than 64K tokens.

What it is

According to Google’s What’s new in Gemini 4 Neon guide, input, thinking and output tokens all share one 1,048,576-token window. A single synchronous reply is capped at 65,536 tokens, but “long decode” lets a response run up to the full 1M window. The model page lists the same limits: a 1,048,576-token unified context and a 65,536-token default synchronous output.

Why it matters

  • One budget, not two. The guide points out that Gemini 3.8 Flash kept separate 1M input and 64K output budgets, while Neon shares one window. A huge prompt therefore leaves less room for thinking and output, so plan your token budget as a whole.
  • Explicit caching is gone. Neon does not support explicit caching (cachedContents and caches.create), and Google says to remove cached_content fields from requests (source). Instead, implicit caching runs by default on prompts of at least 4,096 tokens and discounts cached input tokens by 95% on cache hits.
  • Cost. The guide lists paid-tier prices of $3.00 per 1M input tokens, $15.00 per 1M output tokens (thinking included) and $0.15 for implicit-cached input (source; see also Gemini API pricing).
  • Old caps can hurt. Google advises removing hardcoded low caps such as 8,192 max_output_tokens, or raising them to 65,536, and lowering the thinking level instead if you want to use fewer tokens (source).

How implicit caching works in practice

You don’t create a cache any more. Because caching is implicit and applies to prompts of at least 4,096 tokens (source), the practical habit is simple: put the large, unchanging part of your prompt (a long document, a codebase summary, system instructions) first, and the part that changes with each request (the user’s question) at the end. Repeated requests that share the same long opening then have a chance to hit the cache and be billed at the cached rate. This ordering tip is our own advice, not a guarantee from Google, so check the usage numbers your requests return.

Long decode: answers past 64K tokens

For outputs longer than 65,536 tokens, the guide says to set max_output_tokens above 65,536 (up to 1,048,576 minus your input tokens) and set background to true, so Google’s servers continue in 64K-token hops. Client-side continuation in the latest Google GenAI SDKs is the alternative. One catch: if you set background to true without raising max_output_tokens, the server still stops at 65,536 tokens. Google also notes hard prompts can take several minutes, so use background execution or HTTP timeouts of at least 15 minutes.

Practical example: a long specification in the background

This Python example follows the pattern in Google’s guide, using the Interactions API from the official google-genai SDK. It asks for a long output, polls until the job finishes, then joins the text from every 64K hop.

import time
from google import genai

client = genai.Client()  # reads GEMINI_API_KEY from the environment

interaction = client.interactions.create(
    model="gemini-4-neon",
    input="Write a complete migration specification and test plan for this service.",
    background=True,
    generation_config={
        "max_output_tokens": 262144,
        "thinking_level": "high",
    },
)

while interaction.status in ("in_progress", "queued"):
    time.sleep(5)
    interaction = client.interactions.get(id=interaction.id)

text = "".join(
    content.text
    for step in interaction.steps
    if step.type == "model_output"
    for content in step.content
    if content.type == "text"
)
print(text)
print("Usage:", interaction.usage)

For everyday requests, Google recommends keeping the 65,536 default or leaving max_output_tokens out. Reserve values such as 131,072 or 262,144 for long, multi-step outputs (source).

Quick migration checklist

  1. Delete any caches.create calls and cached_content fields.
  2. Put long, stable context at the start of prompts to benefit from implicit caching.
  3. Raise or remove low max_output_tokens caps.
  4. Use background=True with a higher max_output_tokens for outputs over 64K.
  5. Increase client timeouts for hard prompts.

Next: Part 3 (coming soon) — Agent workflows: function calling, long decode and orchestrating Hydrogen subagents.

Sources

Leave a Reply

Your email address will not be published. Required fields are marked *