README · Auth Methods · Troubleshooting · Architecture
-
Add the plugin to
opencode.json:{ "plugin": ["opencode-claude-code-auth"] } -
Configure models:
npx opencode-claude-code-auth configure
-
Login:
opencode auth login -p anthropic
-
Verify:
opencode run "Hello" -m anthropic/claude-haiku-4-5
opencode auth login -p anthropicIf Anthropic models are not configured, the CLI prompts:
| Option | What it does |
|---|---|
Update this project |
Adds Anthropic provider + default models to opencode.json |
Skip for now |
Skips config. Run npx opencode-claude-code-auth configure later. |
npx opencode-claude-code-auth configure
opencode auth login -p anthropic| Flag | What it does |
|---|---|
| (no flags) | Finds project opencode.json / opencode.jsonc, previews patch, asks for confirmation |
--global |
Uses global config at ~/.config/opencode/opencode.json |
--file <path> |
Uses a specific file |
-y / --yes |
Skips confirmation |
What it adds (only missing keys):
| Key | Value |
|---|---|
provider.anthropic.npm |
@ai-sdk/anthropic |
provider.anthropic.name |
Anthropic |
provider.anthropic.models.claude-sonnet-4-5 |
Claude Sonnet 4.5 |
provider.anthropic.models.claude-haiku-4-5 |
Claude Haiku 4.5 |
model |
anthropic/claude-sonnet-4-5 |
small_model |
anthropic/claude-haiku-4-5 |
Note: The command is idempotent. Running it again when config already exists does nothing.
npx opencode-claude-code-auth doctor| Field | What it checks |
|---|---|
file |
Target config file path |
has |
Whether the file exists |
provider |
Whether provider.anthropic exists |
sonnet |
Whether claude-sonnet-4-5 model exists |
haiku |
Whether claude-haiku-4-5 model exists |
model |
Value of model field |
small |
Value of small_model field |
auth |
Anthropic auth type in OpenCode storage |
Full configuration (copy-paste ready)
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-claude-code-auth"],
"model": "anthropic/claude-sonnet-4-5",
"small_model": "anthropic/claude-haiku-4-5",
"provider": {
"anthropic": {
"npm": "@ai-sdk/anthropic",
"name": "Anthropic",
"models": {
"claude-sonnet-4-5": {
"name": "Claude Sonnet 4.5"
},
"claude-haiku-4-5": {
"name": "Claude Haiku 4.5"
}
}
}
}
}Build from source:
npm install
npm run typecheck
npm run build
npm run smokeLoad locally:
{
"plugin": [
"file:///absolute/path/to/opencode-claude-code-auth/dist/index.js"
]
}