Skip to content

[BUG] Claude Code provider fails with "Invalid API key" despite working CLI authentication #8322

@kazyur

Description

@kazyur

Problem (one or two sentences)

Claude Code provider fails with "Invalid API key" despite working CLI authentication

Context (who is affected and when)

Environment:

Problem:
The Claude Code provider consistently fails with "Invalid API key · Fix external API key" error despite having a properly authenticated Claude CLI that works perfectly in terminal.
Steps to Reproduce:

Install Claude CLI and authenticate with subscription token
Verify CLI works: /Users/andrewkazyur/.local/bin/claude "test" - responds correctly
Configure Roo Code with Claude Code provider pointing to /Users/andrewkazyur/.local/bin/claude
Attempt to use Roo Code - fails with "Invalid API key" error

Expected Behavior:
Roo Code should use the authenticated Claude CLI session for requests
Actual Behavior:
Command fails with exit code 1:
Command failed with exit code 1: /Users/andrewkazyur/.local/bin/claude -p --system-prompt ...
Additional Context:

Claude CLI works perfectly when called directly from terminal
Environment variable ANTHROPIC_API_KEY is properly set with subscription token
Token is valid for 1 year and tied to Claude Max subscription
Same authentication works for interactive Claude CLI usage

Suspected Issue:
The Claude Code provider appears unable to properly interface with Claude CLI's authentication when spawning external processes, despite the CLI being properly authenticated and functional.

Additional information:
When Anthropic API key is connected, RooCode works perfectly

Reproduction steps

OS: macOS Sequoia
Roo Code version: v3.28.8
Claude CLI version: 1.0.124

Expected result

Roo Code should use the authenticated Claude CLI session for requests even when it's authenticated with the token (roo chat subscription)

Actual result

Command fails with exit code 1: Command failed with exit code 1: /Users/andrewkazyur/.local/bin/claude -p --system-prompt ... . Roo said Invalid API key · Fix external API key

Variations tried (optional)

Claude CLI works perfectly when called directly from terminal
Environment variable ANTHROPIC_API_KEY is properly set with subscription token
Token is valid for 1 year and tied to Claude Max subscription
Same authentication works for interactive Claude CLI usage

Suspected Issue:
The Claude Code provider appears unable to properly interface with Claude CLI's authentication when spawning external processes, despite the CLI being properly authenticated and functiona

App Version

v3.28.8

API Provider (optional)

None

Model Used (optional)

Claude Code

Roo Code Task Links (optional)

https://app.roocode.com/task/b6ed7652-8c42-4614-ba59-800fef91cd26

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions