When starting Claude Code, it first looks impossible to set a custom API key. You have two options:
- Claude account with subscription - Pro, Max, Team, or Enterprise
- Anthropic Console account - API usage billing
However, there is a hidden, third option, which is buried deep in the documentation and is usually the most-wanted authentication method by developers working for companies, because they are usually granted an Anthropic API key only, without a Console account. Here's what you need to do.
Create a file named settings.json in one of the following locations:
- In your home directory
- macOS:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json - Linux:
~/.claude/settings.json
- macOS:
- In your project directory's root
./.claude/settings.json
Add the following content to the file:
{
"apiKeyHelper": "echo <the-api-key-you-want-to-use>"
}This file is compatible with macOS, Windows, and Linux.
Restart Claude Code, and you should be able to use it without being asked to log in.
