OpenCode plugin that lets you use Anthropic models with your Claude Pro/Max subscription. No API key required.
This is a fork of opencode-anthropic-login-via-cli with a workaround for copying the OAuth URL in remote and containerized environments (see Remote OAuth URL below).
Reads the Claude CLI binary to extract current beta headers, OAuth scopes, and version info. Stays in sync with Anthropic's API automatically instead of relying on hardcoded values.
Works on macOS, Linux, and Windows.
If you have Claude CLI installed and logged in, the plugin picks up your credentials automatically:
- macOS: System Keychain
- Linux / Windows:
~/.claude/.credentials.json
If you use CCS for multiple Claude Code instances, each instance in ~/.ccs/instances/ is detected and shows up as a separate auth method.
Opens an OAuth flow through claude.com for users without the CLI. Log in, paste the code, done.
Handles expired tokens automatically. Falls back to the CLI if the standard refresh fails.
Patches requests so OpenCode talks to Anthropic's API the same way Claude Code does.
Add to your opencode.json:
{
"plugin": ["opencode-anthropic-login-via-cli-remote@latest"]
}Then open OpenCode and go to Connect Provider > Anthropic.
| Method | Label | How it works |
|---|---|---|
| Auto | Claude Code (auto) | Reads existing CLI credentials from Keychain/filesystem |
| CCS | CCS (instance-name) | Auto-detects each CCS instance in ~/.ccs/instances/ |
| Browser | Claude Pro/Max (browser) | OAuth flow via claude.com with PKCE |
| API Key | API Key (manual) | Standard Anthropic API key |
When authenticating via Claude Pro/Max (browser), the OAuth URL is too long to fit on one line in the OpenCode TUI dialog. The TUI intercepts mouse and keyboard events, making it impossible to cleanly select and copy the URL. This affects anyone without direct desktop access to the machine running OpenCode.
When the env var OAUTH_URL_DIR is set, the plugin writes the full OAuth URL to $OAUTH_URL_DIR/oauth-url.txt as a single line each time the browser auth dialog opens. You can then read it from a second terminal and copy it cleanly into your browser.
If OAUTH_URL_DIR is not set, the plugin behaves exactly as the original — nothing is written and no message is shown.
export OAUTH_URL_HOST_DIR=~/.opencode-auth
export OAUTH_URL_DIR=/root/.opencode-auth
docker run -it --rm \
-e OAUTH_URL_DIR="${OAUTH_URL_DIR}" \
-v "${OAUTH_URL_HOST_DIR}":"${OAUTH_URL_DIR}" \
-v /path/to/opencode-config/:/root/.config/opencode \
-v "$PWD":/workspace \
-w /workspace \
ghcr.io/anomalyco/opencode| Argument | Purpose |
|---|---|
-it |
Keeps stdin open and allocates a TTY — required for the interactive OpenCode UI |
--rm |
Removes the container automatically when it exits |
-e OAUTH_URL_DIR |
Tells the plugin where inside the container to write the OAuth URL file |
-v "${OAUTH_URL_HOST_DIR}":"${OAUTH_URL_DIR}" |
Mounts the host directory into the container so the URL file is readable from your host |
-v /path/to/opencode-config/:/root/.config/opencode |
Mounts the directory containing your opencode.json so OpenCode can find and load the plugin. Without this mount the plugin will not be loaded. Replace /path/to/opencode-config/ with the actual host path. |
-v "$PWD":/workspace |
Mounts your current working directory as the project root inside the container |
-w /workspace |
Sets the container's working directory to match the mounted project |
When the auth dialog appears, on your host:
cat ~/.opencode-auth/oauth-url.txtSet the env var to any writable directory on the remote machine before starting OpenCode:
export OAUTH_URL_DIR=~/.opencode-auth
opencodeWhen the auth dialog appears, in a second session to the same machine:
cat ~/.opencode-auth/oauth-url.txtMIT