Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ prerequisites:

---

πŸŽ₯ Video TutorialFull step-by-step video (with voice) : πŸ‘‰ https://www.youtube.com/watch?v=HQ6dqd7QY38

---

## Reality Check: It's Just Copy-Paste

**Setup Complexity**: Copy 3 text blocks, type 3 commands. That's it.
Expand All @@ -95,7 +99,7 @@ If missing, install from [nodejs.org](https://nodejs.org/)

---

## Step 1: Get Your Free Google API Key
## πŸ”₯ STEP 1 β€” Get Your Free Google API Key

1. Go to: [Google AI Studio](https://aistudio.google.com/api-keys)
2. Click **"Get API Key"**
Expand All @@ -105,19 +109,77 @@ If missing, install from [nodejs.org](https://nodejs.org/)

---

## Step 2: Copy-Paste Setup

**Just copy commands from this block and paste into terminal:**

```bash
# Install tools
## πŸ”₯ STEP 2 β€” INSTALL CLAUDE TOOLS
### Windows (PowerShell or CMD):
```powershell
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
```
### macOS / Linux:
```bash
sudo npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
```

# Create config directories
## πŸ”₯ STEP 3 β€” CREATE REQUIRED FOLDERS
### Windows PowerShell:
```powershell
New-Item -ItemType Directory -Force -Path $HOME\.claude-code-router
New-Item -ItemType Directory -Force -Path $HOME\.claude
```
### Windows CMD:
```cmd
mkdir %USERPROFILE%\.claude-code-router
mkdir %USERPROFILE%\.claude
```
### macOS / Linux:
```bash
mkdir -p ~/.claude-code-router ~/.claude
```
*`-Force` / `-p` = no error if folder already exists*

# Create router config
# Create new config with native Gemini endpoint
## πŸ”₯ STEP 4 β€” CREATE `config.json` (Correct For Each OS)
### 🟦 Windows (PowerShell + CMD) β€” Use Notepad
```powershell
notepad $HOME\.claude-code-router\config.json
```
Or in CMD:
```cmd
notepad %USERPROFILE%\.claude-code-router\config.json
```
Paste this exact JSON:
```json
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "gemini",
"api_base_url": "https://generativelanguage.googleapis.com/v1beta/models/",
"api_key": "$GOOGLE_API_KEY",
"models": [
"gemini-1.5-flash",
"gemini-1.5-flash-exp-0827"
],
"transformer": {
"use": ["gemini"]
}
}
],
"Router": {
"default": "gemini,gemini-1.5-flash",
"background": "gemini,gemini-1.5-flash",
"think": "gemini,gemini-1.5-flash",
"longContext": "gemini,gemini-1.5-flash",
"longContextThreshold": 60000
}
}
```
Save & close.

### 🟩 macOS / Linux
```bash
cat > ~/.claude-code-router/config.json << 'EOF'
{
"LOG": true,
Expand All @@ -131,117 +193,132 @@ cat > ~/.claude-code-router/config.json << 'EOF'
"api_base_url": "https://generativelanguage.googleapis.com/v1beta/models/",
"api_key": "$GOOGLE_API_KEY",
"models": [
"gemini-2.5-flash",
"gemini-2.0-flash"
"gemini-1.5-flash",
"gemini-1.5-flash-exp-0827"
],
"transformer": {
"use": ["gemini"]
}
}
],
"Router": {
"default": "gemini,gemini-2.5-flash",
"background": "gemini,gemini-2.5-flash",
"think": "gemini,gemini-2.5-flash",
"longContext": "gemini,gemini-2.5-flash",
"default": "gemini,gemini-1.5-flash",
"background": "gemini,gemini-1.5-flash",
"think": "gemini,gemini-1.5-flash",
"longContext": "gemini,gemini-1.5-flash",
"longContextThreshold": 60000
}
}
EOF

# Verify file was created
cat ~/.claude-code-router/config.json

# Set your API key (REPLACE "YOUR_KEY_HERE" with actual key!)
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc
source ~/.zshrc
```

**Windows users**: Replace last 2 lines with:
## πŸ”₯ STEP 5 β€” SET GOOGLE API KEY
### Windows PowerShell (Permanent):
```powershell
# Windows PowerShell (Run as Administrator)
[System.Environment]::SetEnvironmentVariable('GOOGLE_API_KEY', 'YOUR_KEY_HERE', 'User')

# Then CLOSE and REOPEN PowerShell completely
# Verify it worked:
```
β†’ Restart PowerShell, then check:
```powershell
echo $env:GOOGLE_API_KEY
```

**Bash users** (older macOS/Linux):
### macOS / Linux
#### Bash:
```bash
# Check your shell first:
echo $SHELL

# If shows /bin/zsh β†’ use ~/.zshrc (already done above)
# If shows /bin/bash β†’ Change last 2 lines to:
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
```

---

### βœ… Verify Setup Worked

**After pasting setup commands, verify immediately:**

#### Zsh (default on macOS):
```bash
claude --version # Should show: Claude Code v2.x.x
ccr version # it will show version number (without hyphen)
echo $GOOGLE_API_KEY # Should show your key (not empty!)

# If any fail, see Troubleshooting section
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc
source ~/.zshrc
```

βœ… **Done!** That's the entire setup.

---

## Step 3: Daily Workflow

**Every time you want to code:**
## πŸ”₯ STEP 6 β€” VERIFY INSTALLATION
```bash
claude --version
ccr version
```
For macOS/Linux:
```bash
echo $GOOGLE_API_KEY
```
For Windows:
```powershell
echo $env:GOOGLE_API_KEY
```
All should show output β†’ Ready!

### Terminal 1 - Start router FIRST
## πŸ”₯ STEP 7 β€” DAILY USAGE
### Terminal 1 β€” Start the router:
```bash
ccr start
# Wait for: βœ… Service started successfully
```

### Terminal 2 - THEN use Claude (after router is ready)

Wait for:
```
βœ” Service started successfully
or
⚠️ API key is not set. HOST is forced to 127.0.0.1.
Loaded JSON config from: C:\Users\User\.claude-code-router\config.json
```
cd ~/your-project

# Use
### Terminal 2 β€” Start Coding (Cross-Platform)
#### macOS / Linux Option 1:
```bash
ccr code

# OR
```
#### macOS / Linux Option 2 (Recommended):
```bash
# Activate Claude environment
eval "$(ccr activate)"

# Start Claude CLI
claude
```

That's it. One command in Terminal 1, three lines in Terminal 2. Just copy-paste!

---

## Verification

**Start a Claude session:**

```bash
ccr code
# OR
#### Windows CMD:
```cmd
set ANTHROPIC_AUTH_TOKEN=test
set ANTHROPIC_API_KEY=
set ANTHROPIC_BASE_URL=http://127.0.0.1:3456
set NO_PROXY=127.0.0.1
set DISABLE_TELEMETRY=true
set DISABLE_COST_WARNINGS=true
set API_TIMEOUT_MS=600000
```
```cmd
claude
```

**Say hi:**

#### Windows PowerShell:
```powershell
$env:ANTHROPIC_AUTH_TOKEN = "test"
$env:ANTHROPIC_API_KEY = ""
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:3456"
$env:NO_PROXY = "127.0.0.1"
$env:DISABLE_TELEMETRY = "true"
$env:DISABLE_COST_WARNINGS = "true"
$env:API_TIMEOUT_MS = "600000"
```
hi
```powershell
claude
```
**Test it:**
Type `hi` β†’ Claude should reply β†’ πŸŽ‰ Success!

---

## ⚠️ Troubleshooting
| Problem | Solution |
| :-------------------- | :---------------------------------------------------------------------- |
| `mkdir` error | Use `-Force` (Windows) or `-p` (macOS/Linux) with `New-Item` / `mkdir` |
| "API key not found" | Restart terminal after setting environment variable |
| `ccr: command not found` | Close & reopen terminal, or restart computer |
| Port 3456 already in use | Kill process: `taskkill //F //PID <pid>` (Win) or `kill -9 <pid>` (Unix) |

**Expected**: Claude responds with a greeting confirming it's working! βœ… Success!

That's it. If Claude responds, your free setup is working perfectly.


That's it. Proceed to **Lesson 3** to learn persistent project context.