API key authentication succeeds at /login but fails on first message

Resolved 💬 3 comments Opened Mar 27, 2026 by wildwoodroadhouse Closed Mar 31, 2026

Description

API key authentication via \/login\ appears to succeed (shows email, says "Login successful") but then fails when attempting to send the first message with "Not logged in" error.

Subscription authentication works perfectly. Only API key authentication is broken.

System Info

  • Claude Code Version: 2.1.85
  • OS: macOS (Darwin 25.3.0)
  • Shell: zsh
  • Setup: ANTHROPIC_API_KEY set in ~/.zshrc

Steps to Reproduce

  1. Set ANTHROPIC_API_KEY environment variable in shell
  2. Run \/login\
  3. CLI shows "Login successful" and displays email
  4. Attempt to send a message
  5. CLI returns "Not logged in * Please run /login"

Expected Behavior

After successful \/login\ with API key, messages should be sent using that API key without re-authentication.

Actual Behavior

API key is rejected on first message attempt despite:

  • Key being valid (verified via \curl -H "x-api-key: $KEY"\ to Anthropic API)
  • Key having full permissions (Tier 4 / Pro account)
  • \/login\ returning success message

Additional Notes

  • Subscription authentication (\/login\ without API key) works flawlessly
  • This matches reported GitHub issue #28176
  • API key has been tested and confirmed valid against Anthropic API endpoints

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗