🧭 How toSoftwareBeginner✨ AI-assisted

How to Call Gemini 4 Argon in the Gemini API With Python

WittyTech Daily··4 min read
#gemini#google-genai#python#interactions-api

Gemini 4 Argon is available in the Gemini API, and a first answer takes about ten lines of Python. By the end of this guide you'll have a working Gemini 4 Argon API call with the google-genai SDK, a thinking level you picked on purpose, a readout of cached tokens, and a clear view of the output cap and the December price change. You need a key on a paid project, because Argon isn't on the Free tier.

The code follows the Gemini API quickstart, which uses the Interactions API (client.interactions.create). The model ID is gemini-4-argon, as listed on the Gemini 4 Argon model page.

1. Install the SDK and set your API key

pip install -U "google-genai>=2.30.1"
export GEMINI_API_KEY="<your-api-key>"

The Interactions API needs google-genai 2.3.0 or later, and Google's Argon docs ask for 2.30.1, so pinning the higher one covers both. The quickstart exports GEMINI_API_KEY and then creates the client with no arguments.

2. Make your first Gemini 4 Argon API call

from google import genai

client = genai.Client()  # no arguments, same as the quickstart

interaction = client.interactions.create(
    model="gemini-4-argon",
    input="Explain idempotency keys to a payments engineer in three sentences.",
)
print(interaction.output_text)

output_text is the shortcut for the final answer. Under the hood the response is a list of steps, where the answer lives in steps of type model_output. You only need to touch those directly for long decode (step 5).

3. Choose a Gemini 4 Argon thinking level

Argon accepts three thinking levels: low, medium and high. The default is medium. Google's long decode guide recommends high for the hardest reasoning and medium for most coding and agentic work.

In the Interactions API the level goes inside generation_config:

prompt = "Find the race condition in this retry loop and explain the fix: ..."

for level in ("low", "medium", "high"):
    interaction = client.interactions.create(
        model="gemini-4-argon",
        input=prompt,
        generation_config={"thinking_level": level, "max_output_tokens": 16384},
    )
    usage = interaction.usage
    print(level, "| thinking:", usage.total_thought_tokens, "| output:", usage.total_output_tokens)

Run it on a real prompt from your project and compare the token counts against answer quality. Two things to watch: thinking tokens are billed at the output rate, and max_output_tokens covers thinking and answer combined, so a tight cap on high can leave the answer short of room.

4. Read cached token counts from usage

Argon uses implicit caching: there is nothing to configure, and Google applies the discount when a request shares a prefix with a recent one. The minimum is 4,096 input tokens, per the caching docs. Hits show up in usage.total_cached_tokens.

runbook = open("runbook.md", encoding="utf-8").read()  # must be 4,096+ tokens to qualify

for question in ("How do I roll back a deploy?", "Who gets paged for a sev 1?"):
    interaction = client.interactions.create(
        model="gemini-4-argon",
        input=runbook + " Question: " + question,
    )
    usage = interaction.usage
    print(question, "| input:", usage.total_input_tokens, "| cached:", usage.total_cached_tokens or 0)

Put the big shared content first and the changing question last, and send similar requests close together. Hits aren't guaranteed, so log this field in production instead of assuming the discount.

5. Know the output cap before you hit it

A normal call can return up to 65,536 tokens (thinking plus answer). In a synchronous call, asking for more returns a 400 error. Going past that is called long decode: the server generates in 64K-token hops, and it only works with background=True, which means you poll for the result.

import time

interaction = client.interactions.create(
    model="gemini-4-argon",
    input="Write a complete migration plan for moving 400 services to a new cluster.",
    background=True,
    generation_config={"max_output_tokens": 262144, "thinking_level": "medium"},
)

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(interaction.status)

Each hop adds a model_output step, so you join them all. The ceiling is 1,048,576 tokens minus your input tokens. A status of incomplete means the model used the whole budget: raise the limit or lower the thinking level. The long decode guide covers streaming and timeouts.

Gotchas

  • No Free tier. Argon returns nothing useful without a paid project.
  • The intro price doubles on December 1, 2026. On the pricing page, standard input is $2.00 per 1M tokens and output (thinking included) is $10.00 through November 30. From December 1 they become $4.00 and $20.00. Cached input goes from $0.10 to $0.20. Budget with the December numbers.
  • No explicit caching. It isn't supported on Argon, and cachedContents returns an error. Implicit caching is all you get.
  • Sampling knobs are ignored. The migration notes say temperature, top_p, top_k and candidate_count have no effect, so don't spend time tuning them.
  • Interactions are stored by default. Paid projects keep them for 55 days, so check that against your customer's data retention rules.

A first Argon call is easy; the thinking level, the cached prefix and the December price are what decide whether it stays affordable once it's in production.

← More in Software