How to Integrate OpenRouter with Claude Code and use Free Models
How to Connect OpenRouter to Claude Code
Step 1. Windows Installation (PowerShell)
Command used to install Claude Code CLI globally:
irm https://claude.ai/install.ps1 | iex
Verify the installation:
claude --version
Step 2. Project Settings File
Created inside your project directory under `.claude/settings.local.json`:
{
"env": {
"ANTHROPIC_BASE_URL": "https://openrouter.ai/api/v1",
"ANTHROPIC_AUTH_TOKEN": "YOUR_OPENROUTER_API_KEY",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_MODEL": "YOUR_CHOSEN_OPENROUTER_MODEL_NAME"
}
}
Step 3. Global Configuration (`~/.claude.json`)
Located at `C:\Users\<YourUsername>\.claude.json`:
Set/update the approved bypass or model configuration:
"hasCompletedOnboarding": true
Step 4. Launching & Testing
In your VS Code terminal:
claude