1. What is Codex CLI
Codex CLI is a local terminal AI coding assistant that helps you with:- Code generation
- Code modification
- Automated command execution
- Project analysis
2. Prerequisites
1. Install Node.js
Recommended: Node.js 20 or higher Download: https://nodejs.org2. Install Codex CLI
3. Configure API
Codex uses a config file for API connection.1. Config File Location
Default paths:- Windows:
- macOS / Linux:
2. Basic Configuration
Editconfig.toml:
model: model name to usebase_url: API address (must include/v1)env_key: environment variable name for the API key
3. Set API Key
macOS / Linux
Windows (PowerShell)
4. Start Codex
Navigate to your project:5. Basic Usage
1. Interactive Mode
2. Single Command
3. Specify a Model
4. Image Input (Multimodal)
6. Troubleshooting
401 / 403 Error
Check:- Is the API Key correct?
- Did the environment variable take effect?
404 Error
Check:- Is the API address correct?
- Does it include the
/v1path?
Model Unavailable
Check:- Is the model name correct?
- Does your account have access to this model?
7. Advanced Configuration
Multiple Models
8. Best Practices
- Use environment variables for API keys (more secure)
- Use consistent model naming for easier switching
- Use separate configs per project
- Regularly check usage and logs
9. Summary
After completing the setup, you can:- Use AI coding in your local terminal
- Connect to a unified API service
- Flexibly switch between models