Skip to content

CLI Setup Guide ​

This guide covers the basic installation and setup of Claude Code, Codex, and Gemini CLI.

Before You Start

Before configuring command-line tools, make sure you understand the following basics:

Environment Requirements ​

This section covers the installation of Node.js, npm, and related dependencies.

Install with Winget (Windows) ​

Open a terminal and run:

bash
winget install OpenJS.NodeJS.LTS

After installation, run node -v and npm -v in a new terminal to verify.

Install with Brew (macOS) ​

Open a terminal and run:

bash
brew install node

If Homebrew is not installed, refer to the official Homebrew documentation.

Verify Environment ​

Run the following commands and confirm that version numbers are returned.

bash
node -v

Tip

Using a faster npm mirror may improve download speed in some regions: npm config set registry https://registry.npmmirror.com

bash
npm -v

Claude Code Setup ​

Install ​

Windows:

bash
npm install -g @anthropic-ai/claude-code

On macOS or Linux, use sudo if required:

bash
sudo npm install -g @anthropic-ai/claude-code

Environment Variables ​

Windows:

bash
setx ANTHROPIC_API_KEY "sk-xxxxxxxxxxxxxx" # Replace with your API key

macOS/Linux:

bash
export ANTHROPIC_API_KEY="sk-xxxxxxxxxxxxxx"
export ANTHROPIC_BASE_URL="https://api.vlxflux.io"

Config File ​

Create or edit .claude.json in your home directory:

json
{
  "theme": "dark",
  "apiBaseUrl": "https://api.vlxflux.io"
}

Launch ​

bash
claude

Codex Setup ​

Install ​

Windows:

bash
npm install -g codex-cli

If elevated permission is required:

bash
sudo npm install -g codex-cli

Environment Variables ​

Windows:

bash
setx OPENAI_API_KEY "sk-xxxxxxxxxxxxxx" # Replace with your API key

macOS/Linux:

bash
export OPENAI_API_KEY="sk-xxxxxxxxxxxxxx"
export OPENAI_BASE_URL="https://api.vlxflux.io/v1"

Config File ​

Edit ~/.codex/config.json:

json
{
  "api_key": "sk-xxxxxxxxxxxxxx",
  "base_url": "https://api.vlxflux.io/v1",
  "model": "gpt-4o"
}

Launch ​

bash
codex

Gemini CLI Setup ​

Install ​

Windows:

bash
npm install -g @google/generative-ai-cli

If elevated permission is required:

bash
sudo npm install -g @google/generative-ai-cli

Environment Variables ​

Run the following in macOS/Linux:

bash
export GEMINI_API_KEY="sk-xxxxxxxxxxxxxx"
export GOOGLE_GEMINI_BASE_URL="https://api.vlxflux.io"

Config File ​

Edit ~/.gemini/config.json:

json
{
  "api_key": "sk-xxxxxxxxxxxxxx",
  "base_url": "https://api.vlxflux.io"
}

Launch ​

bash
gemini

FAQ ​

API key does not take effect?

Restart the terminal, or use echo to confirm the environment variable is loaded.

Model not found?

Make sure the model name is correct and the current key has permission to use it.

Cannot connect to the server?

Check whether the BASE_URL is correct, whether proxy settings interfere, and whether DNS resolution works properly.

Claude Code unauthorized?

Try exporting ANTHROPIC_BASE_URL again before launching.

bash
export ANTHROPIC_BASE_URL="https://api.vlxflux.io"
claude

Extra Configuration ​

Switch Models Dynamically ​

Add an alias in ~/.bashrc or ~/.zshrc:

bash
alias claude_opus='export ANTHROPIC_MODEL="claude-3-opus-20240229" && claude'

Then run:

bash
source ~/.zshrc
claude_opus

Quiet Output ​

bash
codex "写一段快速排序" --quiet