Free Claude Code Setup
This lesson provides free alternatives to use Claude Code without a subscription. You'll choose between Open Router, oGoogle Gemini or DeepSeek as your backend, learning the same Claude Code CLI interface and features covered in Lesson 2.
⚠️ Important (January 2026): Google significantly reduced Gemini API free tier limits in December 2025. Daily request limits dropped 50-80% for most models. OpenRouter free models have daily request limits that vary by model. OpenRouter offers 30+ free models AI Free API but with daily request limits. Models rotate and quality varies. DeepSeek is not truly "free" but offers very low pricing (~$0.028-$0.42 per million tokens). Both deepseek-chat and deepseek-reasoner follow the same pricing: $0.028 per million input tokens (cache hit), $0.28 per million input tokens (cache miss), and $0.42 per million output tokens. Groq has a Free Tier for its API via GroqCloud. Plan your usage accordingly and have backup options ready.
All features work identically: Subagents, skills, MCP servers, hooks, and all other capabilities covered in Lessons 05-15 function the same way with free backends. The only difference is the backend AI model and API provider.
By using Gemini's free tier or DeepSeek's competitive API, you get ongoing free or low-cost consumption—no subscription required. This setup isn't just for learning; many developers use it as their daily driver. The free tiers are generous enough for real development work.
Choose Your Free Backend
Before setup, decide which backend suits you. All three options provide identical Claude Code functionality:
| Factor | OpenRouter | Gemini | DeepSeek |
|---|---|---|---|
| Available Models | 5+ free options | Gemini 2.5 Flash | DeepSeek Chat/Reasoner |
| Free Tier | Daily request limits per model | Daily request limits | Token-based (~$0.028-$0.42/M tokens) |
| Speed | Very Fast | Very Fast | Fast |
| Setup Complexity | Manual, most transparent | Easiest (few steps) | Slightly more involved |
| Reasoning Models | Available (Qwen, Llama) | Native support | Native support |
OpenRouter Setup
This section guides you through configuring Claude Code with OpenRouter's multi-model platform.
OpenRouter aggregates multiple AI models (including Gemini, Qwen, Llama) under one API. This gives you maximum flexibility to experiment with different models without re-configuring.
Step 1: Get Your OpenRouter API Key
- Go to: OpenRouter API Keys
- Click "Create Key"
- Name it (e.g., "Claude Code Router")
- Copy the key (starts with:
sk-or-v1-...)
Step 2: Install and Configure
Select your operating system:
- Windows
- macOS
- Linux
Verify Node.js
node --version # Should show v18.x.x or higher
If missing, install from nodejs.org
Install Tools
Open PowerShell and run:
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
Create Config Directories
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude-code-router"
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude"
Create the Config File
- Open Notepad (search "Notepad" in Windows Start menu)
- Copy and paste this exactly:
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1",
"api_key": "$OPENROUTER_API_KEY",
"models": [
"qwen/qwen-coder-32b-vision",
"google/gemini-2.0-flash-exp:free",
"meta-llama/llama-3.3-70b-instruct:free",
"qwen/qwen3-14b:free",
"xiaomi/mimo-v2-flash:free"
],
"transformer": {
"use": ["openrouter"]
}
}
],
"Router": {
"default": "openrouter,qwen/qwen-coder-32b-vision",
"background": "openrouter,qwen/qwen-coder-32b-vision",
"think": "openrouter,meta-llama/llama-3.3-70b-instruct:free",
"longContext": "openrouter,qwen/qwen-coder-32b-vision",
"longContextThreshold": 60000
}
}
Leave "api_key": "$OPENROUTER_API_KEY" exactly as written. The router reads your key from the environment variable you'll set in the next step.
- Click File → Save As
- In the "File name" field, type exactly:
%USERPROFILE%\.claude-code-router\config.json - Click Save
Set Your API Key
Run PowerShell as Administrator:
- Search "PowerShell" in Windows Start menu
- Right-click on "Windows PowerShell"
- Click "Run as administrator"
- Click "Yes" if prompted
Run this command (replace YOUR_KEY_HERE with your key from Step 1):
[System.Environment]::SetEnvironmentVariable('OPENROUTER_API_KEY', 'YOUR_KEY_HERE', 'User')
- Close PowerShell completely (not just the tab—close the whole window)
- Open a new regular PowerShell (not as admin)
- Verify it worked:
echo $env:OPENROUTER_API_KEY
You should see your API key displayed ✅
Verify Setup
claude --version # Should show: Claude Code v2.x.x
ccr version # Should show version number
echo $env:OPENROUTER_API_KEY # Should show your key
✅ Done! Proceed to Step 3: Daily Workflow below.
Verify Node.js
node --version # Should show v18.x.x or higher
If missing, install from nodejs.org
Copy-Paste Setup
Copy and paste this entire block into Terminal:
# Install tools
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
# Create config directories
mkdir -p ~/.claude-code-router ~/.claude
# Create router config
cat > ~/.claude-code-router/config.json << 'EOF'
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1",
"api_key": "$OPENROUTER_API_KEY",
"models": [
"qwen/qwen-coder-32b-vision",
"google/gemini-2.0-flash-exp:free",
"meta-llama/llama-3.3-70b-instruct:free",
"qwen/qwen3-14b:free",
"xiaomi/mimo-v2-flash:free"
],
"transformer": {
"use": ["openrouter"]
}
}
],
"Router": {
"default": "openrouter,qwen/qwen-coder-32b-vision",
"background": "openrouter,qwen/qwen-coder-32b-vision",
"think": "openrouter,meta-llama/llama-3.3-70b-instruct:free",
"longContext": "openrouter,qwen/qwen-coder-32b-vision",
"longContextThreshold": 60000
}
}
EOF
# Verify file was created
cat ~/.claude-code-router/config.json
Set Your API Key
Replace YOUR_KEY_HERE with your actual API key:
# For zsh (default on macOS):
echo 'export OPENROUTER_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc
source ~/.zshrc
Verify Setup
claude --version # Should show: Claude Code v2.x.x
ccr version # Should show version number
echo $OPENROUTER_API_KEY # Should show your key
✅ Done! Proceed to Step 3: Daily Workflow below.
Verify Node.js
node --version # Should show v18.x.x or higher
If missing, install via your package manager or nodejs.org
Copy-Paste Setup
Copy and paste this entire block into your terminal:
# Install tools
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
# Create config directories
mkdir -p ~/.claude-code-router ~/.claude
# Create router config
cat > ~/.claude-code-router/config.json << 'EOF'
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1",
"api_key": "$OPENROUTER_API_KEY",
"models": [
"qwen/qwen-coder-32b-vision",
"google/gemini-2.0-flash-exp:free",
"meta-llama/llama-3.3-70b-instruct:free",
"qwen/qwen3-14b:free",
"xiaomi/mimo-v2-flash:free"
],
"transformer": {
"use": ["openrouter"]
}
}
],
"Router": {
"default": "openrouter,qwen/qwen-coder-32b-vision",
"background": "openrouter,qwen/qwen-coder-32b-vision",
"think": "openrouter,meta-llama/llama-3.3-70b-instruct:free",
"longContext": "openrouter,qwen/qwen-coder-32b-vision",
"longContextThreshold": 60000
}
}
EOF
# Verify file was created
cat ~/.claude-code-router/config.json
Set Your API Key
Replace YOUR_KEY_HERE with your actual API key:
# For bash:
echo 'export OPENROUTER_API_KEY="YOUR_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
Run echo $SHELL to see which shell you use. If it shows /bin/zsh, use ~/.zshrc instead of ~/.bashrc.
Verify Setup
claude --version # Should show: Claude Code v2.x.x
ccr version # Should show version number
echo $OPENROUTER_API_KEY # Should show your key
✅ Done! Proceed to Step 3: Daily Workflow below.
Step 3: Daily Workflow
Every time you want to code:
- Windows
- macOS
- Linux
PowerShell 1 - Start router FIRST:
ccr start
Leave this window running. You'll see a warning message—that's normal!
PowerShell 2 - Open a NEW PowerShell window and run:
cd C:\your\project\folder
ccr code
Wait 10-20 seconds after running ccr code on first startup. The router needs time to initialize.
When done: Press Ctrl+C in both windows.
Terminal 1 - Start router FIRST:
ccr start
# Wait for: ✅ Service started successfully
Terminal 2 - THEN use Claude:
cd ~/your-project
ccr code
When done: Press Ctrl+C in both terminals.
Terminal 1 - Start router FIRST:
ccr start
# Wait for: ✅ Service started successfully
Terminal 2 - THEN use Claude:
cd ~/your-project
ccr code
When done: Press Ctrl+C in both terminals.
Gemini Setup
This section guides you through configuring Claude Code with Google's Gemini API.
Step 1: Get Your Free Google API Key
- Go to: Google AI Studio
- Click "Get API Key"
- Sign in with Google
- Click "Create API Key"
- Copy the key (looks like:
AIzaSyAaBbCcDd...)
Step 2: Install and Configure
Select your operating system:
- Windows
- macOS
- Linux
Step 0: Install Node.js (Skip if Already Installed)
Check if you have Node.js:
Open PowerShell (search "PowerShell" in Windows Start menu) and type:
node --version
- If you see
v18.x.xor higher → Skip to Step 1 ✅ - If you see an error or version lower than v18 → Follow these steps:
- Go to: nodejs.org
- Click the big green button that says "Download Node.js (LTS)"
- Run the downloaded file (it's called something like
node-v20.x.x-x64.msi) - Click Next → Next → Next → Install
- Wait for it to finish
- Close ALL PowerShell windows completely
- Open a new PowerShell window
- Type
node --versionagain to confirm it works
You should now see a version number like v20.11.0 ✅
Step 1: Install Tools
Open PowerShell and run:
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
Step 2: Create Config Directories
Enable running scriptson your system first:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Now create directories:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude-code-router"
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude"
Step 3: Create the Config File
- Open Notepad (search "Notepad" in Windows Start menu)
- Copy and paste this text exactly as-is:
{
"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-2.5-flash-lite",
"gemini-2.0-flash"
],
"transformer": {
"use": ["gemini"]
}
}
],
"Router": {
"default": "gemini,gemini-2.5-flash-lite",
"background": "gemini,gemini-2.5-flash-lite",
"think": "gemini,gemini-2.5-flash-lite",
"longContext": "gemini,gemini-2.5-flash-lite",
"longContextThreshold": 60000
}
}
Leave "api_key": "$GOOGLE_API_KEY" exactly as written. Do NOT replace it with your actual key here—the router will automatically read your key from the environment variable you set in Step 4.
- Click File → Save As
- In the "File name" field, type exactly:
%USERPROFILE%\.claude-code-router\config.json - Click Save
Step 4: Set Your API Key
Run PowerShell as Administrator:
- Search "PowerShell" in Windows Start menu
- Right-click on "Windows PowerShell"
- Click "Run as administrator"
- Click "Yes" if prompted
Run this command (replace YOUR_KEY_HERE with your actual API key from Step 1):
[System.Environment]::SetEnvironmentVariable('GOOGLE_API_KEY', 'YOUR_KEY_HERE', 'User')
- Close PowerShell completely (not just the tab—close the whole window)
- Open a new regular PowerShell (not as admin this time)
- Verify it worked:
echo $env:GOOGLE_API_KEY
You should see your API key displayed ✅
Verify Setup
claude --version # Should show: Claude Code v2.x.x
ccr version # Should show version number
echo $env:GOOGLE_API_KEY # Should show your key
✅ Done! Proceed to Step 3: Daily Workflow below.
Verify Node.js
node --version # Should show v18.x.x or higher
If missing, install from nodejs.org
Copy-Paste Setup
Copy and paste this entire block into Terminal:
# Install tools
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
# Create config directories
mkdir -p ~/.claude-code-router ~/.claude
# Create router config
cat > ~/.claude-code-router/config.json << 'EOF'
{
"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-2.5-flash-lite",
"gemini-2.0-flash"
],
"transformer": {
"use": ["gemini"]
}
}
],
"Router": {
"default": "gemini,gemini-2.5-flash-lite",
"background": "gemini,gemini-2.5-flash-lite",
"think": "gemini,gemini-2.5-flash-lite",
"longContext": "gemini,gemini-2.5-flash-lite",
"longContextThreshold": 60000
}
}
EOF
# Verify file was created
cat ~/.claude-code-router/config.json
Set Your API Key
Replace YOUR_KEY_HERE with your actual API key:
# For zsh (default on macOS):
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc
source ~/.zshrc
Verify Setup
claude --version # Should show: Claude Code v2.x.x
ccr version # Should show version number
echo $GOOGLE_API_KEY # Should show your key
✅ Done! Proceed to Step 3: Daily Workflow below.
Verify Node.js
node --version # Should show v18.x.x or higher
If missing, install from nodejs.org or use your package manager.
Copy-Paste Setup
Copy and paste this entire block into your terminal:
# Install tools
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
# Create config directories
mkdir -p ~/.claude-code-router ~/.claude
# Create router config
cat > ~/.claude-code-router/config.json << 'EOF'
{
"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-2.5-flash-lite",
"gemini-2.0-flash"
],
"transformer": {
"use": ["gemini"]
}
}
],
"Router": {
"default": "gemini,gemini-2.5-flash-lite",
"background": "gemini,gemini-2.5-flash-lite",
"think": "gemini,gemini-2.5-flash-lite",
"longContext": "gemini,gemini-2.5-flash-lite",
"longContextThreshold": 60000
}
}
EOF
# Verify file was created
cat ~/.claude-code-router/config.json
Set Your API Key
Replace YOUR_KEY_HERE with your actual API key:
# For bash:
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
Run echo $SHELL to see your shell. If it shows /bin/zsh, use ~/.zshrc instead of ~/.bashrc.
Verify Setup
claude --version # Should show: Claude Code v2.x.x
ccr version # Should show version number
echo $GOOGLE_API_KEY # Should show your key
✅ Done! Proceed to Step 3: Daily Workflow below.
Step 3: Daily Workflow
Every time you want to code:
- Windows
- macOS
- Linux
PowerShell 1 - Start router FIRST:
ccr start
Leave this window running. You'll see a warning message—that's normal!
PowerShell 2 - Open a NEW PowerShell window and run:
cd C:\your\project\folder
ccr code
Wait 10-20 seconds after running ccr code on first startup. The router needs time to initialize. If it seems stuck, just wait—it's working!
When done: Press Ctrl+C in both windows.
Terminal 1 - Start router FIRST:
ccr start
# Wait for: ✅ Service started successfully
Terminal 2 - THEN use Claude:
cd ~/your-project
ccr code
When done: Press Ctrl+C in both terminals.
Terminal 1 - Start router FIRST:
ccr start
# Wait for: ✅ Service started successfully
Terminal 2 - THEN use Claude:
cd ~/your-project
ccr code
When done: Press Ctrl+C in both terminals.
DeepSeek Setup
This section guides you through configuring Claude Code with DeepSeek's API.
If you already completed the Gemini Setup above, you already have Node.js and the Claude Code Router installed. You only need to create the DeepSeek configuration and set your API key.
Step 1: Get Your DeepSeek API Key
- Go to: DeepSeek API Platform
- Sign up or log in with your account
- Navigate to API Keys section
- Click "Create API Key"
- Copy the key (looks like:
sk-...)
Step 2: Configure DeepSeek
- Windows
- macOS
- Linux
Create the config file: Open Notepad and paste:
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "deepseek",
"api_base_url": "https://api.deepseek.com/v1",
"api_key": "$DEEPSEEK_API_KEY",
"models": [
"deepseek-chat",
"deepseek-reasoner"
],
"transformer": {
"use": ["openai"]
}
}
],
"Router": {
"default": "deepseek,deepseek-chat",
"background": "deepseek,deepseek-chat",
"think": "deepseek,deepseek-reasoner",
"longContext": "deepseek,deepseek-chat",
"longContextThreshold": 60000
}
}
Leave "api_key": "$DEEPSEEK_API_KEY" exactly as written.
Save as: %USERPROFILE%\.claude-code-router\config.json
Set your API key (Run PowerShell as Administrator):
[System.Environment]::SetEnvironmentVariable('DEEPSEEK_API_KEY', 'YOUR_KEY_HERE', 'User')
Close and reopen PowerShell, then verify:
echo $env:DEEPSEEK_API_KEY
Create config and set API key:
cat > ~/.claude-code-router/config.json << 'EOF'
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "deepseek",
"api_base_url": "https://api.deepseek.com/v1",
"api_key": "$DEEPSEEK_API_KEY",
"models": [
"deepseek-chat",
"deepseek-reasoner"
],
"transformer": {
"use": ["openai"]
}
}
],
"Router": {
"default": "deepseek,deepseek-chat",
"background": "deepseek,deepseek-chat",
"think": "deepseek,deepseek-reasoner",
"longContext": "deepseek,deepseek-chat",
"longContextThreshold": 60000
}
}
EOF
# Set your API key
echo 'export DEEPSEEK_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc
source ~/.zshrc
Create config and set API key:
cat > ~/.claude-code-router/config.json << 'EOF'
{
"LOG": true,
"LOG_LEVEL": "info",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": 600000,
"Providers": [
{
"name": "deepseek",
"api_base_url": "https://api.deepseek.com/v1",
"api_key": "$DEEPSEEK_API_KEY",
"models": [
"deepseek-chat",
"deepseek-reasoner"
],
"transformer": {
"use": ["openai"]
}
}
],
"Router": {
"default": "deepseek,deepseek-chat",
"background": "deepseek,deepseek-chat",
"think": "deepseek,deepseek-reasoner",
"longContext": "deepseek,deepseek-chat",
"longContextThreshold": 60000
}
}
EOF
# Set your API key
echo 'export DEEPSEEK_API_KEY="YOUR_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
Verification
Both Gemini and DeepSeek use the same daily workflow and verification process.
Start a Claude session and say hi:
hi
Expected: Claude responds with a greeting confirming it's working! ✅ Success!
Troubleshooting
- Windows
- macOS
- Linux
"command not found" or "not recognized"
Close and reopen PowerShell completely. If still failing, the npm global bin directory isn't in your PATH.
"API key not found" or empty variable
- Make sure you ran the
SetEnvironmentVariablecommand as Administrator - Close ALL PowerShell windows and open a fresh one
- Check with
echo $env:GOOGLE_API_KEY
Stuck at "starting service"
Wait 20-30 seconds on first run. This is normal.
Router starts but Claude hangs
Make sure ccr start is running in PowerShell 1 before running ccr code in PowerShell 2.
"command not found: claude" or "command not found: ccr"
The npm global bin directory isn't in your PATH:
npm config get prefix
echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.zshrc
source ~/.zshrc
"API key not found" or empty GOOGLE_API_KEY
echo $GOOGLE_API_KEY
# If empty, re-add:
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc
source ~/.zshrc
Router starts but Claude hangs
Wait 2-3 seconds after ccr start shows "Service started" before running ccr code.
"command not found: claude" or "command not found: ccr"
The npm global bin directory isn't in your PATH:
npm config get prefix
echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.bashrc
source ~/.bashrc
"API key not found" or empty GOOGLE_API_KEY
echo $GOOGLE_API_KEY
# If empty, re-add:
echo 'export GOOGLE_API_KEY="YOUR_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
Router starts but Claude hangs
Wait 2-3 seconds after ccr start shows "Service started" before running ccr code.
Try With AI
Once your free setup is working, try these prompts to verify everything works:
Verify Basic Functionality:
"Hello! Confirm you're working by telling me: (1) what model you're using, (2) can you see files in this directory? List them if so."
Test File Operations:
"Create a simple test file called
hello.txtwith the text 'Free Claude Code setup works!' Then read it back to confirm."
Understand the Architecture:
"Explain the architecture of my current setup: I'm using Claude Code CLI with a router pointing to a free backend. What's happening when I send you a message? Walk me through the request flow."
That's it. Proceed to Lesson 05 to learn about teaching Claude your way of working.