When you work with a Lead conversation (for example using Claude Code, Codex, or agy), not every task needs the most expensive frontier model. Writing unit tests, searching where a function is called, updating translations, drafting documentation, or making well-scoped code edits are ideal jobs for fast, budget-friendly (or free) models.
In this tutorial you will learn how to pair OpenCode with OpenRouter (or OpenCode's built-in free models) so your delegated tasks cost pennies—or nothing at all.
Why pair OpenCode and OpenRouter for delegations
- Built-in free models out of the box: as soon as it is installed, OpenCode works right away even without connecting any account by using its built-in free models (in Settings → Agents it shows No provider: free models only).
- Hundreds of models under one account: by connecting a provider like OpenRouter (openrouter.ai), OpenCode can use fast open-weight and commercial models (such as DeepSeek, Qwen Coder, Mistral, Llama, or Gemini Flash) that cost fractions of a cent per task, as well as
:freemodel tiers offered on OpenRouter. - Save your main subscription quota: while your Lead agent (such as Claude Code) uses your flat-rate subscription only to plan the work and review final summaries, the heavy file editing inside separate worktrees is handled by OpenCode.
Step 1: Connect OpenRouter (or another provider) to OpenCode
To add your OpenRouter API key to OpenCode directly from AgiCloud:
- Open the main menu and go to Settings → Agents.
- Find the OpenCode card and press Sign in (or Manage sign-in if you already connected another provider).
- AgiCloud automatically opens a terminal and runs:
opencode auth login - In the interactive terminal menu, use the ↑ and ↓ arrow keys (on a phone, use the Special keys bar at the bottom of the screen) to select OpenRouter (or your preferred provider) and press Enter.
- When
opencodeasks you to paste your API key:- on a computer: paste the key into the terminal and press Enter;
- on a phone: tap the Text button in the top-right corner of the terminal, paste the key into Send to the terminal, and press Send.
- Go back to Settings → Agents and press Check again in the top-right corner: the OpenCode card will now show Connected (
1 providers connected).
[Screenshot: AgiCloud terminal running the interactive opencode auth login menu and the updated OpenCode card in Settings → Agents]
Tip for the Key Vault (Settings → Keys): if you also want your
OPENROUTER_API_KEYavailable as an environment variable in terminals, scripts, or for the built-in Verdict plugin (which readsOPENROUTER_API_KEYfrom the Key Vault to run calibrated decisions with DeepSeek V4 Flash and Mistral Nemo), save it in Settings → Keys under the nameOPENROUTER_API_KEY.
Step 2: Pick a budget model and set it as the default
Whenever the Lead agent spawns a delegated thread with OpenCode, AgiCloud automatically applies the default model you configured in OpenCode's settings. Here is how to set it once for all future delegations:
- Open the Chat section and start a New conversation with OpenCode (this starts the agent once so AgiCloud can record the full list of models available from your connected providers).
- Inside the conversation, tap the agent's Settings bar (right above the message input box) to inspect the Model selector and test your preferred budget or free model.
- Now go to Settings → Agents and scroll to the OpenCode card.
- Under For new conversations, open the Model dropdown (which includes a search box so you can quickly filter across all OpenRouter models) and pick the model you want to use by default.
- AgiCloud confirms with Saved for new conversations.
[Screenshot: "For new conversations" section inside the OpenCode card in Settings → Agents showing the searchable default model selector]
Step 3: Delegate tasks from the Lead to OpenCode
Now you are ready to have your Lead agent coordinate OpenCode:
- Open your Lead conversation (for example with Claude Code, Codex, or agy).
- Ask the lead to break down the job and delegate implementation tasks to OpenCode. For example:
"Analyze the codebase and prepare a plan. Then delegate writing the unit tests and updating the documentation to OpenCode in a separate thread."
- When the "The lead proposes handing over a task" card for OpenCode appears, review the instructions and press Approve and start.
- The child thread assigned to OpenCode starts in its own separate copy (
.agicloud/worktrees/...) automatically using the budget-friendly default model you selected in Step 2. - If a specific task needs a stronger model: you can open the OpenCode child thread at any time, tap the Settings bar at the bottom of the chat, switch to a more capable model just for that thread, and send a follow-up message.
Next step
Did you know that agents in AgiCloud can also generate slides, synthesize two-voice dialogues, and edit full MP4 videos using ffmpeg, MoviePy, and the visual timeline of the Video plugin? Learn how in the next tutorial: