[BUG] claude code doesn't use different API keys for different claude profiles

Resolved 💬 7 comments Opened Mar 27, 2025 by presmihaylov Closed Jan 4, 2026

I'm trying to maintain two separate projects for claude code - one for work, one personal using different API keys.

I had configured that the following way:

alias ccwork="ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY_WORK\" CLAUDE_CONFIG_DIR=\"/Users/pmihaylov/.claudework\" claude"
alias cchobby="ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY_SIDE\" CLAUDE_CONFIG_DIR=\"/Users/pmihaylov/.claudehobby\" claude"

however, I recently found out that for a long time, claude had been using my personal API key in my work account.

I tried fixing this by relogging and setting up new API keys but it seems that's of no use. Regardless of which directory I point the tool to, it always uses whatever API key you last configured.

I also tried setting up the configuration for "use custom API key" but it doesn't seem to respect that at all.

How I tested this:

  • login to work account + setup new API key
  • login to hobby account + setup new API key
  • disable hobby API key
  • run ccwork - this results in Invalid API key because it's attempting to use the hobby API key (the last one I logged in with)

Same happens in the other direction, when logging in work account last + using cchobby.

View original on GitHub ↗

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