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.
Getting Started Scenarios
Three common workflows for setting up a project with Claude Code and a CLAUDE.md file. Pick the scenario that matches your situation.
Create your project directory
mkdir my-project && cd my-project
Initialize a git repository
git init
Launch Claude Code
claude
Paste the prompting framework into Claude Code
Copy the structured brief below, fill in your details, and paste it as your first message to Claude.
Ask Claude to generate a CLAUDE.md file
Claude will create a CLAUDE.md based on your project context.
Review and refine CLAUDE.md
Check the generated file, then ask Claude to adjust anything that's missing or incorrect.
Create a GitLab repo and push
git add -A
git commit -m "Initial project setup with CLAUDE.md"
git remote add origin https://gitlab.company.com/your-group/project-name.git
git push -u origin main
Replace gitlab.company.com with your actual self-hosted GitLab hostname.
Prompting Framework for New Projects
Copy this template, fill in the bracketed fields, and paste it as your first message to Claude Code:
I'm starting a new project. Here's the context:
Project: [name]
Department: [Android Source / APK Tools / Embedded Linux / Smart Devices / Cloud Engineering]
Purpose: [one sentence — what does this project do?]
Platform: [Android TV / Set-top box / Linux SBC / Cloud service / etc.]
Languages: [Java / Kotlin / C / C++ / Python / Go / TypeScript / etc.]
Framework: [AOSP / Buildroot / Spring Boot / FastAPI / React / etc.]
Build system: [Gradle / Make / CMake / Bazel / npm / etc.]
Key dependencies: [list main libraries or services]
Team conventions: [e.g., comments in Chinese, commit messages in English, etc.]
Please:
1. Set up the initial project structure
2. Create a CLAUDE.md file that captures all of the above
3. Include build/run/test commands in CLAUDE.md
Navigate to your project folder
cd /path/to/your-project
Initialize git if not already a repo
git init
Skip this if your project already has a .git directory.
Launch Claude Code
claude
Ask Claude to analyze and generate CLAUDE.md
Analyze this project and create a CLAUDE.md file. Include:
- Project overview and tech stack
- Build, run, and test commands
- Project structure
- Code conventions
- Key dependencies
- Deployment info
Review and refine CLAUDE.md
Check the generated file and ask Claude to adjust anything that's missing or incorrect.
Create a GitLab repo and push
git add CLAUDE.md
git commit -m "Add CLAUDE.md project documentation"
git remote add origin https://gitlab.company.com/your-group/project-name.git
git push -u origin main
Replace gitlab.company.com with your actual self-hosted GitLab hostname.
Clone the repository from GitLab
git clone https://gitlab.company.com/your-group/project-name.git
Replace gitlab.company.com with your actual self-hosted GitLab hostname.
Enter the project directory
cd project-name
Launch Claude Code
claude
Ask Claude to analyze and create CLAUDE.md
Analyze this project and create a CLAUDE.md file. Include:
- Project overview and tech stack
- Build, run, and test commands
- Project structure
- Code conventions
- Key dependencies
- Deployment info
Commit and push CLAUDE.md
git add CLAUDE.md
git commit -m "Add CLAUDE.md project documentation"
git push
SEI CLAUDE.md Template
Use this as a starting point when creating your CLAUDE.md file:
# Project Name
## Overview
Brief description of what this project does and which SEI Robotics department owns it.
## Tech Stack
- **Language**:
- **Framework**:
- **Build System**:
- **Target Platform**:
## Getting Started
### Prerequisites
### Build
### Run
### Test
## Project Structure
Key directories and what they contain.
## Code Conventions
- Comment language: [Chinese / English / both]
- Naming: [camelCase / snake_case / etc.]
- Commit messages: [language, format]
- Branch naming: [feature/xxx, bugfix/xxx]
## Key Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
## Deployment
How and where this project is deployed.
## Team
- Department:
- GitLab group:
- Maintainers:
## Claude Code Notes
Special instructions for Claude Code when working on this project.
- Preferred models/tools
- Files to never modify
- Testing requirements before commits
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.