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:
winget install OpenJS.NodeJS.LTSAfter installation, run node -v and npm -v in a new terminal to verify.
Install with Brew (macOS)
Open a terminal and run:
brew install nodeIf Homebrew is not installed, refer to the official Homebrew documentation.
Verify Environment
Run the following commands and confirm that version numbers are returned.
node -vTip
Using a faster npm mirror may improve download speed in some regions: npm config set registry https://registry.npmmirror.com
npm -vClaude Code Setup
Install
Windows:
npm install -g @anthropic-ai/claude-codeOn macOS or Linux, use sudo if required:
sudo npm install -g @anthropic-ai/claude-codeEnvironment Variables
Windows:
setx ANTHROPIC_API_KEY "sk-xxxxxxxxxxxxxx" # Replace with your API keymacOS/Linux:
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:
{
"theme": "dark",
"apiBaseUrl": "https://api.vlxflux.io"
}Launch
claudeCodex Setup
Install
Windows:
npm install -g codex-cliIf elevated permission is required:
sudo npm install -g codex-cliEnvironment Variables
Windows:
setx OPENAI_API_KEY "sk-xxxxxxxxxxxxxx" # Replace with your API keymacOS/Linux:
export OPENAI_API_KEY="sk-xxxxxxxxxxxxxx"
export OPENAI_BASE_URL="https://api.vlxflux.io/v1"Config File
Edit ~/.codex/config.json:
{
"api_key": "sk-xxxxxxxxxxxxxx",
"base_url": "https://api.vlxflux.io/v1",
"model": "gpt-4o"
}Launch
codexGemini CLI Setup
Install
Windows:
npm install -g @google/generative-ai-cliIf elevated permission is required:
sudo npm install -g @google/generative-ai-cliEnvironment Variables
Run the following in macOS/Linux:
export GEMINI_API_KEY="sk-xxxxxxxxxxxxxx"
export GOOGLE_GEMINI_BASE_URL="https://api.vlxflux.io"Config File
Edit ~/.gemini/config.json:
{
"api_key": "sk-xxxxxxxxxxxxxx",
"base_url": "https://api.vlxflux.io"
}Launch
geminiFAQ
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.
export ANTHROPIC_BASE_URL="https://api.vlxflux.io"
claudeExtra Configuration
Switch Models Dynamically
Add an alias in ~/.bashrc or ~/.zshrc:
alias claude_opus='export ANTHROPIC_MODEL="claude-3-opus-20240229" && claude'Then run:
source ~/.zshrc
claude_opusQuiet Output
codex "写一段快速排序" --quiet