Overview
OpenAI Codex CLI is OpenAI’s command-line programming assistant, an AI programming tool designed for developers. By configuring APIYI service, you can get:🚀 Stable Service
Direct connection to APIYI, no proxy needed
💰 Flexible Billing
Support pay-per-token or pay-per-call
⚡ GPT-5 Support
Use latest GPT-5 models
🔧 Simple Setup
Complete setup in minutes
Environment Preparation
Required Software
1
Install Git
Visit Git Official Website to download and install
Windows Users: Recommend default installation to C drive with default settings
macOS Users: Usually pre-installed, can skip this step
2
Install Node.js
Visit Node.js Official Website to download and installRequires Node.js 18 or higher
3
Verify Installation
Open terminal to verify successful installation:
Quick Start
1. Install Codex CLI
Run the following command in terminal to install globally:2. Get API Key
- Visit APIYI Console
- Create new key or use default key
- Supports two types:
- Pay-per-token: Based on Token usage
- Pay-per-call: Suitable for Codex series models
3. Configure Codex
Create Configuration File
- macOS/Linux
- Windows
Edit configuration file:If directory doesn’t exist, create it first:
Configuration Content
Add the following toconfig.toml:
Model Selection Notes:
gpt-5-codex-high: Strongest programming capability, comparable to GPT-5gpt-5-codex-medium: Medium performance, moderate pricinggpt-5-codex-low: Lightweight version, lowest cost
4. Set Environment Variables
Set your APIYI key as environment variable:- macOS/Linux
- Windows
macOS (zsh):Linux (bash):
After configuration, recommend restarting terminal to ensure environment variables take effect.
5. Start Using
Enter your project directory and launch Codex:Usage Tips
Project Initialization
First time using in project, let Codex familiarize with project structure:AGENTS.md file to record project information.
Chinese Support
By default, Codex uses English for conversation. For Chinese communication, add toAGENTS.md file:
Custom Prompts
Edit~/.codex/instructions.md file to customize system prompts and define AI assistant behavior:
Codex Series Model Comparison
| Model | Billing Mode | Features | Use Cases |
|---|---|---|---|
| gpt-5-codex-high | Token/Call | Strongest programming | Complex algorithms, architecture design |
| gpt-5-codex-medium | Token/Call | Balanced performance | Daily programming tasks |
| gpt-5-codex-low | Token/Call | Lightweight and efficient | Simple code generation |
Billing Recommendations:
- Large Context Scenarios: Pay-per-call more cost-effective
- Short Conversation Scenarios: Pay-per-token more economical
Features
Supported Programming Tasks
- ✅ Code generation and completion
- ✅ Bug fixing and debugging
- ✅ Code refactoring and optimization
- ✅ Unit test writing
- ✅ Documentation generation
- ✅ Code review
- ✅ Algorithm implementation
Supported Languages
Codex supports 100+ programming languages, including:- Mainstream Languages: Python, JavaScript, TypeScript, Java, C++, C#, Go, Rust
- Web Technologies: HTML, CSS, React, Vue, Angular
- Databases: SQL, MongoDB, Redis
- Scripting: Bash, PowerShell, Perl
- Others: Swift, Kotlin, Ruby, PHP, R, MATLAB
Troubleshooting
Prompt command not found: codex
Prompt command not found: codex
Ensure Codex CLI is correctly installed:If still having issues, check if npm global install path is in PATH.
Invalid API Key Error
Invalid API Key Error
- Confirm using APIYI key, not OpenAI official key
- Check environment variable is correctly set:
Connection Error or Timeout
Connection Error or Timeout
Check
base_url in config.toml is correctly set to:How to Switch Models
How to Switch Models
Edit
model field in ~/.codex/config.toml:How to Uninstall or Disable
How to Uninstall or Disable
Uninstall Codex CLI:Disable APIYI Configuration:
Delete environment variables and configuration files:
VS Code / Cursor Integration
Besides command-line use, Codex also provides IDE plugins:Currently, Codex official plugins in VS Code and Cursor don’t support APIYI configuration, requiring official account. To use APIYI in IDE, recommend using other compatible plugins.
Alternatives
- Cursor: Built-in AI features, supports custom API endpoints
- Continue: Open-source AI programming assistant, supports APIYI configuration
- Cline: VS Code plugin supporting custom APIs
Best Practices
Project Organization
- Create AGENTS.md: Record project standards and requirements
- Add .gitignore: Exclude Codex-generated temporary files
- Write Clear Comments: Help AI understand code intent
Prompt Tips
Performance Optimization
-
Choose Models Wisely:
- Simple tasks use
gpt-5-codex-low - Complex tasks use
gpt-5-codex-high
- Simple tasks use
-
Context Management:
- Clean unnecessary conversation history timely
- Focus on current task
-
Batch Processing:
- Describe related tasks at once
- Reduce round-trip interactions
Related Resources
OpenAI Codex Official
Learn about Codex technical details
APIYI Console
Manage API keys and view usage
Claude Code
Explore Claude programming assistant
Model Comparison
View all programming model comparisons
Summary
OpenAI Codex CLI paired with APIYI service provides developers with a powerful and economical AI programming assistant. Through flexible billing modes and stable service, you can fully leverage GPT-5 Codex series programming capabilities to improve development efficiency.Comparison Tip:
- Command-line Experience: Codex CLI suitable for developers familiar with terminal
- IDE Integration: For better IDE experience, consider Claude Code or other plugins supporting APIYI