Skip to content

Trae: gahorouter Quick Start Guide

⏱️ Done in 5 minutes: from creating an API Key to using Claude Code for AI-assisted development in Trae

Two Installation Paths — Choose Whichever Suits You

ItemPath A: CLI + PluginPath B: Plugin Only (No CLI)
Who it's forDevelopers who like the command lineThose who don't want to install a CLI and only use the GUI
Installation stepsOne extra step (install the CLI)One fewer step
Feature differencesBoth CLI and sidebar availableSidebar only
Configuration methodCC Switch or environment variablesCC Switch or environment variables (same)

Prerequisites

Before you start, make sure you have:

  • Register a gahorouter account: Visit https://console.gahorouter.com/keys to register and subscribe (a free trial is available)
  • Install Trae: Download the latest version from https://www.trae.ai/ (users in China can visit https://www.trae.com.cn/), then install and open it to test
  • Network: A stable network connection is required (Path A requires the ability to access international networks when downloading the Claude Code CLI; Path B has no such requirement)

Step 1: Create an API Key (Same for Both Paths)

1.1 Log in to the gahorouter Platform

Visit https://console.gahorouter.com/keys and enter your account and password.

1.2 Create a New API Key

  1. Go to the API Keys page
  2. Click the "Create Key" button
  3. Fill in the configuration details:
ConfigurationDescription
NameRequired. The API Key name (for easy identification)
GroupRequired. Choose an appropriate group based on your plan's subscription permissions
Custom KeyOptional. Use a custom string as the API key
IP RestrictionOptional. Set an allow/deny IP whitelist or blacklist
  1. Click "Create" to generate the API Key

1.3 Save the API Key

Go to the API Keys page, copy the Key (sk-xxxxxx), and save it to a notepad for later use.

Path A: CLI + Plugin

Step 2A: Install the Claude CLI

Windows (run in PowerShell):

powershell
irm https://claude.ai/install.ps1 | iex

macOS (Homebrew recommended; if Homebrew is not installed, run the command below first):

bash
# Install Homebrew (skip if already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Claude Code
brew install --cask claude-code

Linux:

bash
curl -fsSL https://claude.ai/install.sh | sh

Verify the installation:

plaintext
claude --version
# Showing "Claude CLI v1.x.x" means success

Step 3A: Configure the API (Pick One)

Choose the method that fits your habits — both produce exactly the same result.

CC Switch is a visual configuration tool provided by gahorouter. It supports one-click import and multi-environment switching, with no need to manually edit configuration files.

3A.1 Install CC Switch

Go to https://github.com/farion1231/cc-switch and download the version for your system:

  • Windows: Download the .exe installer, then install and run it
  • macOS: Download the .dmg installer, then install and run it

3A.2 One-Click Import Configuration

  1. Log in to gahorouter and go to the API Keys page
  2. Find the target Key and click the "Export CCS" button
  3. When the redirect prompt appears, click "Allow"
  4. The system automatically opens the CC Switch app and completes the configuration import

💡 CC Switch saves the configuration to ~/.gahorouter/config.json and supports multi-environment switching (development / testing / production)

3A.3 Verify the Configuration

Open a terminal and enter:

plaintext
claude

After entering the Claude Code interactive page, type "Hello" and wait for a reply.

  • ✅ Claude returns a normal reply → Configuration successful
  • ❌ Authentication failed → Check whether the API Key was imported correctly
  • ❌ Cannot connect to API → Check your network connection

Configuring manually via environment variables suits developers familiar with the command line and makes reuse easy in CI/CD, Docker, scripts, and similar scenarios.

macOS / Linux:

Edit ~/.zshrc (zsh) or ~/.bashrc (bash) and add the following at the end:

bash
# gahorouter API configuration
export ANTHROPIC_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxx"
export ANTHROPIC_BASE_URL="https://console.gahorouter.com"

After saving, run:

bash
source ~/.zshrc # for zsh users
# or
source ~/.bashrc # for bash users

Windows PowerShell:

powershell
# Permanent setting (writes to the system user environment variables; takes effect after restarting the terminal)
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-xxxxxxxxxxxxxxxxxxxxxx", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://console.gahorouter.com", "User")

Verify the environment variables:

bash
echo $ANTHROPIC_API_KEY # macOS/Linux
echo $env:ANTHROPIC_API_KEY # Windows PowerShell

Outputting your Key value means success.

Verify the connection:

plaintext
claude

After entering the interactive page, type "Hello" and wait for a reply.

  • ✅ Claude returns a normal reply → Configuration successful
  • ❌ Authentication failed → Check that the Key value was pasted completely, with no leading or trailing spaces
  • ❌ Cannot connect to API → Check that ANTHROPIC_BASE_URL is correct, or check your network connection

⚠️ Priority note: Environment variables take precedence over CC Switch configuration. If both are set, the environment variables override the CC Switch values.

Path B: Plugin Only (No CLI Installation Required)

Suitable for users who don't want to use the command line. Skip the CLI installation and install the plugin directly in Trae to use the graphical interface.

Step 2B: Install the Claude Code Plugin in Trae

  1. Open Trae and click the Extensions icon in the left activity bar, or press Ctrl+Shift+X
  2. Type "Claude Code" in the search box
  3. Find Claude Code for VS Code and click "Install"
  4. After installation, the ⚡ Spark icon appears in the left activity bar

💡 If the icon doesn't appear in the sidebar, it may be collapsed. Right-click the empty area of the activity bar or open the ··· More menu, then check "claude code: open" to display the icon.

Step 3B: Configure the API (Pick One)

The plugin obtains the API Key by reading system environment variables or the CC Switch configuration. The configuration method is exactly the same as Path A — just pick one.

Follow the steps in "Option A: Use CC Switch" under Path A — they are exactly the same.

After configuration, there is no need to open a terminal. Go directly to Step 4B to verify.

macOS / Linux:

Edit ~/.zshrc (zsh) or ~/.bashrc (bash) and add the following at the end:

bash
export ANTHROPIC_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxx"
export ANTHROPIC_BASE_URL="https://console.gahorouter.com"

After saving, run:

bash
source ~/.zshrc # for zsh users
# or
source ~/.bashrc # for bash users

Windows PowerShell:

powershell
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-xxxxxxxxxxxxxxxxxxxxxx", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://console.gahorouter.com", "User")

⚠️ On Windows, after setting the system environment variables, you must completely close Trae and reopen it before the plugin can read the new variables.

Step 4B: Verify the Plugin Connection

  1. In Trae, click the ⚡ Spark icon on the left to open the Claude Code panel
  2. Type "Hello" in the dialog box
  3. Claude returns a normal reply → Configuration successful

Common errors:

  • ❌ Authentication failed → Check that ANTHROPIC_API_KEY is correct, then restart Trae and try again
  • ❌ Cannot connect → Check that ANTHROPIC_BASE_URL is https://console.gahorouter.com — note that it does not include /v1

Step 4: Using It in Trae (Same for Both Paths)

Mode 1: Trae Terminal Integration (Path A Only)

Run the Claude CLI directly in Trae's built-in terminal, with no extra plugin needed.

Advantages:

  • ✅ Supports full CLI parameters (--files, --model, etc.)
  • ✅ Suited to developers and command-line users

Steps:

  1. Open a project in Trae (menu bar File → Open Folder, or click Open Project on the start page)
  2. Open a terminal (menu bar Terminal → New Terminal, or shortcut Ctrl+`; on macOS, Control+`)
  3. Type claude in the terminal and press Enter to enter the Claude Code interactive page
  4. On first use, confirm trusting the current workspace by following the prompts
  5. Start chatting, for example: "Please analyze the structure of this project"

Mode 2: Claude Code for VS Code Plugin (Available in Both Path A and Path B)

Trae is built on the VS Code core and is fully compatible with VS Code extensions. You can install the Claude Code plugin directly to get a graphical sidebar interface.

Advantages:

  • ✅ Graphical interface, intuitive to use
  • ✅ Sidebar chat, no need to switch to a terminal
  • ✅ Supports code highlighting and syntax coloring
  • ✅ Suited to users unfamiliar with the command line

Steps:

  1. Open the Trae extension marketplace (click the Extensions icon in the left activity bar, or use the shortcut Ctrl+Shift+X)
  2. Type "Claude Code" in the search box
  3. Find Claude Code for VS Code and click "Install" (Path B users have already done this in Step 2B)
  4. After installation, the ⚡ Spark icon appears in the left activity bar; click it to open the Claude Code panel
  5. Interact with Claude in the dialog box

💡 If the icon doesn't appear in the sidebar, it may be collapsed. Right-click the empty area of the activity bar or open the ··· More menu, then check "claude code: open" to display the icon.

💡 Path A users can use both modes at the same time, sharing the same API configuration.

Step 5: Hands-On Conversation Examples

Scenario 1: Understanding an Unfamiliar Project

plaintext
👤 You: Please help me understand the overall architecture of this project

🤖 Claude: Let me analyze this project...
[Automatically reads the project directory structure]
This is a REST API project based on Express + MongoDB...

Scenario 2: Code Refactoring Consultation

bash
# Launch with a file (terminal mode, Path A)
claude chat --files "src/utils/emailSender.js"
plaintext
👤 You: How is the code quality of this file? Any suggestions for improvement?

🤖 Claude: Code quality assessment: ⭐⭐⭐ (3/5)
✅ What's done well: ...
❌ Existing issues: ...
🔧 Refactoring suggestions (by priority): ...

Scenario 3: Bug Debugging

plaintext
👤 You: I got an error when running: TypeError: Cannot read properties of undefined

🤖 Claude: Let me analyze this error...
[Locates line 42 in src/api/user.js]
Root cause: the user object's property was accessed before it was initialized...
Fix: ...

Conversation Tips

TipExample
Provide file context--files "src/auth/**/*.js"
Break tasks into stepsUnderstand first → then design → then generate code
Trigger built-in SkillsSay "review the code" / "write tests" / "got an error"

Getting Help

If you run into problems: