Over the past few months, terminal and desktop AI agents have radically changed the way we write and maintain code. The flip side is familiar to anyone who uses them daily: API costs. A couple of refactoring sessions on a medium-sized codebase are enough to burn through tens of dollars in tokens.
The question I asked myself is simple: is it possible to build a daily setup on OpenCode based exclusively on free models, yet solid and resilient enough not to leave me stranded in the middle of a task?
The answer is yes—as long as you don’t rely on a single model or a single provider. Here is the architecture I put together, why I chose every single piece, and the ready-to-use configuration files for OpenCode 2.3.2.
The Problem with Free Models (and How to Work Around It)
Anyone who has tried using :free models on a coding agent knows the three main limitations well:
- Rate limits (429) and queues during peak hours: a free endpoint might respond smoothly for an hour and then get saturated for ten minutes.
- Smaller or variable context windows: some free models cap out at 128K–200K tokens, which fill up quickly on an agent that reads files and runs shell commands.
- No single model excels at everything: a model that is fast at micro-edits is often not the best choice for designing the architecture of an entire feature.
To solve these three problems, I focused on three fronts: per-agent specialization, multi-provider redundancy, and automatic context management.
1. Specializing Models by Role (build, plan, assistant)
In OpenCode, we aren’t forced to use a single model for everything. We can assign a different model to each agent based on the cognitive load required:
build→openrouter/particle-ai/particle-1:freeThis is the agent that writes code, edits files, and runs commands. I chose Particle 1 because it is specifically trained on software engineering and terminal workflows, produces clean tool calls without wasting excessive tokens, and offers roughly a 1-million-token context window.plan→opencode/beam-freeWhen I need to plan a refactor or analyze the architecture before touching the code, I don’t need raw speed—I need deep reasoning. Beam (on OpenCode Zen) is purpose-built for complex agentic reasoning and is highly token-efficient, while also keeping my OpenRouter quota free for thebuildagent.assistant→openrouter/google/gemma-4-26b-a4b-it:freeFor everything outside pure coding (quick questions, documentation summaries, writing, analysis), I use a general-purpose sub-agent powered by Gemma 4 26B A4B (MoE architecture): responsive, versatile, multimodal, and lightweight for everyday tasks.
The Little $10 Trick on OpenRouter
Even though I exclusively use models with the :free suffix (keeping actual spend at $0), I loaded $10 in credits onto my OpenRouter account. On OpenRouter, maintaining a positive balance unlocks significantly higher daily rate limits on free models compared to the completely unauthenticated/zero-balance tier, turning :free models into something you can genuinely rely on all day. Those $10 sit untouched, yet they make a huge difference in the number of daily requests you can make.
2. Two Essential Plugins: Clean Context and Automatic Fallback
Having good models isn’t enough if the context window blows up or a provider throws an error. To make the system self-healing, I installed two plugins in OpenCode’s global configuration (~/.config/opencode/opencode.json):
opencode-auto-fallback: this is the real safety net. It intercepts network errors, rate limits (429), overloads (503/529), or unavailable endpoints, puts the failing model into a temporary cooldown, and automatically fails over to the next model in the fallback chain configured for each agent.@tarquinen/opencode-dcp(Dynamic Context Pruning): works silently in the background to strip out duplicate tool calls and obsolete error inputs without altering the actual session history. The result: fewer wasted tokens, faster responses, and a consistently lean context window.
Two Things to Watch Out For
- The plugin must be registered with the right syntax in
opencode.json. Simply having afallback.jsonfile on disk isn’t enough: the plugin only reads it if it is listed under thepluginfield (singular in the OpenCode 2.3.2 schema). Without that entry, the file is ignored and no fallback takes place. - Large Context Fallback is not available on OpenCode V2. In earlier versions of the plugin, you could configure a larger-context model to kick in when the window filled up. On V2, this feature does not work because the plugin lacks access to the required hooks (
session.summarize). Fallback therefore triggers only on errors or rate limits, not on context overflow.
3. The Complete Ready-to-Copy Configuration
To eliminate any single point of failure, each agent gets one primary model and two fallbacks across different providers (OpenRouter, OpenCode Zen, and Kilo Gateway), avoiding back-to-back models on the same provider.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"model": "openrouter/particle-ai/particle-1:free",
"agent": {
"build": {
"model": "openrouter/particle-ai/particle-1:free"
},
"plan": {
"model": "opencode/beam-free"
},
"assistant": {
"mode": "subagent",
"model": "openrouter/google/gemma-4-26b-a4b-it:free"
}
},
"plugin": [
"opencode-auto-fallback",
"@tarquinen/opencode-dcp@latest"
]
}
~/.config/opencode/fallback.json
{
"$schema": "https://raw.githubusercontent.com/HyeokjaeLee/opencode-auto-fallback/main/docs/fallback.schema.json",
"enabled": true,
"autoUpdate": false,
"cooldownMs": 300000,
"maxRetries": 3,
"defaultFallback": [
"openrouter/openrouter/free",
"kilo/kilo-auto/free"
],
"agents": {
"build": {
"fallback": [
"opencode/deepseek-v4.1-flash-free",
"kilo/particle-ai/particle-1:free"
]
},
"plan": {
"fallback": [
"kilo/nvidia/nemotron-3-ultra-550b-a55b:free",
"openrouter/nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free"
]
},
"assistant": {
"fallback": [
"opencode/nemotron-3.5-lightning-free",
"openrouter/google/gemma-4-31b-it:free"
]
}
}
}
Conclusion
With this setup, I achieved a fast multi-agent workflow with context windows up to 1 million tokens, automatic memory pruning via DCP, and cross-gateway failover across three providers—all while keeping actual credit burn at zero.
Of course, :free models come with one trade-off worth keeping in mind: compared to paid enterprise endpoints, they may have looser data retention policies (especially on OpenRouter or experimental endpoints, depending on your account’s privacy settings). For open-source projects, prototypes, learning, and everyday development, however, this setup delivers an unbeatable performance-to-cost ratio.