{"id":16871,"library":"opencode-claude-code-auth","title":"Anthropic Authentication Plugin for OpenCode","description":"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.","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/ragingstar2063/opencode-claude-code-auth","tags":["javascript","opencode","opencode-plugin","anthropic","claude","claude-code","oauth","authentication","ai","typescript"],"install":[{"cmd":"npm install opencode-claude-code-auth","lang":"bash","label":"npm"},{"cmd":"yarn add opencode-claude-code-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add opencode-claude-code-auth","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"While end-users typically interact via the `npx opencode-claude-code-auth configure` CLI, this is a hypothetical programmatic entry point for internal or advanced OpenCode-plugin development to trigger the configuration logic.","symbol":"configurePlugin","correct":"import { configurePlugin } from 'opencode-claude-code-auth/cli';"},{"note":"This represents the main plugin class or entry point that OpenCode's plugin system would internally instantiate. Direct programmatic import by end-user applications is not the primary use case, as interaction is usually through OpenCode's configuration and CLI.","symbol":"AnthropicAuthPlugin","correct":"import { AnthropicAuthPlugin } from 'opencode-claude-code-auth';"},{"note":"This is a type import for the internal Anthropic provider interface, useful for TypeScript developers who might be extending or understanding the plugin's internal workings within the OpenCode framework. Not for direct end-user consumption.","symbol":"AnthropicProvider","correct":"import type { AnthropicProvider } from 'opencode-claude-code-auth/types';"}],"quickstart":{"code":"{\n  \"plugin\": [\"opencode-claude-code-auth\"]\n}\n\n# Save the above JSON to your opencode.json file\n\n# Then, in your terminal:\nopencode auth login -p anthropic\n\n# Follow the prompts to pick a login path (Claude Code session, browser sign-in, or API key).\n# If OpenCode asks to configure Anthropic models, say yes.\n\n# Verify your setup:\nopencode run \"Hello, Claude! What's new?\" -m anthropic/claude-sonnet-4-5\n","lang":"typescript","description":"This quickstart demonstrates how to add the plugin to `opencode.json`, authenticate with Anthropic via the CLI, and then test model access."},"warnings":[{"fix":"Ensure `opencode-claude-code-auth` is added to your `opencode.json` plugin array and you have completed the `opencode auth login -p anthropic` process.","message":"OpenCode v1.3.x and newer versions removed built-in Anthropic authentication, making this plugin necessary to restore the functionality. Without it, direct Anthropic integration in OpenCode will fail.","severity":"breaking","affected_versions":">=1.3.0 (for OpenCode), all versions (for this plugin)"},{"fix":"Upgrade your Node.js environment to version 20 or newer. Check your Node.js version with `node -v`.","message":"The package requires Node.js version 20 or higher. Running with older Node.js versions will result in execution errors.","severity":"gotcha","affected_versions":"<0.1.0"},{"fix":"Install the Anthropic `claude` CLI and ensure you are logged in via `claude login`. Alternatively, use the 'Browser sign-in' or 'API key' methods.","message":"When using the 'Claude Code session' login path, the plugin relies on the `claude` CLI being installed and configured to read credentials from the macOS Keychain (or `~/.claude/.credentials.json` on Linux/Windows). If the `claude` CLI is not present or its tokens are invalid, this authentication method will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"For 'Claude Code session', ensure the `claude` CLI can be spawned. For 'Browser sign-in', ensure network access to Anthropic's OAuth endpoints for refresh token usage. API key is generally most straightforward for non-interactive use.","message":"Token refresh mechanisms differ significantly between the 'Claude Code session' and 'Browser sign-in' paths. Developers should be aware of these differences, especially in automated environments where manual intervention for refreshes is undesirable.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Verify that `\"opencode-claude-code-auth\"` is present in the `plugin` array within your `opencode.json` file. Ensure OpenCode has internet access to download npm packages.","cause":"The `opencode-claude-code-auth` plugin was not correctly specified in `opencode.json` or OpenCode failed to install it automatically.","error":"Error: Cannot find module 'opencode-claude-code-auth'"},{"fix":"Run `opencode auth login -p anthropic` again to re-authenticate and refresh your tokens. If using an API key, double-check its validity.","cause":"Your authentication tokens (session, OAuth, or API key) have expired, are invalid, or lack the necessary permissions.","error":"Authentication Failed: Anthropic API returned a 401 or 403 error."},{"fix":"Upgrade your Node.js environment to version 20 or higher, as required by the package. Use `nvm install 20` or your preferred Node.js version manager.","cause":"This error typically indicates an incompatible Node.js version, especially when `NODE_OPTIONS` conflicts with internal module loading or features not present in older versions.","error":"node: --enable-source-maps is not allowed in NODE_OPTIONS"}],"ecosystem":"npm","meta_description":null}