Configure Claude Code with BytePass
Claude Code is Anthropic's official CLI coding assistant. This guide walks you through connecting it to BytePass so you can use Claude models without a direct Anthropic account.
Estimated time: 5–10 minutes (or under 2 minutes with CC-Switch)
Prerequisites
- Node.js 18+ — Check with
node --version. If not installed, download from nodejs.org. - A BytePass API key — Create one at bytepass.ai/keys. See Quick Start if you haven't registered.
Install Claude Code
npm install -g @anthropic-ai/claude-codeIf you see permission errors on macOS/Linux, use sudo npm install -g @anthropic-ai/claude-code or fix your npm prefix.
Configuration
Method 1: Import from BytePass dashboard (recommended)
If you have CC-Switch installed, go to bytepass.ai/keys and click the "Import to CCS" button next to your key. Done — no manual config needed.
See the full CC-Switch guide for installation and details.
Method 2: Environment variables
Set these two variables in your shell profile (~/.zshrc, ~/.bashrc, or ~/.bash_profile):
export ANTHROPIC_BASE_URL="https://api.bytepass.ai"
export ANTHROPIC_AUTH_TOKEN="sk-your-bytepass-key"Then reload your shell:
source ~/.zshrcImportant: The base URL is https://api.bytepass.ai — do NOT add /v1 at the end. Claude Code adds the path automatically.
Method 3: Config file
Edit ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.bytepass.ai",
"ANTHROPIC_AUTH_TOKEN": "sk-your-bytepass-key"
}
}This is the same file that CC-Switch writes to. If you already have other settings in this file, just add/update the env keys.
Verify
Open a new terminal and run:
claudeType any message. If you get a response from Claude, the setup is complete.
Troubleshooting
"Please log in" or login page keeps opening
Claude Code may try to open a browser login on first run. Once you've configured the API key via env vars or settings.json, this should not happen. If it persists, make sure you opened a new terminal after setting the variables.
401 Unauthorized
- Check that your API key is correct and starts with
sk- - Make sure you have credits in your BytePass account
400 Bad Request or "invalid URL"
You likely added /v1 to the base URL. Use https://api.bytepass.ai — no trailing path.
"Connection refused" or timeout
- Check your network connection
- Test API reachability:
curl https://api.bytepass.ai/v1/models -H "Authorization: Bearer YOUR_KEY"
Environment variable not taking effect
- Make sure you opened a new terminal after editing your shell profile
- Check for conflicting variables:
env | grep ANTHROPIC - If using
settings.json, make sure the JSON is valid
What's next?
- CC-Switch — Simplify config management
- Tips & tricks — Save tokens, manage context, and work more efficiently
- FAQ — Common questions and error fixes