opencode reads its provider list from models.dev, and `gemini-4-argon` is in that registry with a release date of October 13, 2026, so you do not have to define the model by hand. You do have to fix one number, because the registry caps its output at 32,768 tokens while Google lets the model generate up to 1,048,576. Get that wrong and long responses stop early for no visible reason.
Here is the whole setup, in order.
# 1. install the provider credential, stored in ~/.local/share/opencode/auth.json opencode auth login --provider google # 2. confirm what your credential can reach opencode auth list opencode models | grep gemini-4-argon # 3. run it opencode run -m google/gemini-4-argon "Explain the build system in this repository in 200 words."
If step 2 prints `google/gemini-4-argon`, the rest of this page is configuration and troubleshooting rather than setup.
opencode's provider metadata comes from models.dev, so the entry below is what opencode has before you configure anything. Values are from the registry on October 15, 2026.
Google's own pages agree on the price and the context figure and disagree on the output limit, because 32,768 is not the model's ceiling. Google's model guide states a unified 1,048,576-token limit covering input and output together, with a default single-request output of 65,536 tokens for streaming and 32,768 tokens for non-streaming direct HTTP. The registry's 32,768 is the conservative default, not the maximum.
The provider also accepts three environment variable names for the key, which is worth knowing before you spend an hour on a typo:
export GEMINI_API_KEY="your-key" # the one Google's own examples use # GOOGLE_API_KEY and GOOGLE_GENERATIVE_AI_API_KEY are also accepted
Credentials through `opencode auth login` cover the common case. Project-level configuration is where routing, model visibility and the output limit live.
{ "$schema": "https://opencode.ai/config.json", "model": "google/gemini-4-argon", "provider": { "google": { "models": { "gemini-4-argon": { "limit": { "context": 1048576, "output": 200000 } } }, "whitelist": ["gemini-4-argon", "gemini-3.8-flash"] }, "anthropic": { "whitelist": ["claude-opus-5-5", "claude-haiku-5-5"] } } }
Three things in that file are doing work. `model` sets the project default so `opencode run "..."` uses Argon without a flag. `limit.output` raises the ceiling above the registry default, which is the fix for truncated long decodes. `whitelist` narrows the model picker to the two models you actually want on this project, which is a small but real guard against a teammate selecting a frontier model for a formatting task.
Three layers decide which model actually runs, and they are resolved in a fixed order that is worth knowing before you debug a wrong model. The command line wins: `opencode run -m google/gemini-4-argon` overrides everything for that invocation. Next is the agent definition, if you invoked a named agent that carries its own model. Then the project config's `model` field, and finally whatever the picker last remembered for that session. Credentials are separate from all of it: a key exported in your shell competes with the key in `~/.local/share/opencode/auth.json`, and the environment value takes priority. That is why a rejected key after a successful `opencode auth login` usually means an old export in your shell profile rather than a bad credential.
Anthropic sits in the same file on purpose. Both providers work in the same harness, which makes the model a one-line change rather than a migration.
This is the loop that works on an existing codebase: read, plan, then patch, with a check between each step.
# 1. establish what the module does, with no edits opencode run -m google/gemini-4-argon \ "Read src/billing/ and write PLAN.md: entry points, external calls, and every place a currency is assumed to be USD. Do not edit source files." # 2. review the plan yourself, then ask for the change opencode run -m google/gemini-4-argon \ "Implement PLAN.md step 1 only. Keep the diff under 200 lines and update the tests in tests/billing/." # 3. prove it, and check what it cost npm test -- --run tests/billing opencode stats
Two rules make this reliable. Ask for the plan as a file, because a plan in a chat window is not reviewable. And read the diff before step 2 runs the tests, because the model will happily change a test to match the code it just wrote.
For repository-wide work, add a subagent so the expensive reading happens once:
opencode agent create --name planner --model google/gemini-4-argon \ --prompt "You map unfamiliar codebases. You never edit files. You return a plan file with file paths and risks."
Argon's distinguishing feature is generating far more than a normal response in one request, and the two ways to break it are both configuration errors rather than model limits.
from google import genai from google.genai import types client = genai.Client() response = client.models.generate_content( model="gemini-4-argon", contents=open("PLAN.md").read() + "\nReturn the complete patch set for every file listed above.", config=types.GenerateContentConfig( max_output_tokens=200_000, thinking_config=types.ThinkingConfig(thinking_level="HIGH"), ), ) with open("patch-set.md", "w") as f: f.write(response.text) print("finish reason:", response.candidates[0].finish_reason)
Printing the finish reason is the check that catches truncation. A response that ends because it hit the ceiling and a response that ends because it finished look identical in the text.
Over plain HTTP, use streaming or stay under 32,768 output tokens, because the documented non-streaming ceiling is lower:
curl -N -sS -X POST \ "https://generativelanguage.googleapis.com/v1beta/models/gemini-4-argon:streamGenerateContent?alt=sse" \ -H "x-goog-api-key: $GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{"parts": [{"text": "Produce the full refactor plan for the module below."}]}], "generationConfig": {"maxOutputTokens": 200000} }'
Inside opencode, the equivalent is the `limit.output` value from the config above. Set it once in `opencode.json` and every long task in that project inherits it.
Two limits are worth knowing before you plan around long output. Input and output share the same 1,048,576-token budget on Argon, so a large input reduces the output available in the same request. And thinking tokens count as output, so a HIGH thinking level on a long task consumes part of the budget before the answer starts.
Four of these come from the live API on October 15, 2026 and three from opencode's own troubleshooting page.
No credential sent at all:
{ "error": { "code": 403, "message": "Method doesn't allow unregistered callers (callers without established identity). Please use API Key or other form of API consumer identity to call this API.", "status": "PERMISSION_DENIED" } }
A credential sent and rejected:
{ "error": { "code": 400, "message": "API key not valid. Please pass a valid API key.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "API_KEY_INVALID" } ] } }
If the second one appears even though `opencode auth list` shows the provider, the key in the environment is winning over the key in the credentials file. Unset the environment variable and retry before you re-enter anything.
A model referenced with the wrong path:
ProviderModelNotFoundError
opencode documents the rule as `/`, with examples like `openrouter/google/gemini-2.5-flash`, and suggests running `opencode models` to see what your credentials actually expose. `google/gemini-4-argon` is correct; `gemini-4-argon`, `google/gemini-4-argon-latest` and `google-vertex/gemini-4-argon` are not, unless you configured that provider.
A broken provider configuration:
ProviderInitError
The documentation's first check is that the provider is set up correctly and the JSON is valid, which in practice means a trailing comma in `opencode.json`.
Anything that reaches the provider and fails there:
AI_APICallError
This is the wrapper for the two JSON bodies above, so read the status field inside it rather than the outer message.
Two failures with no error to read. First, long output that stops early: check for a 32,768 output cap in either the registry metadata or your own config, and print the finish reason. Second, a cost surprise: Anthropic supports explicit prompt caching and Argon does not, only implicit caching for shared prefixes of 6,144 tokens or more, so a pipeline built to pre-warm an explicit cache will run correctly on Argon and cost more than you planned. Rate limiting is documented separately as `429 RESOURCE_EXHAUSTED` with exponential backoff, and the Google SDKs retry transient errors up to four times by default.
Argon's published price is $2 per million input tokens and $10 per million output tokens through November 30, 2026, then $4 and $20. Batch requests are half those rates, and cache reads are $0.10 per million. The model is not available on the Google API free tier, so there is no free lane to test in.
# who is spending it opencode stats # where the model is allowed to be used grep -n "model" opencode.json
The cheapest change to a bill on this model is the same as on any other: keep retrieval, classification and formatting on a small model. That is the routing argument in model and skill routing, and the numbers behind the cheap tier are in the Claude Haiku 5.5 subagent guide.
opencode is the harness that makes the model choice reversible, and the rest of this cluster covers the surrounding decisions: the Jev opencode guide for the tooling layer, Gemini 4 Argon vs Claude Code for the model decision itself, what Gemini 4 Argon is for the lineup context, and how to use it free for what the paid tiers actually require. The complete Jev guide indexes the older cluster, and how to install Jev covers the install.
If you want this configured inside a team rather than on your own laptop, that is the work we do: an embedded AI engineer inside your existing engineering team, spec first, with the review gates and the exit written down. Send a written intake or see what we do.
Do I need to register the model in opencode by hand?
No. models.dev lists `gemini-4-argon` under the `google` provider, so `opencode auth login --provider google` and `opencode run -m google/gemini-4-argon` are enough to start. You only edit config to change limits, hide models or set defaults.
Why does my long response stop early in opencode?
The registry lists a 32,768-token output limit for this model. Override `limit.output` in `opencode.json` and make sure you are streaming for anything above 32,768 on direct HTTP calls.
Which environment variable should hold the key?
Any of `GEMINI_API_KEY`, `GOOGLE_API_KEY` or `GOOGLE_GENERATIVE_AI_API_KEY`. Use one, and avoid leaving an environment key set while also using `opencode auth login`, because the environment value takes precedence and the mismatch looks like a rejected key.
Can I use Vertex AI instead of the Gemini API?
Yes. The opencode provider documentation for Google Vertex AI uses `GOOGLE_CLOUD_PROJECT` with an optional `VERTEX_LOCATION`, and requires the Vertex AI API enabled on the project.
Is Argon free to test?
Not on the API. Google's pricing page states the model is not available on the free tier or on the Google AI Pro plan, so testing means a billed project. The cheaper routes are batch pricing at half rate and the introductory rates before December 1, 2026.
[1] opencode, Providers, read October 15, 2026. The models.dev dependency, the `/connect` credential flow, storage in `~/.local/share/opencode/auth.json`, the `provider` config block, `baseURL`, `blacklist` and `whitelist`, and the Google Vertex AI environment variables.
[2] opencode, CLI, read October 15, 2026. `opencode run`, the `--model` flag in `provider/model` form, `opencode auth login`, `opencode auth list`, `opencode models` and `opencode stats`.
[3] opencode, Config, read October 15, 2026. The `opencode.json` schema, the `model` default and the `limit.input` and `limit.output` fields.
[4] opencode, Troubleshooting, read October 15, 2026. `ProviderModelNotFoundError` with the `/` rule, `ProviderInitError`, and `AI_APICallError`.
[5] models.dev, provider registry, read October 15, 2026. The `google` provider entry for `gemini-4-argon`: context 1,048,576, output 32,768, costs of $2 and $10, cache read $0.10, release date 2026-10-13, tool calling and reasoning support, and input modalities.
[6] Google, Gemini Developer API pricing, read October 15, 2026. The introductory and December rates, batch pricing, cache pricing and the free tier restriction.
[7] Google, Gemini 4 Argon model guide, read October 15, 2026. The unified token limit, the default output ceilings, long decodes, continuation tokens, thinking levels, implicit caching and the required SDK versions.
[8] Google, Introducing Gemini 4 Argon, October 13, 2026. Availability and positioning.
Maxpertise is an AI-native engineering company. We embed native AI engineers inside your team, live in about 10 days. Please enable JavaScript to view the site, or email contact@maxpertise.net.