Anthropic Authentication Plugin for OpenCode

0.1.6 · active · verified Wed Apr 22

This package, `opencode-claude-code-auth`, is an OpenCode plugin designed to restore and manage Anthropic (Claude) authentication methods within the OpenCode ecosystem. It provides three distinct authentication paths: reading local Claude Code session credentials, initiating a browser-based OAuth flow, or utilizing a plain Anthropic API key. The plugin addresses the removal of built-in Anthropic authentication from OpenCode v1.3.x, ensuring continued access to Claude models for users. It is currently at version 0.1.6, indicating active development with frequent minor updates. Key differentiators include its flexible login options, token management (refreshing Claude CLI tokens or using OAuth refresh tokens), and seamless integration into OpenCode's provider system to intercept and manage all Anthropic API traffic. It targets Node.js environments version 20 or higher.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to add the plugin to `opencode.json`, authenticate with Anthropic via the CLI, and then test model access.

{
  "plugin": ["opencode-claude-code-auth"]
}

# Save the above JSON to your opencode.json file

# Then, in your terminal:
opencode auth login -p anthropic

# Follow the prompts to pick a login path (Claude Code session, browser sign-in, or API key).
# If OpenCode asks to configure Anthropic models, say yes.

# Verify your setup:
opencode run "Hello, Claude! What's new?" -m anthropic/claude-sonnet-4-5

view raw JSON →