How to Switch From Claude Code to OpenCode on Clean Energy
Move from Claude Code to OpenCode, the open-source coding agent, and run it on models powered by 100% renewable energy through the Viro API. Config to copy, a migration prompt to paste, and what carries over.
Claude Code is a great coding agent. But if you care about the footprint of the AI you use all day, you have no say in where it runs or what powers it.
OpenCode gives you that choice. It’s an open-source coding agent for your terminal (with a desktop app too) that works with any OpenAI-compatible provider. Point it at the Viro API and your agent runs on models hosted on 100% renewable energy, or on frontier models like Claude with their electricity matched with renewables.
Here’s how to switch in about 10 minutes, including a prompt you can paste to do most of the migration for you.
The short version
- Get a Viro API key at console.viro.app. New accounts get free sandbox credit, no card needed.
- Install OpenCode:
curl -fsSL https://opencode.ai/v2/install | bash - Paste the migration prompt below into Claude Code (one last job) to create your OpenCode config.
- Run
opencodein your project and pick a model with/models.
Your CLAUDE.md and skills keep working. OpenCode reads them.
Why you can’t just point Claude Code at a green API
Claude Code only talks to servers that speak Anthropic’s own Messages format, and Anthropic says it doesn’t support routing Claude Code to non-Claude models through any gateway. The Viro API, like most model providers, speaks the OpenAI-compatible format.
So the honest path is to switch the agent, not the API. OpenCode is built for exactly this: it’s provider-agnostic, and the Viro API plugs straight in.
Step 1: Get a Viro API key
Sign up at console.viro.app, create a key, and add it to your shell profile:
export VIRO_API_KEY="viro_sk_..."
Check it works:
curl https://api.viro.app/v1/models -H "Authorization: Bearer $VIRO_API_KEY"
Step 2: Install OpenCode
curl -fsSL https://opencode.ai/v2/install | bash
OpenCode also installs with Homebrew or npm, and there’s a desktop app for Mac, Windows and Linux. See opencode.ai/docs for every option.
Step 3: Paste this migration prompt into Claude Code
Open Claude Code in your project one more time and paste this. It creates your OpenCode config, moves your MCP servers and custom commands, and touches nothing Claude Code needs:
I'm moving this project from Claude Code to OpenCode, using the Viro API
(OpenAI-compatible, base URL https://api.viro.app/v1) as the model provider.
1. Create opencode.json in the project root using OpenCode's current (V2)
config format, with "$schema": "https://opencode.ai/config.json" and a
provider under "providers" named "viro":
- "name": "Viro"
- "env": ["VIRO_API_KEY"]
- "package": "@opencode/ai/providers/openai-compatible"
- "settings": { "baseURL": "https://api.viro.app/v1" }
- "models", each with a display "name" and a "modelID":
clean -> viro/clean
kimi-k2.7-code -> viro/kimi-k2.7-code
deepseek-v4.1-flash -> viro/deepseek-v4.1-flash
claude-sonnet-5 -> anthropic/claude-sonnet-5
2. If .mcp.json exists, copy every server in "mcpServers" into opencode.json
under "mcp": { "servers": { ... } }.
- stdio servers become { "type": "local", "command": [command, ...args],
"environment": { ... } }
- HTTP servers become { "type": "remote", "url": "...", "headers": { ... } }
Replace any secret values with {env:NAME} references.
3. Copy each file in .claude/commands/ to .opencode/commands/ with the same
name. Keep $ARGUMENTS and $1/$2 placeholders as they are.
4. Leave CLAUDE.md and .claude/skills/ where they are. OpenCode reads both.
5. Don't delete or change any Claude Code files. When you're done, list what
you created and anything you couldn't convert (hooks, permissions,
settings), so I can handle those by hand.
No Claude Code handy? Paste the same prompt into any AI chat, attach your .mcp.json, and copy the result into opencode.json.
What the config looks like
If you’d rather write it yourself, here’s the provider part of opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"viro": {
"name": "Viro",
"env": ["VIRO_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": { "baseURL": "https://api.viro.app/v1" },
"models": {
"clean": { "name": "Viro Clean (renewable router)", "modelID": "viro/clean" },
"kimi-k2.7-code": { "name": "Kimi K2.7 Code", "modelID": "viro/kimi-k2.7-code" },
"deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash", "modelID": "viro/deepseek-v4.1-flash" },
"claude-sonnet-5": { "name": "Claude Sonnet 5 (energy matched)", "modelID": "anthropic/claude-sonnet-5" }
}
}
}
}
Put it in your project root, or in ~/.config/opencode/opencode.json to use it everywhere. Full details in our OpenCode setup guide.
Step 4: Start coding
cd your-project
opencode
Type /models and pick one. A good starting point:
| Model | Energy | Price per 1M tokens (in / out) | Good for |
|---|---|---|---|
| Kimi K2.7 Code | 100% renewable | $1.56 / $6.24 | Day-to-day coding agent work |
| DeepSeek V4.1 Flash | 100% renewable | $0.36 / $1.80 | Fast, cheap edits and questions |
| Viro Clean (router) | 100% renewable | Varies by model | Let Viro pick a clean model per request |
| Claude Sonnet 5 | Energy matched | $3.00 / $15.00 | When you want Claude itself |
Prices from the Viro API catalog in November 2026; see the live model list for current prices.
What carries over from Claude Code
| Claude Code | In OpenCode |
|---|---|
CLAUDE.md |
Read automatically in any folder without an AGENTS.md |
~/.claude/CLAUDE.md |
Read automatically if you have no global AGENTS.md |
.claude/skills/, ~/.claude/skills/ |
Loaded automatically |
.mcp.json servers |
Move to mcp.servers in opencode.json (the prompt does it) |
.claude/commands/*.md |
Copy to .opencode/commands/ (the prompt does it) |
| Hooks, permissions, settings | Set up again in OpenCode’s own config |
Want to make it official? Rename CLAUDE.md to AGENTS.md. It’s the shared format many agents read, including OpenCode and Codex.
Is it really greener?
Coding agents use a lot more AI than chat: every step of a task sends your context back to the model. Running that on a renewable-powered model, and using smaller models for small jobs, makes a real difference. We dig into the numbers in the environmental footprint of AI coding agents.
Viro’s open models run in data centers powered by 100% renewable energy, and the API doesn’t store your prompts or code for Viro-hosted models. Frontier models like Claude run on their makers’ infrastructure; Viro matches their electricity with renewable energy and labels them separately, so you always know which is which.
Coming from Codex instead?
Same idea, different files: see how to switch from Codex to OpenCode.
Get a free Viro API key and run your coding agent on clean energy.
Frequently asked questions
Can I use the Viro API inside Claude Code?
No. Claude Code only talks to endpoints that speak Anthropic's Messages API, and Anthropic says it doesn't support routing Claude Code to non-Claude models. The Viro API is OpenAI-compatible, so the way to use it is through an open agent like OpenCode.
Does OpenCode read my CLAUDE.md?
Yes. In any folder without an AGENTS.md, OpenCode reads CLAUDE.md instead, and with no global AGENTS.md it reads ~/.claude/CLAUDE.md. It also loads skills from .claude/skills and ~/.claude/skills.
Can I still use Claude models in OpenCode?
Yes. Through the Viro API you can pick Claude Sonnet 5 and other Claude models in OpenCode. They run on Anthropic's infrastructure and Viro matches their electricity with renewable energy, labelled Energy Matched.
Which model should I use for coding on clean energy?
Kimi K2.7 Code is built for coding and runs on 100% renewable-powered infrastructure. For cheaper, faster work, DeepSeek V4.1 Flash is a good default. The viro/clean router picks a renewable-powered model for each request.
Is OpenCode free?
OpenCode is open source. You pay only for the model usage through whatever provider you connect, here the Viro API, which starts with free sandbox credit and no card.
Sources
- OpenCode docs: Providers, Config, Rules, MCP servers, Skills, OpenCode
- OpenCode rules (AGENTS.md and CLAUDE.md), OpenCode
- LLM gateway configuration, Claude Code docs
- Connect Claude Code to tools via MCP, Claude Code docs
- Viro API, Viro
Cover photo by Chris Ried on Unsplash



