Using gahorouter in Claude Code
This guide walks you through connecting gahorouter to Claude Code, so the AI can write code, edit files, run commands, and answer questions right on your computer.
👉 All you need to know is how to open a terminal and copy-paste commands. No programming required.
Table of Contents
- Preparation
- Step 1: Install Claude Code
- Step 2: Point It to gahorouter
- Step 3: Let's Go!
- Common Usage
- More Questions
Preparation
Finish all three steps before configuring Claude Code.
Step One: Get Your API Key and Bind the Right Group
- Open your browser and go to https://console.gahorouter.com
- After logging in, click "API Keys" in the left-hand menu
- Click the "Create Key" button and give the key a name (e.g., my-laptop)
- Click the "Group" button and select the model group you want to use (e.g., Official Premium Channel 4x)
- Copy the long string
cr-xxxxxxxxxxxx...shown on the screen —— it is displayed only once; once you close it, it's gone for good. Paste it into your notes immediately and keep it safe - Go back to the key list, click the "Group" column for the row of the key you just created, and select a group whose name contains "Claude," "Flagship," or "Premium"
What happens if you pick the wrong group: Claude Code will return 401/503. Just go back to the console and switch it.
If the group list is empty → you haven't subscribed to any channel yet. Contact your administrator to enable one, or buy a plan in the console.
Step Two: Install Node.js
Claude Code runs on your computer and depends on the Node.js environment.
- Open https://nodejs.org/
- Click the big green "LTS" button to download
- After installation, open your computer's terminal and type:
node -vIf you see v20.x.x or a similar number, you're good.
How do I open the terminal?
- Mac: Press ⌘+Space, search for "Terminal," and hit Enter
- Windows: Press the Win key, search for "PowerShell," and hit Enter
- Linux: You can figure this out yourself
Step Three: Remember Your Operating System
Some commands later differ between Mac/Linux and Windows. I'll distinguish them with labels. Just know which one you're using.
Step 1: Install Claude Code
Open the terminal, copy-paste the line below, and hit Enter:
npm install -g @anthropic-ai/claude-codeWait for it to finish (usually 1~2 minutes). If there are no red errors, the installation succeeded.
If you see permission denied (Mac/Linux), use this instead:
sudo npm install -g @anthropic-ai/claude-codeIt will prompt you for your computer's password.
Verify the installation:
claude --versionIf you see a version number (e.g., 0.x.x), it's installed. If you get "command not found," close the terminal, reopen it, and try again.
Step 2: Point It to gahorouter
By default, Claude Code connects to Anthropic's official servers. We need to change it to connect to gahorouter. The method is to set two "environment variables."
Replace cr-your-key in the commands below with your real API Key, then run:
Mac / Linux:
export ANTHROPIC_BASE_URL="https://console.gahorouter.com"
export ANTHROPIC_AUTH_TOKEN="cr-your-key"Windows (PowerShell):
$env:ANTHROPIC_BASE_URL="https://console.gahorouter.com"
$env:ANTHROPIC_AUTH_TOKEN="cr-your-key"⚠️ Both of the settings above only apply to the current terminal window. They stop working once you close it. To make them permanent, see "Make the Configuration Permanent" below.
Make the Configuration Permanent (Recommended, Do It Once)
Mac / Linux: Open your shell configuration file.
# Mac defaults to zsh
open -e ~/.zshrc
# Linux generally uses bash
nano ~/.bashrcAdd two lines at the end of the file:
export ANTHROPIC_BASE_URL="https://console.gahorouter.com"
export ANTHROPIC_AUTH_TOKEN="cr-your-key"Save and close, then run source ~/.zshrc (or ~/.bashrc) to apply.
Windows:
- Press Win+R, type
sysdm.cpl, and hit Enter - Switch to the "Advanced" tab → click "Environment Variables"
- Under "User variables," click "New" and add two entries:
- Variable name
ANTHROPIC_BASE_URL, valuehttps://console.gahorouter.com - Variable name
ANTHROPIC_AUTH_TOKEN, valuecr-your-key
- Variable name
- Click OK → fully close all PowerShell windows and reopen them (minimizing doesn't count; you must quit and reopen), otherwise the new variables won't be read
Step 3: Let's Go!
In the terminal, navigate into a folder where you want the AI to work for you, then launch:
cd ~/projects/my-code # go into your project directory
claude # launch!The first launch will ask you some initialization questions:
- Choose a theme (pick whatever)
- Whether to log in to your Anthropic account → choose "Skip" or a similar "don't log in" option (we're using a gahorouter Key, no OAuth login needed)
- Confirm the working directory (press Enter to accept)
- Whether to allow command execution (we recommend choosing "Accept in this project once")
Once it starts successfully, you'll see a prompt. Send a quick test message:
> HelloIf you see the AI's reply, the configuration succeeded. Now you can start using it for real:
> What does this project do?
> Add a hello function to main.py for me
> Run the testsCommon Usage
| What you want to do | Just say this |
|---|---|
| Understand the project | "What's the structure of this project? What tech stack does it use?" |
| Edit code | "Change the login function to an async version" |
| Write new features | "Add a user registration endpoint and store it in the database" |
| Fix bugs | "Run the tests and fix the ones that fail" |
| Generate docs | "Write a README for api.py" |
| Organize notes | "Categorize and merge the markdown files in notes/ by topic" |
| Have it look things up | "Look up what new features Python 3.13 has" |
Tips:
- To exit Claude Code, type
/exitor press Ctrl+C twice - To switch models, type
/model, which pops up a selection menu (Sonnet by default; choose Opus if you want something stronger) - To have it read a specific file, just type
@filenamein your message, e.g.,@README.md summarize this document - To clear the context and start over, type
/clear
More Questions
How do I choose a model?
- Everyday conversation and coding:
claude-sonnet-4-6(the default, always a safe bet) - Strongest reasoning:
claude-opus-4-6(a bit slower, but solves hard problems well) - Fast and cheap:
claude-haiku-4-5-20251001 - Temporarily switch models inside Claude Code:
/model
Can one Key use both Claude and GPT at the same time?
No. One Key can only bind to one group. To use models from both families at once, create two Keys in the console: one bound to a Claude group for Claude Code, and one bound to a GPT group for Codex.
How do I switch Keys or groups?
- Switch Key: run
export ANTHROPIC_AUTH_TOKEN=new-keyagain, then restart Claude Code - Switch group: no client changes needed; just re-select the group for the Key in the console
Can I use it reliably on a network in mainland China?
Yes. gahorouter comes with built-in overseas network optimization. Direct connections from within mainland China work fine, and you don't need to provide your own proxy.
Can I use it with Cursor / Windsurf / other IDEs?
The approach for other IDEs is similar: as long as the IDE lets you change the API base URL, fill in https://console.gahorouter.com (Anthropic protocol).
Related Links
- gahorouter Console: https://console.gahorouter.com
- Product Website: https://gahorouter.com
- If you want to use Codex (the GPT series), check out the other document "Using gahorouter in Codex"
- If you're a developer who wants to call the API directly in code, check out the "gahorouter Model API Reference"
Have fun!