Argon Long Decode continues in 64K-token background hops. It requires background: true and an output budget above 65,536. Input, thinking, and output share context; every hop is billed.
Suitable for complex math/science/research, formal proofs, difficult coding, and Agents that need more than 64K tokens; also suitable for evaluations where tools truncate output at the output cap.
Generally unsuitable for chat/QA/summaries/classification/extraction, which are usually under 32K; fixed-length writing; multi-turn short tool-call Agents; prompts near the input cap; and latency-sensitive tasks. Long Decode may take minutes.
Model: Gemini 4 Argon, gemini-4-argon.
APIs: Interactions API background execution; GenerateContent API client-side continuation; Interactions client-side continuation coming soon; examples are provided in Python/JS/REST.
Long Decode requires background: true and max_output_tokens > 65,536; start complex reasoning at 262,144; the maximum is 1,048,576 minus input. Use thinking_level: "high" for the hardest tasks; the default is medium for most coding/Agent tasks, and lowering thinking_level saves tokens.
Create a background interaction with max_output_tokens > 65,536 and <= 1,048,576.
The server runs the first hop, up to 64K tokens.
It continues in 64K hops until the task is complete or the configured limit is exhausted.
Each hop adds a model_output step to interaction.steps under the same ID.
Poll or stream the interaction, then join all model_output text.
import time
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-4-argon",
input="Write a complete, rigorous proof of the prime number theorem.",
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)
# Each hop adds a model_output step, so join the text of all of them.
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("Status:", interaction.status)
print("Usage:", interaction.usage)import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
let interaction = await client.interactions.create({
model: "gemini-4-argon",
input: "Write a complete, rigorous proof of the prime number theorem.",
background: true,
generation_config: {
max_output_tokens: 262144,
thinking_level: "high",
},
});
while (interaction.status === "in_progress" || interaction.status === "queued") {
await new Promise((resolve) => setTimeout(resolve, 5000));
interaction = await client.interactions.get(interaction.id);
}
// Each hop adds a model_output step, so join the text of all of them.
const text = interaction.steps
.filter((step) => step.type === "model_output")
.flatMap((step) => step.content ?? [])
.filter((content) => content.type === "text")
.map((content) => content.text)
.join("");
console.log(text);
console.log("Status:", interaction.status);
console.log("Usage:", interaction.usage);# 1. Create the background interaction. It returns an ID right away.
ID=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-argon",
"input": "Write a complete, rigorous proof of the prime number theorem.",
"background": true,
"generation_config": {"max_output_tokens": 262144, "thinking_level": "high"}
}' | jq -r '.id')
# 2. Poll until the status is no longer in_progress or queued.
# The REST response has no output_text field, so join the text of every model_output step.
while true; do
RESP=$(curl -s "https://generativelanguage.googleapis.com/v1beta/interactions/$ID" \
-H "x-goog-api-key: $GEMINI_API_KEY")
STATUS=$(echo "$RESP" | jq -r '.status')
if [[ "$STATUS" != "in_progress" && "$STATUS" != "queued" ]]; then
echo "$RESP" | jq -r '[.steps[]? | select(.type == "model_output") | .content[]? | select(.type == "text") | .text] | join("")'
echo "$RESP" | jq '{status, usage}'
break
fi
sleep 5
done| Run mode | Output limit |
|---|---|
background: false (streaming or non-streaming) | 65,536 tokens; greater values return 400, and Long Decode is not yet available |
background: true, no max_output_tokens set | 65,536 tokens |
background: true, max_output_tokens greater than 65,536 | The configured value, up to 1,048,576 minus input tokens |
You must explicitly set max_output_tokens > 65,536. Check that the Agent or evaluation tool uses the same setting. A lower value, such as 8,192, may stop before thinking is complete.
| Configuration | Background Interactions | Client continuation GenerateContent |
|---|---|---|
| Initiator | Google server | Google GenAI SDK / your own code |
| Tokens per request | max_output_tokens within one interaction | 64K streaming, 32K non-streaming |
| Runtime | Up to 24h | 20m |
| Storage | Requires store:true | Server stores none |
| Use | Easiest Long Decode | Finer retry/backoff/error/recovery control |
Background Interactions are the simplest option. Client continuation is available through GenerateContent. Interactions advanced client-side continuation is coming soon.
Limit the task to complex reasoning, code, or Agent work; fix the ID, input, and acceptance criteria.
Decide whether more than 64K is needed. Do not enable it by default for ordinary chat/QA/summary/classification/extraction.
Use Interactions with background: true, store: true, and a suitable maximum; start complex reasoning at 262,144, with a maximum of 1,048,576 minus input.
Use thinking_level: "high" for the hardest tasks; use the default medium for most coding/Agent work; lowering it saves tokens.
Poll in_progress/queued until a terminal state; join all model_output steps under the same ID; read usage.
For streaming, set stream: true and thinking_summaries: "auto"; save interaction.created ID and every event_id.
On disconnect, call interactions.get with the last event_id and continue; read through the end, then check status. Use an HTTP read timeout of 15–20m.
Handle terminal states: read completed; execute tools and return results for requires_action; increase the maximum and retry for incomplete; retry failed, and for repeated failures submit the interaction ID where supported; read usage and confirm billing for cancelled.
Record input/thinking/output/cached/total tokens per hop. Do not use total_input_tokens as the context size; estimate prompt + total_output_tokens + total_thought_tokens.
Long Decode is limited to Argon, with more than 64K and up to 1,048,576 tokens in a shared context; input/thinking/output share that context.
The server automatically generates and combines 64K hops, with model_output steps under the same ID.
background must be true and max_output_tokens must be greater than 65,536; the maximum is 1,048,576 minus input. Without a setting, the default is 65,536.
With background false, streaming and non-streaming output is 65,536; a larger value returns 400, and background Long Decode is unavailable.
Background runtime is up to 24h; GenerateContent continuation allows 64K streaming / 32K non-streaming and has a 20m runtime; the server stores no data.
For streaming recovery, save the interaction ID and events; use interactions.get with stream: true and the last event_id; replay missed events after completion.
Terminal states are completed, requires_action, incomplete, failed, and cancelled, with the handling described above.
max_output_tokens includes thinking and visible output. Start long coding/Agent tasks at the 65,536 default; for complex reasoning/math/science/proofs, use background with 262,144.
interaction.usage fields are total_input_tokens, total_cached_tokens, total_output_tokens, total_thought_tokens, and total_tokens. In step.stop/status_update streams, values are cumulative; read the latest value rather than adding them.
In the repeated-context example, with a 1,000-token prompt and 200,000 tokens of thinking/output across four hops, inputs are 1,000, 66,536, 132,072, and 197,608, for a total of 397,216. With a 95% implicit-cache discount, effective context is approximately 201,000.
Every token in every hop is billed, including thinking-only tokens. Intro cached input is $0.10 per 1M tokens; ordinary input is $2.00 per 1M tokens. Cancelled/failed interactions are billed for completed work.
To stop a running interaction: Python uses client.interactions.cancel(id=interaction.id), JavaScript uses client.interactions.cancel(interaction.id), and REST uses POST /v1beta/interactions/{id}/cancel.
Related links: GenerateContent API Long Decode, Background execution guide, Thinking, Latest Gemini 4 Argon model page.
It does not directly raise ordinary synchronous output to 1,048,576; use background plus 64K hops.
The 1,048,576-token limit is shared by input/thinking/output, so output is reduced by input.
max_output_tokens includes thinking and visible output. high only provides more room; the model decides how much to use. Fixed token/word targets are not supported.
Repeated context means total_input_tokens can exceed the actual context; do not use it directly for compression/trimming.
Background execution requires store: true. The page does not provide another storage schema; do not invent one.
Complex tasks can take minutes. Use a 15–20m streaming HTTP timeout and keep the normal connection open between 5K-token chunks; the first 64K takes about the first 10m, with later chunks of about 5,000 tokens.
With background false, Long Decode is unavailable; values above 65,536 fail. Future support is noted.
The model does not follow a token/word target; Long Decode is not a length controller.
Create gemini-4-argon with background: true, store: true, max_output_tokens: 262144, and thinking_level: "high"; record the ID.
Poll the endpoint/SDK until terminal, join model_output, and save usage.
Test the same input at 65,536, 262,144, and near 1,048,576 minus input; record completion, truncation, failure, thinking, and output.
Run a streaming test: save the ID/events, disconnect/reconnect with the last event_id, read to the end, confirm replay, and concatenate the final result.
Construct and record each terminal state; do not treat incomplete empty text as success.
Record tokens/cost per hop; separate the 95% implicit-cache discount from uncached input.
Gemini 4 Argon