I use my own API key in private projects, and it seems to work like this:
# .env file ANTHROPIC_API_KEY=sk-...In the project:
# .claude/settings.json { "apiKeyHelper": "source .env && echo $ANTHROPIC_API_KEY" }Then invoke
claudein inside the project root and verify with/statuscommand:Claude Code v1.0.85 L Session ID: 69... ... Account L Auth Token: apiKeyHelper L API Key: apiKeyHelper
Source: https://github.com/anthropics/claude-code/issues/441#issuecomment-3207226042
If someone get this error: Error getting API key from apiKeyHelper (in settings or ~/.claude.json): /bin/sh: 1: source: not found
That error comes from the fact that your shell (likely /bin/sh) doesn’t recognize the source command — it’s a Bash built-in, not POSIX-standard.
Here's the fix (Force bash):
{ "apiKeyHelper": "bash -c 'source .env && echo $ANTHROPIC_API_KEY'" }
Never teach people to put a secret key in a non-popular env var convention file. Always put it in the popular environment variable file.
Answer from ImBIOS on Stack OverflowVideos
I use my own API key in private projects, and it seems to work like this:
# .env file ANTHROPIC_API_KEY=sk-...In the project:
# .claude/settings.json { "apiKeyHelper": "source .env && echo $ANTHROPIC_API_KEY" }Then invoke
claudein inside the project root and verify with/statuscommand:Claude Code v1.0.85 L Session ID: 69... ... Account L Auth Token: apiKeyHelper L API Key: apiKeyHelper
Source: https://github.com/anthropics/claude-code/issues/441#issuecomment-3207226042
If someone get this error: Error getting API key from apiKeyHelper (in settings or ~/.claude.json): /bin/sh: 1: source: not found
That error comes from the fact that your shell (likely /bin/sh) doesn’t recognize the source command — it’s a Bash built-in, not POSIX-standard.
Here's the fix (Force bash):
{ "apiKeyHelper": "bash -c 'source .env && echo $ANTHROPIC_API_KEY'" }
Never teach people to put a secret key in a non-popular env var convention file. Always put it in the popular environment variable file.
Looks like folks found a workaround that actually works: https://github.com/anthropics/claude-code/issues/441#issuecomment-3050967059
Create a
~/.claude/settings.jsonfile with this content:{ "apiKeyHelper": "echo <API KEY>" }
» npm install @anthropic-ai/claude-code
I'm a bit confused about how claude code work for payment. I've been logging in with my personal account and paying for credits but now I have an API key from my employer which I'd like to use. I also have a Claude Desktop subscription from my employer, but when I log in with that for Claude Code I'm still prompted to pay for my own credits and I don't see how to enter my API key.
I must be misunderstanding something - does anyone have any tips?