Can claude code work with multiple API keys?
Status Fixed / completed
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 7 comments · opened Mar 7, 2025 · closed Mar 7, 2025
I want to use CC with different API keys for different projects, so that I have an API key for work and one for side-projects, linked to different anthropic accounts.
Is that possible to do via claude config or similar?
7 Comments
Similar to #161
I wrote a small script today to workaround this - it dynamically updates the
primaryApiKeyin claude's confighttps://gist.github.com/preslavmihaylov/610032389f697af6806839c5856bdb09
Hi, you can use a multiple Claude Code configurations with
CLAUDE_CONFIG_DIRenv var as described here: https://github.com/anthropics/claude-code/issues/261#issuecomment-2701757283@presmihaylov I'd love to see that gist you shared, but currently it 404s when I click it. Any chance you could share it again?
Hey @Ga68 the solution I used at the time isn't applicable anymore as claude code changed the way their config file works.
Also, even if you use that suggestion to multiplex
CLAUDE_CONFIG_DIRthat is not going to work either because of this issue so no way to do this nowadays unfortunately unless Claude team shipped a fix for this.My workaround for now is to
/loginevery time to ensure I'm using the correct account.I have written a simple bash tool to manage the keys for the default Claude configuration file for multiple projects.
I wanted this not just to separate work/personal but to be able to allocate API costs to different Anthropic Console Workspaces for cost tracking.
Hopefully someone finds this useful.
https://github.com/jonopryor/claude-code-api-key-manager
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.