Prerequisites
Internet
Required for installation and API calls.
Terminal
macOS Terminal, Linux shell, or Windows PowerShell / CMD.
Create an OpenRouter API Key
-
1
Go to openrouter.ai and click Sign Up.
You can sign up with Google, GitHub, or email.
-
2
Navigate to Settings → Keys.
-
3
Click "Create Key".
Give it a descriptive name, e.g.,
claude-code-work. -
4
Copy your API key immediately.
It starts with
sk-or-v1-and is only shown once. Store it in a password manager. -
5
(Optional) Add credits at openrouter.ai/credits.
Credits are required to make API calls. Usage is pay-as-you-go.
Security reminder: Treat your API key like a password. Never share it, commit it to git, or paste it in Slack/Teams/email.
Install Claude Code
Option A — Native Install Recommended
Auto-updates in the background. Open Terminal and run:
curl -fsSL https://claude.ai/install.sh | bash
Option B — Homebrew
Does not auto-update — run brew upgrade claude-code periodically.
brew install --cask claude-code
Native Install Recommended
Works on most Linux distributions and WSL. Open your terminal and run:
curl -fsSL https://claude.ai/install.sh | bash
Prerequisite: Install Git for Windows first. Accept all defaults during installation.
Option A — PowerShell Recommended
Open PowerShell and run:
irm https://claude.ai/install.ps1 | iex
Option B — Command Prompt (CMD)
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Option C — WinGet
Does not auto-update — run winget upgrade Anthropic.ClaudeCode periodically.
winget install Anthropic.ClaudeCode
Option D — WSL
If you have WSL set up, open your WSL terminal and use the Linux install command above.
Configure Environment Variables
Tell Claude Code to route requests through OpenRouter by setting these environment variables.
Step 1: Open your shell profile in a text editor.
Zsh (default on macOS)
nano ~/.zshrc
Bash (default on most Linux)
nano ~/.bashrc
Step 2: Add these lines at the bottom of the file. Replace the placeholder with your actual key.
# Claude Code — OpenRouter Configuration
export OPENROUTER_API_KEY="sk-or-v1-YOUR_KEY_HERE"
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY=""
Step 3: Save the file (in nano: Ctrl+O → Enter → Ctrl+X).
Step 4: Reload your profile:
source ~/.zshrc # or: source ~/.bashrc
Option A — PowerShell Commands Recommended
Run these in PowerShell. Replace the placeholder with your actual key.
[Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", "sk-or-v1-YOUR_KEY_HERE", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://openrouter.ai/api", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-or-v1-YOUR_KEY_HERE", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "", "User")
After running, close and reopen PowerShell.
Option B — System Environment Variables (GUI)
- Press Win+R, type
sysdm.cpl, press Enter. - Go to Advanced tab → Environment Variables.
- Under User variables, click New and add each:
| Variable Name | Value |
|---|---|
| OPENROUTER_API_KEY | sk-or-v1-YOUR_KEY_HERE |
| ANTHROPIC_BASE_URL | https://openrouter.ai/api |
| ANTHROPIC_AUTH_TOKEN | sk-or-v1-YOUR_KEY_HERE |
| ANTHROPIC_API_KEY | (leave empty) |
Click OK to save, then close and reopen your terminal.
.env file in your project. The native Claude Code installer does not read .env files. They must be in your shell profile or set as system-level environment variables.
Launch & Verify
Open a new terminal window
Old windows won't have the new environment variables.
Navigate to any project folder and launch Claude Code:
cd your-project-folder
claude
If you were previously logged in to Anthropic, log out first:
/logout
This clears cached Anthropic credentials so OpenRouter takes over.
Verify the connection:
/status
You should see confirmation that your connection is active and routed through OpenRouter.
Try a test prompt:
What files are in this directory?
If Claude responds with a file listing — you're all set!
Success! Claude Code is now connected through OpenRouter. You can start using it for coding tasks.
Troubleshooting
"Authentication failed" or "Invalid API key" ▶
- Double-check your
OPENROUTER_API_KEYstarts withsk-or-v1-. - Make sure you opened a new terminal window after setting variables.
- Run
/logoutinside Claude Code to clear old Anthropic credentials. - Ensure
ANTHROPIC_API_KEYis set to an empty string (""), not left unset.
"Insufficient credits" or rate limit errors ▶
- Add credits at openrouter.ai/credits.
- Check your usage at openrouter.ai/activity.
"claude" command not found ▶
- Close and reopen your terminal after installation.
- On Windows, ensure Git for Windows is installed.
- Try reinstalling with the native installer.
Environment variables not being picked up ▶
- Do not put variables in a
.envfile — the native installer ignores them. - Variables must be in your shell profile (
~/.zshrcor~/.bashrc) or system environment variables. - Verify:
echo $ANTHROPIC_BASE_URL(macOS/Linux) orecho %ANTHROPIC_BASE_URL%(Windows CMD).
Behind a corporate proxy ▶
Add your proxy to your shell profile:
export HTTPS_PROXY="https://your-proxy:port"
ESAFENET (亿赛通) encryption blocking Claude Code ▶
ESAFENET CDG uses kernel-level transparent encryption that blocks node.exe and git.exe from reading encrypted source files. IT admins need to whitelist Claude Code processes.
Department CLI Tools
Curated command-line tools for each SEI Robotics department. Click any command to copy it.
AI Tool Recommendations
Ask our AI assistant for personalized CLI tool recommendations based on your role and workflow.
Your key is only used in your browser and sent directly to OpenRouter. It is never stored or sent anywhere else.
Quick Reference
| What | Command / Link | |
|---|---|---|
| Install (macOS / Linux) | curl -fsSL https://claude.ai/install.sh | bash | |
| Install (Windows PS) | irm https://claude.ai/install.ps1 | iex | |
| Install (Homebrew) | brew install --cask claude-code | |
| Install (WinGet) | winget install Anthropic.ClaudeCode | |
| Launch | claude | |
| Check status | /status | |
| Log out | /logout | |
| OpenRouter keys | openrouter.ai/settings/keys | |
| OpenRouter credits | openrouter.ai/credits | |
| Usage dashboard | openrouter.ai/activity | |
Tips & Best Practices
Monitor Costs
Check openrouter.ai/activity regularly. Set spending limits in your account settings.
Stay Updated
Native installs auto-update. Homebrew/WinGet users: upgrade manually.
Provider Failover
OpenRouter routes between multiple Anthropic providers for high availability.
Never Commit Keys
Keep your API key out of code, git repos, and shared documents. Use env vars only.