Codex CLI Guide
Overview
Codex CLI is an open-source command-line AI programming assistant launched by OpenAI that runs directly in your terminal. By configuring shallowseek's API endpoint, you can use Codex CLI to access the platform's rich model resources for coding, debugging, and project management.
Install Codex CLI
npm Global Install (Recommended)
npm install -g @openai/codex
Verify Installation
codex --version
If a version number is displayed, the installation was successful.
Configure shallowseek API
After installation, configure Codex CLI to connect to the shallowseek platform:
Initialize Configuration
codex init
Set API Endpoint
# Set API Base URL
codex config set base_url "https://api.shallowseek.top/"
# Set API Key
codex config set api_key "sk-your-api-key-here"
Or configure via environment variables:
# Linux / macOS (~/.bashrc or ~/.zshrc)
export OPENAI_BASE_URL="https://api.shallowseek.top/"
export OPENAI_API_KEY="sk-your-api-key-here"
# Windows (PowerShell)
$env:OPENAI_BASE_URL="https://api.shallowseek.top/"
$env:OPENAI_API_KEY="sk-your-api-key-here"
Codex CLI uses the OpenAI-compatible interface, so simply configure OPENAI_BASE_URL and OPENAI_API_KEY to connect to shallowseek.
Basic Usage
Interactive Mode
cd /path/to/your/project
codex
Run codex in your project directory to enter interactive programming assistant mode. Codex CLI automatically analyzes the project context to help you write and modify code.
Single Query
codex -p "Explain the architecture of this project"
codex -p "Write a Python quicksort function for me"
Pipe Mode
cat error.log | codex -p "Analyze this error and suggest fixes"
git diff | codex -p "Review these code changes"
Common Commands
| Command | Description |
|---|---|
codex | Start interactive mode |
codex -p "question" | Single query and output the result |
codex init | Initialize configuration |
codex config | View and modify configuration |
codex --model model-name | Specify which model to use |
codex --help | View full help |
Model Selection
Use the --model parameter to specify a model:
# Use GPT-4o
codex --model gpt-4o
# Use Claude Sonnet
codex --model claude-sonnet-4-20250514
# Use Claude Opus (suitable for complex tasks)
codex --model claude-opus-4-20250514
- Daily coding — Sonnet or gpt-4o, fast and cost-effective
- Complex refactoring — Opus, stronger reasoning and code generation
- Quick scripts — Flash or Mini models, fastest response
Tips & Tricks
- Run in the project root directory — Codex CLI automatically detects project structure and files
- Use clear descriptions — Clearly state what functionality to implement and which files to modify
- Leverage pipes — Pipe git diff, error logs, etc. to codex for analysis
- Execute step by step — Break complex tasks into smaller steps, verifying each one
- Use git protection — Codex modifies files directly; commit before making changes
- Review diffs — Codex shows diffs after modifying files; carefully review before confirming
FAQ
How do I confirm Codex is connected to shallowseek?
Run codex config to view the current configuration and confirm base_url is https://api.shallowseek.top/. Run a simple chat test to verify the connection.
What should I do if the connection fails?
- Check if
base_urlandapi_keyare correctly set - Verify that the API Key is valid and not expired
- Check if the network can reach
api.shallowseek.top - Ensure the API address does not end with
/v1
What is the difference between Codex CLI and Claude Code?
Both are command-line AI programming assistants. Codex CLI is developed by OpenAI and uses the OpenAI-compatible interface, allowing direct connection to shallowseek. Claude Code is developed by Anthropic. The choice depends on your personal preference. shallowseek supports both.