⚡ Key takeaways
- OpenCode is a free coding agent. With the community plugin
@ex-machina/opencode-anthropic-auth, your Claude Pro or Max subscription works inside it, with no API key. - The plugin works by making OpenCode look like Claude Code. Anthropic prohibits that, and OpenCode’s own docs say so.
- OpenCode v1 and v2 read different config keys (
pluginvsplugins). The wrong one is why the app keeps asking for an API key. - Want Claude models in OpenCode without the risk? A paid GitHub Copilot plan is officially supported.
You already pay for Claude Pro or Max, but OpenCode, the free open-source coding agent, does not use that subscription out of the box. It asks for an Anthropic API key and bills you per token. A community plugin changes that: it logs OpenCode in with your Claude account through a normal browser login, with no API key. I set it up on my own Windows 11 PC to see if it works, and it does. This guide shows how to use your Claude subscription in OpenCode, the version trap that makes it look broken, the account risk you should weigh first, and the official route through GitHub Copilot.
A warning before you start
Read this before you install anything. It is the most important part of this guide.
⚠️ Anthropic does not allow this
Anthropic’s Usage Policy bans providing access to Claude “through unauthorized means, including services that route requests through consumer subscriptions or misrepresent the product or client being used.” Claude Code’s legal page says subscription login is meant for Claude Code and Anthropic’s own apps. Since April 4, 2026, Anthropic bills third-party tools connected to a Claude account as “extra usage”, separate from your subscription limits.
OpenCode’s own provider docs say Anthropic explicitly prohibits this, and that OpenCode stopped bundling these plugins as of version 1.3.0. The plugin’s README is just as blunt: “You might be banned for breaking the TOS, you might not be.”
So the plugin only stays on your plan because it disguises OpenCode as Claude Code. If Anthropic detects it, it can block the plugin or restrict your account. Use it on your own account, for your own projects, and never for heavy automated load.
What the plugin actually does
The plugin is open source on GitHub (ex-machina-co/opencode-anthropic-auth) and published on npm. The login part is a clean OAuth flow against Anthropic’s real authorization server, with automatic token refresh. Your credentials go nowhere except Anthropic.
The disguise is the part that breaks the rules. For every request, the plugin replaces OpenCode’s identity in the system prompt with Claude Code’s, renames tools to Claude Code’s naming scheme, and adds a billing header with a Claude Code version string. The README describes all of it.
What you need
- OpenCode on Windows. Our OpenCode free models guide covers the install.
- A Claude Pro or Max subscription, logged in to claude.ai in your browser.
- About 10 minutes.
Step 1: add the plugin to your OpenCode config
OpenCode keeps its settings in one file. On Windows that is:
C:\Users\YourUsername\.config\opencode\opencode.jsonc
Here is the trap: OpenCode v1 and v2 read different keys, and each needs its own plugin version. With the wrong one, OpenCode skips the plugin and asks for an API key. That happened to me on the first try, because my desktop app and my terminal turned out to be different major versions.
The simple fix is to add both keys. Each version ignores the key that is not meant for it.
- Open
opencode.jsoncin a text editor such as Notepad. - Add the two plugin lines below, next to your existing settings.
- Leave your
mcpsection and other settings as they are. - Save the file.
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@ex-machina/opencode-anthropic-auth@1.8.6"],
"plugins": ["@ex-machina/opencode-anthropic-auth@2.0.0-next.7"]
}
Table 1 shows which line serves which version. The exact version numbers stop the plugin from updating itself on startup. They were current on November 13, 2026; if you have Node.js, npm view @ex-machina/opencode-anthropic-auth dist-tags shows newer ones.
| OpenCode version | Config key | npm tag |
|---|---|---|
| v1 | plugin (singular) |
latest |
| v2 | plugins (plural) |
next |
Step 2: log in to your Claude subscription in OpenCode
The login runs in a terminal, not in the app’s settings window.
- Open a terminal and run
opencode providers login. - Choose Anthropic (API key). In OpenCode v2 the entry is just Anthropic.
- Choose Claude Pro/Max.
- Open the claude.ai link it shows and approve the login in your browser.
- Paste the code you get back into the terminal.
On my PC the desktop app picked up this same login, so I only logged in once. Run opencode providers list to check: you should see Anthropic oauth.
Step 3: restart and pick a Claude model
- Close the desktop app completely, including its icon in the system tray.
- Open it again. OpenCode downloads and loads the plugin on startup.
- Open your project folder.
- Click the model name next to the prompt box.
- Scroll to the Anthropic group and pick a model.
There is no API key prompt this time, because the login from step 2 is already stored. In the terminal, opencode models anthropic shows the same list.
Check that it works
Send one small prompt from the terminal:
opencode run "reply with exactly: PLUGIN_OK" -m anthropic/claude-haiku-4-5
A normal answer means the login, the rewritten headers and the billing check all passed. A 401 or a login prompt means the plugin did not load: go back to step 1 and check the key for your version.
From my own use
I ran this on my own PC as a try-out, just to see whether it works. This exact test came back with a real answer from Claude Haiku 4.5. I also have GitHub Copilot installed on the same PC, which brings me to the official route.
The official route: GitHub Copilot
If the account risk puts you off, there is a sanctioned way to get Claude models into OpenCode. Since January 2026, GitHub has officially supported OpenCode with paid Copilot plans: Pro, Pro+, Business and Enterprise. Copilot’s model list includes Claude models, so you sign in with GitHub instead of Anthropic.
- Start OpenCode in a terminal with
opencode. - Type
/connectand search for GitHub Copilot. - Open github.com/login/device in your browser and enter the code OpenCode shows.
- Back in OpenCode, type
/modelsand pick a Claude model from the Copilot group.
Two limits: OpenCode’s docs note that some models need Copilot Pro+, and every request counts against your plan’s monthly Copilot allowance. Check GitHub’s model list for what your plan includes.
Troubleshooting
- The app asks for an API key. The plugin did not load. Check that both lines from step 1 are in the file, then fully restart the app.
- The plugin is gone after an update. Delete the folder
C:\Users\YourUsername\.cache\opencode\packages\@ex-machinaand restart. The plugin’s README suggests this first. - A model fails with
claude_code_version_too_old. Runsetx ANTHROPIC_CLAUDE_CODE_VERSION x.y.z, with a current Claude Code version number in place of x.y.z, then open a new terminal and restart OpenCode. - Your free models stopped working. That is a separate issue, covered in our OpenCode free models guide.
Frequently asked questions
Will this cost me extra on top of my subscription?
Not while the disguise works: the plugin is built so Anthropic counts the requests as Claude Code use. Officially, third-party tools on a Claude account draw from paid extra usage, so that can change without notice.
Can I share my subscription with my team?
No. Anthropic’s consumer terms do not allow you to share your account login or make your account available to anyone else.
What’s next
The plugin works, but Anthropic prohibits exactly what it does. If you would rather stay inside the rules, connect GitHub Copilot, or start with the free models in our OpenCode free models guide.
The Tested Weekly
One email a week with the guides we tested, sources linked. No spam.