cd /news/large-language-models/how-to-call-gemini-4-argon-with-the-… · home › topics › large-language-models › article
[ARTICLE · art-151991] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=· neutral

How to Call Gemini 4 Argon with the OpenAI SDK: Streaming, reasoning_effort and the Real Cost of Each Request

A developer at API gateway apimodels.app published a guide showing how to call Google's Gemini 4 Argon reasoning model through the OpenAI Python SDK by swapping the base_url, covering streaming, the reasoning_effort parameter, and per-request cost tracking. The writeup notes that Argon always reasons before answering and that Google bills thinking tokens at the output rate, with the author's own tests showing a one-word "OK" reply consumed 66 thinking tokens on 14 October 2026, and 105 at low versus 302 at high effort the next day. The author recommends setting thinking levels deliberately and reading reasoning_tokens from every response, since high-effort prompts ran 8 to 10 minutes.

by read6 min views2 publishedOct 17, 2026

You send Gemini 4 Argon a one-line question, get a one-word answer, and the usage block says you paid for about 70 output tokens. That is not a bug. Argon thinks before every answer, and thinking is billed as output.

Gemini 4 Argon (gemini-4-argon) is Google's flagship reasoning model, available on the paid tier of the Gemini API since 13 October 2026, with a 1M-token context window shared by input and output and up to 65,536 output tokens per response. This tutorial calls it through an OpenAI-compatible endpoint with the official openai Python package, streams long answers, sets the thinking level with reasoning_effort, and reads back exactly what each request cost.

Disclosure up front: the endpoint in the examples is apimodels.app, the API gateway I work on. The same code runs against Google's own OpenAI-compatible endpoint if you swap the base URL; I note the differences where they matter. This post was drafted with AI assistance from our docs and test notes, and every command was checked against those sources.

pip install openai curl for the first check

export APIMODELS_API_KEY="sk_your_key_here"

https://api.apimodels.app/v1 (with Google directly, it is https://generativelanguage.googleapis.com/v1beta/openai/ and a Gemini API key) Argon always reasons before it answers, and Google bills those thinking tokens at the output rate. Google's pricing page says it plainly: "Output price (including thinking tokens)". Google's thinking guide lists three levels for Argon (low, medium, high), sets medium as the default, and thinking cannot be turned off.

Our own measurements show the effect. On 14 October 2026, asking Argon to reply with just "OK" used 66 thinking tokens. On 15 October, the same prompt used 105 thinking tokens at low and 302 at high. On one hard reasoning prompt, high ran for 8 to 10 minutes. So two habits matter from the first line of code: set the thinking level on purpose, and read the thinking count from every response.

This request asks a short question at the lowest thinking level, which keeps the first test fast.

curl https://api.apimodels.app/v1/chat/completions \
  -H "Authorization: Bearer $APIMODELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-4-argon",
    "messages": [{"role": "user", "content": "In one sentence: what does a database index trade off?"}],
    "reasoning_effort": "low",
    "max_tokens": 4000
  }'

You get a standard chat-completion object. Look at usage: completion_tokens already includes thinking, and completion_tokens_details.reasoning_tokens tells you how much of it was thinking.

The OpenAI SDK needs only a different base_url. Using with_raw_response keeps the response headers, which carry the request ID and, for non-streaming calls on apimodels.app, the amount charged.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APIMODELS_API_KEY"],
    base_url="https://api.apimodels.app/v1",
    timeout=900,  # high-effort runs can take minutes
)

raw = client.chat.completions.with_raw_response.create(
    model="gemini-4-argon",
    messages=[{"role": "user", "content": "Explain the N+1 query problem in two sentences."}],
    reasoning_effort="low",
    max_tokens=4000,
)
resp = raw.parse()
print(resp.choices[0].message.content)

u = resp.usage
thinking = getattr(u.completion_tokens_details, "reasoning_tokens", 0) or 0
print("input:", u.prompt_tokens, "| output incl. thinking:", u.completion_tokens, "| thinking:", thinking)
print("request id:", raw.headers.get("x-apimodels-request-id"))
print("charged (USD):", raw.headers.get("x-apimodels-cost"))

The last two lines are apimodels.app-specific headers; with Google directly they are absent and you calculate cost from usage yourself.

Streaming is the safe default for Argon, because a long, high-effort answer can take minutes. Ask for usage in the final chunk with stream_options.

stream = client.chat.completions.create(
    model="gemini-4-argon",
    messages=[{"role": "user", "content": "Write a step-by-step plan to migrate a Flask app from SQLAlchemy 1.4 to 2.0."}],
    reasoning_effort="medium",
    stream=True,
    stream_options={"include_usage": True},
)

usage = None
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        usage = chunk.usage

print("\n\nusage:", usage)

In one test on 15 October 2026, a stream of 16,599 output tokens took 144 seconds, with the first token after 8.7 seconds, about 120 tokens per second after that. On api.apimodels.app a streamed Argon response can run for up to 30 minutes; a non-streaming request is cut off at 13 minutes (limits as of 17 October 2026). Use the api.apimodels.app host for long jobs.

reasoning_effort maps to Argon's three thinking levels. apimodels.app sends none and minimal as low (Argon cannot turn thinking off), medium as medium, and high, xhigh and max as high; any other value is dropped and the model's default (medium) applies. Google's own OpenAI-compatible endpoint maps minimal to low for Argon as well.

A practical split:

Do not use max_tokens as your cost control. Google's docs warn that when the limit is hit during reasoning, the answer can come back truncated or empty while the thinking tokens are still billed. Lower the thinking level instead, and keep max_tokens generous. The ceiling for a normal request is 65,536; anything above that returns a 400 error.

Tool calling works through the same endpoint: in our tests on 15 October 2026, single tools, three parallel tools, streaming and multi-turn tool conversations all passed. One schema detail trips people up. Some JSON Schema generators add a top-level "$schema" key, and Gemini rejects it:

Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[0].parameters'

Strip it before you send the tool definition:

def clean_parameters(schema: dict) -> dict:
    schema = dict(schema)
    schema.pop("$schema", None)
    return schema

Every successful LLM response from apimodels.app carries an x-apimodels-request-id header, streaming included. Pass that ID to the records endpoint to get the settled amount.

curl https://api.apimodels.app/v1/records/<request-id> \
  -H "Authorization: Bearer $APIMODELS_API_KEY"

When data.settled is true, data.credits is the final USD amount taken from your balance, and data.usage holds the token counts. A failed request always shows 0, and the lookup itself is free.

apimodels.app is a multi-model API gateway: one API key and an OpenAI-compatible endpoint, plus native Gemini and Anthropic formats, for more than 140 image, video, audio and language models. For Argon that means more than one upstream channel with automatic failover, no charge for failed requests, and the per-request lookup above. As of 17 October 2026 Argon costs $1.10 per million input tokens and $5.50 per million output there, 55% of Google's $2 / $10 list. Google's list rises to $4 / $20 on 1 December 2026, and apimodels.app moves to $2.20 / $11.00 at 00:00 UTC that day, still 55%, with no code change. Argon supports Google's implicit caching only: explicit cache objects are not supported, and whether a repeated prefix hits is decided on Google's side and is not guaranteed. Cached tokens bill at $0.055 per million ($0.11 from 1 December), but budget as if nothing is cached. Details are on the Gemini 4 Argon model page.

Skip it if you need more than 65,536 output tokens in one answer: that is Google's long-decode mode, which needs Google's background execution API, and apimodels.app does not expose it. Skip it too if you need a contract, compliance terms or provisioned throughput directly with Google.

Invalid JSON payload received. Unknown name "$schema"``$schema key. Remove it (Step 5).content with finish_reason: "length"`` max_tokens. Raise reasoning_effort. Authorization: Bearer <key>. stream=True, or raise the SDK timeout for non-streaming calls. Does reasoning_effort work with Gemini 4 Argon? Yes. It maps to Argon's thinking levels low, medium and high, and it changes the bill: the same prompt used 105 thinking tokens at low and 302 at high in our test. Argon cannot turn thinking off, so none behaves like low. Set it per request rather than globally, and use high only for work that runs in the background.

How do I know what a single Argon request cost? Read usage.completion_tokens (thinking included) and usage.prompt_tokens from the response. On apimodels.app, non-streaming responses also carry the charged amount in x-apimodels-cost, and GET /v1/records/{id} returns the settled amount for any request, streaming or not.

What do you set reasoning_effort to for coding agents: one global level, or per task?

This post was written with AI assistance from apimodels.app's docs and our test notes, and reviewed before publishing. I work on apimodels.app.

── more in #large-language-models 4 stories · sorted by recency
── more on @google 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-call-gemini-4…] indexed:0 read:6min 2026-10-17 · —