Gemini 4 Argon is Google's frontier model that excels at deep work in complex, real-world tasks across domains including coding, finance, legal, cybersecurity, and science. It's the first model in the Gemini 4 family.
This document covers what's new with 4 Argon, the API conventions it enforces, how to migrate to it, and a quickstart. For an overview of the Gemini 4 family, see Get started with Gemini 4.
What's new in Gemini 4 Argon?
- Context window: The 1,048,576-token context window is shared across input, thinking, and output tokens.
- Long decodes up to 1,048,576 tokens: Extends generation beyond the
single-request output limit (65,536 tokens for streaming requests, or 32,768
tokens for non-streaming direct HTTP requests) up to 1,048,576 tokens on
GenerateContent. The Google Gen AI SDK handlescontinuation_tokenautomatically across requests, or you can managecontinuation_tokenin your own continuation loop. - Thinking levels:
LOW,MEDIUM(default ongemini-4-argon), andHIGH(default ongemini-4-argon-cyber-permissive). - Implicit caching with durable caching: Implicit caching applies automatically to shared prompt prefixes of 6,144 tokens or more, with durable caching enabled by default. Explicit context caching isn't supported.
- Agentic video understanding: Generally available, and off by default.
Quickstart
Before you begin, you must authenticate to Agent Platform using Application Default Credentials (ADC) or an API key. See Get started with Gemini Enterprise Agent Platform for more information.
In the following code blocks, replace PROJECT_ID with your project ID.
Installation
Upgrade to the latest Google Gen AI SDK (google-genai >= 2.30.1 for Python,
@google/genai >= 2.29.1 for JavaScript, >= 1.74.0 for Go, >= 1.77.0 for
Java, >= 1.26.0 for .NET, or >= 1.6.0 for Kotlin):
pip install --upgrade "google-genai>=2.30.1"
Basic request
Python (GenerateContent)
from google import genai
client = genai.Client(enterprise=True, project="PROJECT_ID", location="global")
response = client.models.generate_content(
model="gemini-4-argon",
contents="How does AI work?",
)
print(response.text)
Python (Interactions API)
from google import genai
client = genai.Client(enterprise=True, project="PROJECT_ID", location="global")
turn1 = client.interactions.create(
model="gemini-4-argon",
input="Design a lock-free ring buffer in Rust for multi-producer, single-consumer telemetry ingestion.",
store=True,
)
print(turn1.output_text)
turn2 = client.interactions.create(
model="gemini-4-argon",
input="Add a bounded backpressure policy and unit tests for concurrent writers.",
previous_interaction_id=turn1.id,
)
print(turn2.output_text)
REST
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-4-argon:generateContent \
-d '{
"contents": {
"role": "USER",
"parts": { "text": "Why is the sky blue?" }
}
}'
Structured output
from pydantic import BaseModel, Field
from google import genai
from google.genai import types
class ArchitectureReview(BaseModel):
component: str = Field(description="Service or module name")
bottlenecks: list[str] = Field(description="Throughput or latency bottlenecks")
recommended_changes: list[str] = Field(description="Concrete refactoring steps")
client = genai.Client(enterprise=True, project="PROJECT_ID", location="global")
response = client.models.generate_content(
model="gemini-4-argon",
contents="Review a synchronous order-processing pipeline backed by a single primary database at 15,000 writes/sec.",
config=types.GenerateContentConfig(
response_mime_type="application/json",
response_schema=ArchitectureReview,
thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
),
)
print(response.text)
Long decodes
By default, a single API request generates up to 65,536 thinking and output
tokens (or 32,768 tokens for non-streaming direct HTTP requests). To generate
completions up to 1,048,576 tokens on GenerateContent (v1beta1), set
max_output_tokens greater than 65,536 (up to 1,048,576). The
Google Gen AI SDK automatically follows continuation_token across requests
when finish_reason is CONTINUATION (set automatic_continuation=False in
GenerateContentConfig to disable automatic continuation), or you can pass
continuation_token in a custom loop.
Python (SDK - Recommended)
from google import genai
from google.genai import types
client = genai.Client(enterprise=True, project="PROJECT_ID", location="global")
# Automatic continuation is enabled by default in google-genai >= 2.30.1.
# Chunks across all continuation requests are yielded as a single stream.
for chunk in client.models.generate_content_stream(
model="gemini-4-argon",
contents="Write a complete formal proof of the prime number theorem.",
config=types.GenerateContentConfig(
max_output_tokens=256000,
thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
),
):
print(chunk.text, end="")
# Set automatic_continuation=False to disable automatic continuation
# and stop at a single request.
single_request_response = client.models.generate_content(
model="gemini-4-argon",
contents="Write a complete formal proof of the prime number theorem.",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
automatic_continuation=False,
),
)
print(single_request_response.text)
REST (Custom continuation loop)
# Request 1: Initial request with maxOutputTokens > 32,768
curl -s -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-4-argon:generateContent" \
-d '{
"contents": [{
"role": "user",
"parts": [{"text": "Write a complete formal proof of the prime number theorem."}]
}],
"generationConfig": {
"maxOutputTokens": 131072,
"thinkingConfig": {"thinkingLevel": "HIGH"}
}
}'
# Request 2: Resend the original request with top-level continuationToken
# from Request 1 (candidates[0].continuationToken)
curl -s -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-4-argon:generateContent" \
-d '{
"contents": [{
"role": "user",
"parts": [{"text": "Write a complete formal proof of the prime number theorem."}]
}],
"continuationToken": "CONTINUATION_TOKEN_FROM_REQUEST_1",
"generationConfig": {
"maxOutputTokens": 131072,
"thinkingConfig": {"thinkingLevel": "HIGH"}
}
}'
Mandatory API rules and behavioral conventions
Gemini 4 Argon enforces the following conventions:
- Context window and single-request output limits:
- The 1,048,576-token context window is shared across input, thinking, and
output tokens. Setting
max_output_tokensgreater than1,048,576returns an HTTP400error. - To avoid unintended long completions, the default single-request output limit (thinking + model response) is 65,536 tokens (or 32,768 tokens for non-streaming direct HTTP requests).
- The 1,048,576-token context window is shared across input, thinking, and
output tokens. Setting
Long decodes:
- How long decode works: Long decode splits a generation up to
1,048,576 tokens across multiple
GenerateContentinferences. When a request reaches its per-request output limit before finishing, the API returnsfinish_reason=CONTINUATIONand an encryptedcontinuation_tokencontaining a hash of the original prompt and the generation state up to that point. Includecontinuation_tokenin subsequent requests with the original prompt untilcontinuation_tokenis no longer emitted andfinish_reason=STOP. (In Agent Studio, setting the output token limit greater than 65,536 up to 1,048,576 handles continuation tokens automatically.) - When to use long decode: Most requests finish within the per-request
limit (65,536 tokens, or 32,768 tokens for non-streaming REST calls).
Long decode gives the model more room to reason; it does not make
answers longer (use
thinking_levelto control reasoning depth).
Workload Use long decode? Why Hard math, science, research, and formal proofs Yes The model can spend more than 65,536 tokens to explore and check its reasoning. The hardest coding and agentic tasks Yes Some tasks need more than 65,536 tokens of thinking and code in one response. Most coding and agentic tasks finish under 65,536 tokens. Evaluation harnesses that stop at the output limit Yes Long decode prevents cut-off answers when the model spends an entire 65,536- or 32,768-token request on thinking. Chat, Q&A, summarization, classification, and extraction No These tasks finish well under 32,768 tokens. Requests for a fixed length, such as "write a 700,000-word book" No The model does not follow length targets. Agents that call tools in many short turns No Each turn is short. Large outputs on each turn fill the shared 1,048,576-token input and output window quickly. Prompts near the 1,048,576-token input limit No Output can use only 1,048,576 tokens minus your input. Latency-sensitive requests No Long decode can run for several minutes. - Choosing a continuation option: All options reach the same
1,048,576-token limit on
gemini-4-argonandgemini-4-argon-cyber-permissive.
Dimension Option 1: Google Gen AI SDK (recommended) Option 2: Your own streaming loop ( streamGenerateContent)Option 2: Your own non-streaming loop ( generateContent)Who starts each segment The SDK ( automatic_continuation=Trueby default). Setmax_output_tokensgreater than 65,536 (up to 1,048,576) for outputs over 65,536 tokens.Your code, at each checkpoint or after a dropped stream Your code, every 32,768 tokens Tokens per request Up to 65,536 per segment 65,536 per stream 32,768 per request Time limit per request 20 minutes 20 minutes 20 minutes Storage and ZDR No server storage (ZDR-compliant) No server storage (ZDR-compliant) No server storage (ZDR-compliant) Best for Most applications REST callers and custom harnesses that stream Simple evaluation harnesses - Implementation rules and limitations:
v1beta1API requirement (known issue): Long decoding (continuation_token) onGenerateContent(generateContentandstreamGenerateContent) is supported only in thev1beta1API (notv1). The Google Gen AI SDK usesv1beta1by default unlessapi_version='v1'is specified inhttp_options; for direct REST calls, use thev1beta1endpoint path. Long decode isn't supported on the Interactions API.- SDK versions and OpenAI compatibility: Upgrade to the latest
Google Gen AI SDK (
google-genai >= 2.30.1for Python,@google/genai >= 2.29.1for JavaScript,>= 1.74.0for Go,>= 1.77.0for Java,>= 1.26.0for .NET, or>= 1.6.0for Kotlin). Older SDK versions and the OpenAI compatibility layer cannot retrieve long completions using continuation tokens. For custom client implementations, see the Google Gen AI SDK reference implementation. - Resend the original request with
continuation_token: In a custom loop, setmax_output_tokensgreater than 65,536 (streaming) or 32,768 (unary) up to 1,048,576, and resend the originalcontents,system_instruction, andtoolson every continuation request along with the latestcontinuation_token(a top-level field onGenerateContentRequestin REST, or inGenerateContentConfigin the Google Gen AI SDK). Don't append partial model output intocontentsor send a follow-up prompt asking the model to continue. - Continue through thinking-only requests: Loop while
finish_reasonisCONTINUATIONandcontinuation_tokenis present, even if a request spent all 32,768 or 65,536 tokens thinking (parts: [{"text": ""}]). Iffinish_reasonisMAX_TOKENSwhencontinuation_tokenis present, generation reached the requestedmax_output_tokenscap—raisemax_output_tokensin the request. Combine accumulated parts into a singlemodelturn for multi-turn history only afterSTOP. - Token counting, compaction, and 95% implicit cache discount:
- In the Python Google Gen AI SDK (
generate_contentandgenerate_content_stream), the final response or chunk'susage_metadataaccumulates total billed tokens across continuation requests. Because each continuation request re-prefills prior partial completions as input tokens,prompt_token_countincreases cumulatively across continuation requests—don't useprompt_token_countto trigger context compaction in agent harnesses. Instead, readinitial_prompt_token_count(onGenerateContentResponseorusage_metadata), and wait untilGenerateContentcompletes (nocontinuation_tokenpresent) before compacting. - In custom REST loops,
usage_metadatais cumulative within each request; sum the finalprompt_token_count,cached_content_token_count,candidates_token_count, andthoughts_token_countacross requests. - Each continuation request re-prefills the prompt plus prior decoded tokens and automatically receives the 95% implicit context caching discount (6,144-token minimum) when requests run back-to-back within the 15–20 minute cache TTL.
streamGenerateContentandgenerateContentreturncontinuation_tokenandusage_metadataat the end of each request (65,536 streaming / 32,768 unary), and billing occurs at the end of the request.
- In the Python Google Gen AI SDK (
- How long decode works: Long decode splits a generation up to
1,048,576 tokens across multiple
Ignored sampling parameters (
temperature,top_k,top_p): The backend ignores custom values. Control reasoning depth withthinking_level, and output format withresponse_schema.Unsupported parameters (
frequency_penalty,presence_penalty,candidate_count): These return an HTTP400error. Remove them from your requests.Context caching: Explicit context caching isn't supported. Implicit caching (with durable caching enabled by default) applies automatically to shared prompt prefixes of 6,144 tokens or more, so put static content at the start of your prompt.
Agentic video: Uploaded videos default to
media_processing="static". Setmedia_processing="agentic"to enable agentic video processing.Token counting and billing: Every token the model processes is counted and billed, including thinking tokens and internal tool system instructions and function declarations when using grounding. Grounding with Google Search also remains billed per query.
Function calling:
- Turn symmetry: Each
FunctionResponsemust match theid,name, and order of the precedingFunctionCall. - Sequential execution: Prefer sequential tool execution turns in multi-step tool loops.
- Pre-tool formatting: Separate inline instructions with
\n\nand avoid unstructured text before tool calls.
- Turn symmetry: Each
Chat sequence validation:
- History payloads can't end with a
modelrole turn. - Prefilled model turns aren't supported.
- History payloads can't end with a
Migrate to 4 Argon from 3.1 Pro
The following behavior is different from gemini-3.1-pro-preview:
- The context window is one 1,048,576-token window shared by input, thinking,
and output, instead of separate input and output limits. Single-request
output is capped at 65,536 tokens (or 32,768 tokens for non-streaming direct
HTTP requests), and can be extended up to 1,048,576 tokens using
long decodes on
GenerateContent(handled automatically in the Google Gen AI SDK, or usingcontinuation_tokenin custom loops). thinking_budgetreturns an HTTP400error instead of being mapped to a thinking level.MINIMALalso returns an error.- Explicit context caching isn't supported.
- Every token the model processes is billed, including internal tool system instructions and function declarations when using grounding.
For a side-by-side comparison, see Migrate from Gemini 3.1 Pro.
To migrate from gemini-3.1-pro-preview, do the following:
- Update the model ID to
gemini-4-argon(orgemini-4-argon-cyber-permissivefor Fairwind-approved cybersecurity workloads). - Upgrade to the latest Google Gen AI SDK and account for the shared
context window: Upgrade to
google-genai >= 2.30.1(Python) or the equivalent latest Google Gen AI SDK. Input, thinking, and output tokens share the 1,048,576-token context window. For outputs exceeding 65,536 tokens (up to 1,048,576 tokens) onGenerateContent, setmax_output_tokensgreater than 65,536 so the Google Gen AI SDK continues automatically across requests (or handlecontinuation_tokenin your own REST loop). - Replace the reasoning budget parameter: Replace
thinking_budgetandMINIMALwiththinking_levelset to one of the following values:HIGH: Default ongemini-4-argon-cyber-permissive. Multi-file software engineering, formal proofs, architecture design, and vulnerability discovery.MEDIUM: Default ongemini-4-argon. General coding, tool use, document Q&A, and video understanding.LOW: Classification, summarization, and metadata extraction.
- Remove explicit caching and front-load static prompt content (6,144 tokens or more) for automatic implicit caching.
- Remove parameters that have no effect or aren't supported:
- Remove
temperature,top_p, andtop_k, which are ignored. - Remove
candidate_count,frequency_penalty, andpresence_penalty. - Remove any prefilled model turns from conversation histories.
- Remove
Summary checklist for developers
Known issues
- Long decodes on
GenerateContentrequirev1beta1: Long decoding (continuation_token) on theGenerateContentAPI (generateContentandstreamGenerateContent) is supported only in thev1beta1API (notv1). The Google Gen AI SDK usesv1beta1by default unlessapi_version='v1'is set inhttp_options; for direct REST calls, use thev1beta1endpoint path.