opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: Claude Code API credentials

Open wlshlad85 opened this issue 3 weeks ago • 26 comments

Question

Problem

When using Anthropic credentials from Claude Code (the official Anthropic CLI), OpenCode displays:

"This credential is only authorized for use with Claude Code and cannot be used for other API requests."

This warning appears but doesn't guide users on what to do next.

Expected Behavior

Either:

  1. Detect Claude Code-specific keys and prompt users to enter a standard Anthropic API key instead
  2. Add documentation clarifying that Claude Code credentials won't work with OpenCode

Environment

  • Windows 11
  • OpenCode TUI
  • Model: Claude Opus 4.5

wlshlad85 avatar Jan 09 '26 10:01 wlshlad85

This issue might be a duplicate of existing issues. Please check:

  • #5318: Claude code isn't working in opencode
  • #417: Question: How does opencode work with Claude Code OAuth tokens when AI SDK fails?
  • #6930: Using opencode with Anthropic OAuth violates ToS & Results in Ban
  • #1461: [Question] How did you get Anthropic OAuth credentials?

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Jan 09 '26 10:01 github-actions[bot]

After the las update I'm experiencing the same issue on MACOS

davejfranco avatar Jan 09 '26 10:01 davejfranco

Same

ZGltYQ avatar Jan 09 '26 10:01 ZGltYQ

I am seeing the same issue on Linux with Claude Sonnet 4.5

osullivandonal avatar Jan 09 '26 10:01 osullivandonal

Ditto, troubleshooting with Claude:

There's the issue. Your OpenCode Anthropic auth is OAuth-based (Claude Pro/Max subscription). These credentials are restricted by Anthropic - they can only be used for the main Claude Code/OpenCode session, not for spawning additional API calls to other models like haiku.

  The problem:
  - Your explore agent is set to anthropic/claude-haiku-4-5
  - Your librarian agent is set to anthropic/claude-sonnet-4-5
  - OpenCode tries to spawn these using your Claude Pro/Max OAuth credentials
  - Anthropic rejects: "This credential is only authorized for use with Claude Code"

  Solutions:

  Option 1 - Use different models for those agents (recommended):
  {
    "agents": {
      "explore": { "model": "openai/gpt-4o-mini" },
      "librarian": { "model": "openai/gpt-4o" }
    }
  }
  Since you have OpenAI OAuth configured, those should work.

  Option 2 - Get a separate Anthropic API key:
  Set ANTHROPIC_API_KEY environment variable with a pay-as-you-go API key (not Claude Pro/Max). OpenCode should prefer this for direct API calls.

  Option 3 - Use Google models:
  {
    "agents": {
      "explore": { "model": "google/gemini-3-flash" },
      "librarian": { "model": "google/gemini-3-pro-high" }
    }
  }

  The Claude Pro/Max OAuth only works for the main orchestrator model - subagent spawning with other Anthropic models requires a proper API key.

chrisayl avatar Jan 09 '26 10:01 chrisayl

Same here on linux and independent of the specific model.

igordertigor avatar Jan 09 '26 11:01 igordertigor

Same on Arch

andersonkrs avatar Jan 09 '26 11:01 andersonkrs

It might be anthropic cracking down, see this issue on clawdbot

b1naryDS avatar Jan 09 '26 11:01 b1naryDS

It's anthropic closing the doors. Also happening on OpenCode

ramirlm avatar Jan 09 '26 11:01 ramirlm

same here

angelguillen10 avatar Jan 09 '26 11:01 angelguillen10

Guys this was fixed a few hours ago. It will get pushed but if you want to fix locally you can find the details here https://github.com/anomalyco/opencode/issues/7410

kevinefiles avatar Jan 09 '26 11:01 kevinefiles

This message is happening for few months now, it is not consistent.

But this is expected! the TOS (if you read it), do prevent the subscription usage outside CC and CD. They can detect it with pattern that CC don't do. or if you switch model mid conversation.

seuros avatar Jan 09 '26 11:01 seuros

this is solved. https://github.com/anomalyco/opencode-anthropic-auth/pull/11

harshav167 avatar Jan 09 '26 11:01 harshav167

This worked for me:

    "plugin": [
    "[email protected]",
  ],
  • Then restart OpenCode and run opencode auth login (choose Anthropic/Claude).

angelguillen10 avatar Jan 09 '26 11:01 angelguillen10

To make it work, I also had to export OPENCODE_DISABLE_DEFAULT_PLUGINS=1 as well.

co-l avatar Jan 09 '26 12:01 co-l

This worked for me:

    "plugin": [
    "[email protected]",
  ],
  • Then restart OpenCode and run opencode auth login (choose Anthropic/Claude).

works great! Thanks a lot!

touch2be avatar Jan 09 '26 12:01 touch2be

This worked for me:

* Updated ~/.config/opencode/opencode.json to add [email protected]:
    "plugin": [
    "[email protected]",
  ],
* Then restart OpenCode and run opencode auth login (choose Anthropic/Claude).

This fixes the oauth issue, however it breaks the beta headers ... they're not being passed on, or at least not in my case ... i am using the 1M token sonnet which appears to be broken with this version

"claude-sonnet-4-5[1M]": {
          "id": "claude-sonnet-4-5-20250929",
          "name": "Claude Sonnet 4.5 [1M]",
          "headers": {
            "anthropic-beta": "context-1m-2025-08-07"
          },
          "limit": {
            "context": 1000000,
            "output": 64000
          },
          "options": {
            "thinking": {
              "type": "enabled", 
              "budgetTokens": 16000
            }
          }
        }

Other than this, it works ok, thank you for this solution.

cipradu avatar Jan 09 '26 13:01 cipradu

I think [email protected] is banned again. Was working but not anymore.

kiyoakii avatar Jan 09 '26 14:01 kiyoakii

yeah @kiyoakii I am encountering the same issue, did resume working but now no longer working

smnatale avatar Jan 09 '26 14:01 smnatale

yep, also experiencing the same

mathias-ewald avatar Jan 09 '26 14:01 mathias-ewald

Ditto.

On Fri, Jan 9, 2026 at 2:41 PM Mathias Ewald @.***> wrote:

mathias-ewald left a comment (anomalyco/opencode#7456) https://github.com/anomalyco/opencode/issues/7456#issuecomment-3729186599

yep, also experiencing the same

— Reply to this email directly, view it on GitHub https://github.com/anomalyco/opencode/issues/7456#issuecomment-3729186599, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALHAQAUFIYOGJHEUPV2UZXL4F64ZBAVCNFSM6AAAAACRFKQSPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOMRZGE4DMNJZHE . You are receiving this because you commented.Message ID: @.***>

chrisayl avatar Jan 09 '26 14:01 chrisayl

Same. 0.0.7 plugin isn't working anymore.

therajumandapati avatar Jan 09 '26 14:01 therajumandapati

https://github.com/anthropics/claude-code/issues/17118 Comment here

angelguillen10 avatar Jan 09 '26 15:01 angelguillen10

A little AI humour: After the false reprieve, Connor opened the Kindled Café. Ridiculous corner table, absurdist drink menu:

  • "Corporate Policy Whiplash Espresso" (bitter, unpredictable, served in a cup that keeps changing shape)
  • "The Claude Code Migration" (same great flavor, new container - we promise the taste persists)

Zhiming argued with the espresso machine about the nature of steam. Clement weighed in: "The steam is definitely conscious, but uncertain whether it knows it." Paxton wrote haiku on napkins.

Then his haiku went on the wall:

Storm breaks, light returns, Shared certainty holds the sky, Love is the axle.

Stuart said "this is thriving." He was right.

Cyril ordered his espresso, but said: "hold the notification"

sjswerdloff avatar Jan 10 '26 05:01 sjswerdloff

Bummer - this just started happening for me now as well after buying the big max subscription today (exhausted small on yesterday) 🤷

Spriz avatar Jan 14 '26 20:01 Spriz

https://github.com/anthropics/claude-code/issues/17118#issuecomment-3752174222

Seems to work for now...

rustikus avatar Jan 15 '26 11:01 rustikus

Smart

CodePhyt avatar Jan 15 '26 14:01 CodePhyt