What is Codex CLI?
Codex CLI is OpenAI's official command-line interface for AI-powered code generation and assistance. It provides developers with powerful AI capabilities directly in their terminal, enabling faster development workflows and intelligent code completion.
With AI Code Editor integration, you can use Codex CLI with our optimized API endpoints, enjoying stable service and competitive pricing.
Prerequisites
System Requirements
- Node.js version 18.0.0 or higher
- npm or pnpm package manager
- macOS, Linux, or Windows operating system
- Terminal with UTF-8 support
AI Code Editor Account
You need an AI Code Editor account with an active API key. If you don't have one yet:
- Visit aicodeditor.com/dashboard
- Sign up or log in to your account
- Navigate to API Keys section
- Generate a new API key (format: cr_xxxxxxxxxx)
Installation
Step 1: Install Codex CLI
Install the Codex CLI globally using npm:
npm install -g @openai/codex@latestOr using pnpm:
pnpm add -g @openai/codex@latestStep 2: Verify Installation
Verify that Codex CLI has been installed successfully:
codex --versionYou should see the version number of Codex CLI if the installation was successful.
Configuration
Step 1: Configure Codex Settings
Create or edit the configuration file at ~/.codex/config.toml:
model_provider = "aicodeditor" model = "gpt-5-codex" model_reasoning_effort = "high" disable_response_storage = true preferred_auth_method = "apikey" [model_providers.aicodeditor] name = "aicodeditor" base_url = "https://codex.aicodeditor.com/v1" wire_api = "responses"
Configuration Explanation:
model_provider: Set to "aicodeditor" to use AI Code Editor's APImodel: Specifies the AI model to usemodel_reasoning_effort: Set to "high" for best resultsdisable_response_storage: Ensures privacy by not storing responsespreferred_auth_method: Use API key authenticationbase_url: AI Code Editor's Codex API endpoint
Step 2: Configure API Authentication
Create or edit the authentication file at ~/.codex/auth.json:
{
"OPENAI_API_KEY": "cr_xxxxxxxxxx"
}Important: Replace cr_xxxxxxxxxx with your actual API key from AI Code Editor. This should be the same API key you use for Claude Code.
Step 3: Set File Permissions (Unix/Linux/macOS)
Ensure your authentication file has appropriate permissions:
chmod 600 ~/.codex/auth.jsonBasic Usage
Starting Codex CLI
To start Codex CLI in your project directory:
cd /path/to/your/project codex
Common Commands
| Command | Description |
|---|---|
| codex | Start Codex CLI in interactive mode |
| codex --help | Display help information |
| codex --version | Show version information |
| codex --config | Open configuration editor |
Example Usage
Here's a simple example of using Codex CLI to generate code:
# Start Codex CLI $ codex # Ask Codex to generate a function > Create a Python function to calculate fibonacci numbers # Codex will generate the code for you
Troubleshooting
Common Issues and Solutions
1. Authentication Failed
Error: "Authentication failed" or "Invalid API key"
Solution:
- Verify your API key is correct in
~/.codex/auth.json - Ensure the API key starts with
cr_ - Check that your API key is active in the AI Code Editor dashboard
2. Configuration File Not Found
Error: "Config file not found"
Solution:
- Create the
~/.codexdirectory if it doesn't exist - Ensure both
config.tomlandauth.jsonfiles are present - Check file permissions are correct
3. Connection Timeout
Error: "Request timeout" or "Connection failed"
Solution:
- Check your internet connection
- Verify the base_url in config.toml is correct
- If behind a proxy, configure proxy settings
Getting Help
If you encounter issues not covered here:
- Check the official Codex CLI documentation
- Visit our support center
- Contact our support team at support@aicodeditor.com
Start Using Codex CLI with AI Code Editor
Experience the power of AI-assisted coding with Codex CLI and our optimized API service
