Can claude code work with multiple API keys?

Status Fixed / completed
Maintainer reply None cached
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?

View original on GitHub ↗

7 Comments

peterkaminski · 1 year ago

Similar to #161

presmihaylov · 1 year ago

I wrote a small script today to workaround this - it dynamically updates the primaryApiKey in claude's config
https://gist.github.com/preslavmihaylov/610032389f697af6806839c5856bdb09

ghost · 1 year ago

Hi, you can use a multiple Claude Code configurations with CLAUDE_CONFIG_DIR env var as described here: https://github.com/anthropics/claude-code/issues/261#issuecomment-2701757283

Ga68 · 1 year ago

@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?

presmihaylov · 1 year ago

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_DIR that 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 /login every time to ensure I'm using the correct account.

jonopryor · 1 year ago

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

github-actions[bot] · 1 year ago

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.