What the official cloud options don't support
According to Anthropic's documentation:
- Remote Control — "API keys are not supported." It also stops working when
ANTHROPIC_BASE_URLpoints anywhere other thanapi.anthropic.com, and your own computer has to stay on. - Cloud sessions (Claude Code on the web) — require signing in with a claude.ai account and "aren't available through third-party providers." API keys set in the cloud environment don't override your subscription.
So if you use an Anthropic Console key, a company gateway, OpenRouter, or another Anthropic-compatible provider, the official cloud features are off the table. The CLI itself works fine with all of them—it just needs somewhere to run.
How Claude Code picks up your key
ANTHROPIC_API_KEYSent as the x-api-key header. Used instead of your subscription when set.ANTHROPIC_AUTH_TOKENSent as a Bearer token. Anthropic recommends it when you're unsure which one a gateway expects.ANTHROPIC_BASE_URLWhere requests go. Leave unset for Anthropic's own API.ANTHROPIC_DEFAULT_*_MODELMap the opus, sonnet, and haiku aliases to the model IDs your provider offers.Setup on any Linux server
Install Claude Code
Follow Anthropic's install guide on the server, or use a machine that already has it.
Add your credentials to settings
Put them under
envin~/.claude/settings.jsonso they apply no matter howclaudeis launched.Keep it running
Start sessions inside
tmuxso they survive disconnects, and secure remote access to the box.Verify
Run
/statusinside Claude Code to confirm the base URL and credential it's actually using.
{
"env": {
"ANTHROPIC_API_KEY": "sk-ant-..."
}
}
For a gateway or relay, use ANTHROPIC_BASE_URL plus ANTHROPIC_AUTH_TOKEN instead. Never put keys in a project's committed .claude/settings.json.
The shortcut: AlwaysAgent
AlwaysAgent hands you a dedicated US Linux server with Claude Code and Codex preinstalled and a browser workspace on top. Paste your key, base URL, or relay in settings and start a session.
- Your keys stay on your own server. We never proxy your model calls or add a markup.
- Close your laptop and the task keeps running; check in from your phone.
- Use an Anthropic key, OpenRouter, a relay, or your claude.ai login—switch per session.
FAQ
Does Claude Code on the web support API keys?
Should I use ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN?
Will my API key override my Claude subscription?
Your own server, your own key
AlwaysAgent gives you a dedicated Linux server with Claude Code and Codex preinstalled. Paste your key in settings and start from any browser.
Try it for $0.05/h →