Claude Code Integration
This guide explains how to use Claude Code with a third-party Claude-compatible endpoint.
Example gateway URL used in this guide: https://direct.reachapi.ai.
1. General Prerequisites
Before you begin, make sure that:
- You already have a ReachAPI key, for example
sk-xxxxxx - The gateway is compatible with the Claude Messages API at
POST /v1/messages - You have a usable terminal environment, such as Windows PowerShell, macOS Terminal, or a Linux shell
Official documentation for installation and advanced setup:
Node.js requirements:
- Minimum version:
18+ - Recommended version: LTS (
20+)
Note: We provide Claude-compatible capabilities through the AWS API, so we recommend additionally setting CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1". Because AWS API support typically lags behind, some experimental features may not be compatible yet.
2. Windows (PowerShell recommended)
2.1 Install Node.js and Claude Code
Install Node.js LTS:
winget install OpenJS.NodeJS.LTSVerify the installation:
node -v
npm -vInstall Claude Code using the officially recommended method:
irm https://claude.ai/install.ps1 | iexOptional Windows CMD installer:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdGlobal npm installation is also possible, but it is not the preferred approach:
npm install -g @anthropic-ai/claude-codeAfter installation, verify:
claude --version
claude doctorNote: On native Windows, Git for Windows is recommended. See Set up on Windows for more details.
2.2 Temporary Configuration (current session only)
$env:ANTHROPIC_BASE_URL="https://direct.reachapi.ai"
$env:ANTHROPIC_API_KEY="YOUR_REACH_API_KEY"
$env:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"
claude2.3 Persistent Configuration (recommended)
Option A: Write Claude Code global settings to %USERPROFILE%\.claude\settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://direct.reachapi.ai",
"ANTHROPIC_API_KEY": "YOUR_REACH_API_KEY",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}Option B: Use setx
setx ANTHROPIC_BASE_URL "https://direct.reachapi.ai"
setx ANTHROPIC_API_KEY "YOUR_REACH_API_KEY"
setx CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS "1"Reopen the terminal after running these commands.
Option C: Write to your PowerShell profile
Add-Content -Path $PROFILE -Value '`
$env:ANTHROPIC_BASE_URL="https://direct.reachapi.ai"`
$env:ANTHROPIC_API_KEY="YOUR_REACH_API_KEY"`
$env:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"`
'
. $PROFILE3. macOS / Linux / WSL
3.1 Install Node.js and Claude Code
If you use nvm:
nvm install --lts
nvm use --ltsOr install it from the Node.js website.
Verify the installation:
node -v
npm -vInstall Claude Code using the officially recommended method:
curl -fsSL https://claude.ai/install.sh | bashGlobal npm installation is also possible, but it is not the preferred approach:
npm install -g @anthropic-ai/claude-codeAfter installation, verify:
claude --version
claude doctor3.2 Temporary Configuration (current session only)
export ANTHROPIC_BASE_URL="https://direct.reachapi.ai"
export ANTHROPIC_API_KEY="YOUR_REACH_API_KEY"
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"
claude3.3 Persistent Configuration (recommended)
Option A: Write Claude Code global settings to ~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://direct.reachapi.ai",
"ANTHROPIC_API_KEY": "YOUR_REACH_API_KEY",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}Option B: Write the variables into your shell config file
zsh:
echo 'export ANTHROPIC_BASE_URL="https://direct.reachapi.ai"' >> ~/.zshrc
echo 'export ANTHROPIC_API_KEY="YOUR_REACH_API_KEY"' >> ~/.zshrc
echo 'export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"' >> ~/.zshrc
source ~/.zshrcbash:
echo 'export ANTHROPIC_BASE_URL="https://direct.reachapi.ai"' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY="YOUR_REACH_API_KEY"' >> ~/.bashrc
echo 'export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"' >> ~/.bashrc
source ~/.bashrc4. Project-Level Configuration (recommended)
For a single repository, project-level settings are usually the best option: .claude/settings.local.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://direct.reachapi.ai",
"ANTHROPIC_API_KEY": "YOUR_REACH_API_KEY",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}It is recommended not to commit this file into your repository.
5. Optional: Pin a Default Model
Temporary setting on macOS / Linux / WSL:
export ANTHROPIC_MODEL="YOUR_MODEL_ID"Temporary setting on Windows PowerShell:
$env:ANTHROPIC_MODEL="YOUR_MODEL_ID"Or add it to settings.json / settings.local.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://direct.reachapi.ai",
"ANTHROPIC_API_KEY": "YOUR_REACH_API_KEY",
"ANTHROPIC_MODEL": "YOUR_MODEL_ID"
}
}6. Verify the Setup
macOS / Linux / WSL:
ANTHROPIC_BASE_URL="https://direct.reachapi.ai" \
ANTHROPIC_API_KEY="YOUR_REACH_API_KEY" \
claude -p "Reply with: connection successful"Windows PowerShell:
$env:ANTHROPIC_BASE_URL="https://direct.reachapi.ai"
$env:ANTHROPIC_API_KEY="YOUR_REACH_API_KEY"
claude -p "Reply with: connection successful"If Claude Code returns model output, the gateway setup is working.
7. Troubleshooting
401 / 403 Authentication Failed
- Check whether
ANTHROPIC_API_KEYis correct - Confirm that the key is still valid and has access to the target model
404 / Invalid Path
- Confirm that
ANTHROPIC_BASE_URLis set tohttps://direct.reachapi.ai - Confirm that the gateway implements the Claude-compatible path
POST /v1/messages
Streaming Issues
- Confirm that the gateway supports
text/event-stream(SSE) - Check whether an intermediate layer such as a CDN, WAF, or reverse proxy is buffering the stream
Windows Commands Not Taking Effect
- After using
setx, you must reopen the terminal - If both settings files and system environment variables are configured, make sure old values are not overriding the new ones
- Run
claude doctorto inspect the current environment
Unable to connect to Anthropic services / ERR_BAD_REQUEST
If you see an error like this:
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ERR_BAD_REQUEST
Please check your internet connection and network settings.
Note: Claude Code might not be available in your country. Check
supported countries at https://anthropic.com/supported-countriesTry the following workaround:
- Open
~/.claude.json - Add this line in the JSON:
"hasCompletedOnboarding": true, - Save the file and restart Claude Code
Make sure the JSON remains valid, including commas in the right places.
8. Official References
- Claude Code environment variables: Environment variables
- Claude Code settings: Settings