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?
- Unified input and output token limit: 4 Argon has a unified 1,048,576-token limit that includes both input and output tokens (where output includes thinking, function calls, and the final response).
- Long decodes up to 1,048,576 tokens: Extends generation beyond the
single-request output limit (65,536 tokens, or 32,768 tokens for
non-streaming direct HTTP requests) up to 1,048,576 tokens (minus your input
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.
Try it in Agent Studio
To test prompts and configure gemini-4-argon in the
Agent Studio
UI:
- Open Agent Studio
in your Google Cloud project and select
gemini-4-argonunder the Gemini group. - In Model settings, configure:
- Thinking level: Choose
Low,Medium(default), orHigh. - Region: Select
Global,us, oreu. - Output token limit: Set between
32,768and1,048,576(1,048,576default). Agent Studio handles continuation tokens automatically for responses over the single-request limit.
- Thinking level: Choose
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
from google.genai import types
client = genai.Client(enterprise=True, project="PROJECT_ID", location="global")
response = client.models.generate_content(
model="gemini-4-argon",
contents="Design a lock-free ring buffer in Rust for multi-producer, single-consumer telemetry ingestion.",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(
thinking_level="MEDIUM", # Default: "MEDIUM" (Valid: "LOW", "MEDIUM", "HIGH")
),
),
)
print(response.text)
Python (Interactions API)
from google import genai
client = genai.Client(enterprise=True, project="PROJECT_ID", location="global")
# Turn 1: Initial request (stored server-side by default)
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)
# Turn 2: Continue the conversation using previous_interaction_id
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 application-default 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": "Provide an architectural review of this Go interface."
}
]
}
],
"generationConfig": {
"thinkingConfig": {
"thinkingLevel": "MEDIUM"
}
}
}'
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 output tokens (or 32,768
tokens for non-streaming direct HTTP requests), where output includes thinking,
function calls, and the final response. To generate completions up to 1,048,576
tokens on GenerateContent (v1beta1), set max_output_tokens greater than
65,536 for streaming requests or greater than 32,768 for non-streaming requests
(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.
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(
thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
automatic_continuation=False,
),
):
print(chunk.text, end="")
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:
Thinking levels: 4 Argon supports three
thinking_levelvalues (thinking_budgetandMINIMALreturn an HTTP400validation error):Thinking level Recommended workloads 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. LOWClassification, summarization, and metadata extraction. Unified input and output token limit and single-request output limits:
1,048,576is the overall token limit of the model and includes both input and output tokens (where output includes thinking, function calls, and the final response).max_output_tokenscontrols the output token cap for the generation (up to1,048,576minus your input tokens); settingmax_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).
Long decodes:
- How long decode works: Long decode splits a generation up to
1,048,576 tokens across multiple
GenerateContentinferences. For example, if a task requires 256,000 output tokens (including thoughts, function calls, and the final response), the first streaming request generates up to 65,536 output tokens and emitsfinish_reason=CONTINUATIONwith an encryptedcontinuation_tokencontaining a hash of the original prompt and the generation state up to that point. Includingcontinuation_tokenin subsequent requests with the original prompt continues generation from where it left off 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). Use long
decode only when one response needs more output than that. 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 unified 1,048,576-token input and output limit 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: Choose one of two options. Most
developers use Option 1. 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 Google Gen AI SDKs: Python ( google-genai) 2.30.1, JavaScript (@google/genai) 2.29.1, Go 1.74.0, Java 1.77.0, .NET 1.26.0, and Kotlin 1.6.0. You setmax_output_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, with a checkpoint every 5,000 tokens after 32,768 32,768 per request Time limit per request 20 minutes 20 minutes 20 minutes Storage 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, refer to the Google Gen AI SDK reference implementations in Python and JavaScript/TypeScript. - 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.
streamGenerateContentandgenerateContentreturnusage_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. To log intermediate state before a tool call, use a dedicated function declaration:{ "name": "update", "description": "Update working notes before tool execution", "parameters": { "type": "OBJECT", "properties": { "previous_step": {"type": "STRING"}, "plan": {"type": "STRING"}, "next_step": {"type": "STRING"} }, "required": ["previous_step", "plan", "next_step"] } }
- 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:
- 4 Argon has a unified 1,048,576-token limit across
input and output (where output includes thinking, function calls, and the
final response), 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.
client = genai.Client(
enterprise=True,
project="PROJECT_ID",
location="global", # Supports "global", "us", and "eu"
)
response = client.models.generate_content(
- model="gemini-3.1-pro-preview",
+ model="gemini-4-argon",
contents=prompt,
config=types.GenerateContentConfig(
- temperature=0.0,
- cached_content="projects/.../cachedContents/...", # Explicit caching unsupported
thinking_config=types.ThinkingConfig(
- thinking_budget=16384, # Returns HTTP 400 instead of mapping silently
- thinking_level="MINIMAL", # MINIMAL unsupported on Gemini 4 Argon
+ thinking_level="MEDIUM", # Valid: "LOW", "MEDIUM" (default), "HIGH"
),
),
)
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 unified
input and output token limit: Upgrade to
google-genai >= 2.30.1(Python),@google/genai >= 2.29.1(JavaScript), or the equivalent latest Google Gen AI SDK. Input and output tokens (including thinking and function calls) share the unified 1,048,576-token limit. 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 toLOW,MEDIUM(default ongemini-4-argon), orHIGH(default ongemini-4-argon-cyber-permissive). - 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.
Additional resources
- Gemini 4 Argon model page
- Get started with Gemini 4
- Introductory notebook
- Gemini 4 Argon Cyber Permissive