Skip to main content

Prerequisites

Claude Code is a command-line AI programming assistant from Anthropic that supports direct conversation with AI, code generation, debugging, and more in your terminal. By integrating ByteRouter, you can access multiple AI models including GPT, Claude, and Gemini directly within Claude Code. Before getting started, ensure you have:
  1. ByteRouter API Key Sign in to ByteRouter Console to get your API key
Tip: If you don’t have a ByteRouter account yet, register at ByteRouter first and obtain your API key.

Step 1: Install Claude Code

Choose one of the following installation methods:

Verify Installation

After installation, run the following command to confirm success:
If a version number (e.g., 1.x.x) is displayed, the installation is successful.

Step 2: Configure ByteRouter API

Three configuration methods are available. Choose the one that suits your workflow. This is the most stable configuration method and works persistently after one-time setup. 1. Find the configuration directory:
  • Windows: Press Win + R, type %userprofile%\.claude
  • macOS: Press Command + Shift + G, type ~/.claude
  • Linux: Navigate to ~/.claude directory
If the directory doesn’t exist, run claude once in your terminal and press Ctrl + C to exit. The directory will be created automatically.
2. Create or edit the settings.json file:
After saving, restart Claude Code for changes to take effect.

Method 2: Permanent Environment Variables

Configure at the system level so all terminal windows automatically load the settings.

Method 3: Temporary Environment Variables

Suitable for temporary testing. Configuration will be lost when you close the terminal.
Temporary environment variables only work in the current terminal window. You’ll need to reconfigure them after opening a new terminal or restarting.

Step 3: Get Started

Verify Configuration

Start Claude Code and send a simple message to confirm configuration:
If you receive an AI response, the configuration is successful. If you encounter errors, refer to the troubleshooting section below.

Usage Modes

Claude Code offers two interaction modes:
  • Interactive Mode: Run claude to enter continuous conversation, ideal for complex tasks
  • Single Command: Run claude "your question" to get a one-time response and exit, perfect for quick queries

Supported Models

ByteRouter supports various AI models that you can switch between based on your needs. See the Getting Started page for the complete model list.

Common Model Examples

Common Commands

Here are frequently used commands and shortcuts in Claude Code:

Troubleshooting

Q1: Login selection screen still appears after configuration?

If “Select login method” is displayed, the configuration hasn’t taken effect. Troubleshooting steps:
  1. Using settings.json method: Verify the file path is correct
    • Windows: C:\Users\<username>\.claude\settings.json
    • macOS / Linux: ~/.claude/settings.json
  2. Using environment variables: Ensure you started Claude Code in the same terminal window where you set the variables
  3. Check JSON format: Make sure brackets, commas, and quotes are correct (don’t use Chinese quotes)

Q2: Authentication errors?

Ensure ANTHROPIC_BASE_URL is set to https://byterouter.ai/v1.

Q3: “Unable to connect” error?

This means Claude Code cannot connect to the API service.
  1. Check your network connection
  2. Verify ANTHROPIC_BASE_URL is configured correctly
  3. If using a proxy, ensure it allows access to byterouter.ai

Q4: How to switch models?

Two options:
  1. In interactive mode: Type /model command to switch
  2. Modify configuration: Change the ANTHROPIC_MODEL field in settings.json or environment variables, then restart Claude Code

Q5: Slow responses?

  1. Try switching to a faster model
  2. Shorten your questions to reduce context length
  3. Check your local network status

Support & Help

If you encounter any issues:

Get Started with ByteRouter

Register now and get your API key to start using multiple AI models in Claude Code!