Skip to content

fix: Claude Code API credentials #7456

Closed as not planned
Closed as not planned

Description

@wlshlad85

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

Activity

  1. github-actions commented on Jan 9, 2026

    @github-actions
    Contributor

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

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

  2. davejfranco commented on Jan 9, 2026

    @davejfranco

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

  3. ZGltYQ commented on Jan 9, 2026

    @ZGltYQ
    Contributor

    Same

  4. osullivandonal commented on Jan 9, 2026

    @osullivandonal

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

  5. chrisayl commented on Jan 9, 2026

    @chrisayl

    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.
    
  6. igordertigor commented on Jan 9, 2026

    @igordertigor
    Contributor

    Same here on linux and independent of the specific model.

  7. andersonkrs commented on Jan 9, 2026

    @andersonkrs

    Same on Arch

  8. b1naryDS commented on Jan 9, 2026

    @b1naryDS

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

  9. ramirlm commented on Jan 9, 2026

    @ramirlm

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

  10. angelguillen10 commented on Jan 9, 2026

    @angelguillen10

    same here

  11. kevinefiles commented on Jan 9, 2026

    @kevinefiles

    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 #7410

  12. seuros commented on Jan 9, 2026

    @seuros
    Contributor

    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.

  13. harshav167 commented on Jan 9, 2026

    @harshav167
  14. angelguillen10 commented on Jan 9, 2026

    @angelguillen10

    This worked for me:

    • Updated ~/.config/opencode/opencode.json to add opencode-anthropic-auth@0.0.7:
        "plugin": [
        "opencode-anthropic-auth@0.0.7",
      ],
    
    • Then restart OpenCode and run opencode auth login (choose Anthropic/Claude).
  15. 25 remaining items

  16. Hennoloe commented on Jan 29, 2026

    @Hennoloe

    "plugin": ["opencode-anthropic-auth@latest"],

    Just added this line of code and updated to version 1.1.41 and it worked for me.

  17. itzcodex24 commented on Jan 30, 2026

    @itzcodex24

    Seeing this same issue, even after adding said plugin to the config and "restarting" opencode as well as signing out and back into anthropic oauth.

  18. Steffen025 commented on Jan 30, 2026

    @Steffen025

    Seeing this same issue, even after adding said plugin to the config and "restarting" opencode as well as signing out and back into anthropic oauth.

    Try the system prompt injection then: #7456 (comment)

  19. isomoes commented on Feb 9, 2026

    @isomoes

    We use Claude Pro OAuth. When using claude-opus-4-6, we encounter Error: unknown certificate verification error, but claude-sonnet-4-5 works fine. Interestingly, after re-logging into Anthropic, claude-opus-4-6 starts working. This behavior is confusing. @harshav167

    similar https://github.com/anomalyco/opencode-anthropic-auth/pull/47

  20. mahyarmirrashed commented on Mar 19, 2026

    @mahyarmirrashed

    Happening again...

  21. avall commented on Mar 20, 2026

    @avall

    Logged in claude (PRO Subscription):
    Image

    cat ~/.config/opencode/opencode.json
    {
    "$schema": "https://opencode.ai/config.json",
    "snapshot": false,
    "plugin": [
    "opencode-claude-auth"
    ]
    }

    npm ls -g --depth=0 opencode-claude-auth
    $HOME/.local/share/mise/installs/node/22.22.1/lib
    └── opencode-claude-auth@0.5.2

    Image

    Restart opencode > /connect > Anthropic (Claude Max or API Key)
    ... Nothing happens. It seems hanged

  22. nevalions commented on Mar 20, 2026

    @nevalions

    Yes it happens again, Failed to authorize

  23. mrstruijk commented on Mar 20, 2026

    @mrstruijk

    Same, it says that the code is invalid when trying to do /connect, and throws a 429 error when trying to use one of the Anthropic models.

    This worked for me: https://github.com/griffinmartin/opencode-claude-auth

  24. nevalions commented on Mar 20, 2026

    @nevalions

    This worked for me: https://github.com/griffinmartin/opencode-claude-auth

    Any security checks on this repo, is it trusted to share auth data?

  25. mrstruijk commented on Mar 20, 2026

    @mrstruijk

    Good question...? Idk!

  26. Joeyzzyy commented on Mar 31, 2026

    @Joeyzzyy

    I put together a narrow fix for this.

    Scope:

    • improve the error guidance for Claude Code-only Anthropic credentials
    • point users to use a standard Anthropic API key instead
    • keep this limited to provider error messaging plus a small test
  27. rekram1-node commented on Mar 31, 2026

    @rekram1-node
    Contributor

    We cannot legally support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions