Codex CLI
Integrate ARZASTORE AI API with Codex CLI — OpenAI's AI coding assistant in the terminal
What is Codex CLI?
System Requirements
Operating System
- macOS / Linux (Terminal with Bash/Zsh)
- Windows (PowerShell / Git Bash)
Software
- Node.js version 22 or later
- npm (bundled with Node.js)
Account
- ARZASTORE AI account with sufficient balance
- Consumer API Key (sk-xxx)
- Subscribed to an OpenAI model (GPT-4.1, o4-mini, o3, ...)
Install Codex CLI
Install Codex CLI using npm:
npm install -g @openai/codex
Verify the installation:
codex --version
Update version
Quickstart via API Keys (Recommended)
Similar to the Claude Code flow, you can complete the setup in minutes directly from the API Keys page without manual configuration.
- 01Go to Console → API Keys, select the API Key you want to use
- 02Switch to the Codex CLI tab
- 03Select your OS, default model, then copy the setup command
- 04Paste the command into terminal, restart terminal, then run codex
- 05If there are errors, quickly check the Troubleshooting section below
First Run
# Mở Codex CLI trong thư mục dự án
cd /path/to/your/project
codex
# Chạy với câu lệnh cụ thể
codex "Giải thích cấu trúc của dự án này"
Manual Configuration
If not using auto setup, configure the 2 environment variables below.
Environment Variables
| Variable | Value | Description |
|---|---|---|
| OPENAI_API_KEY | sk-your-api-key | Consumer API Key from ARZASTORE AI |
| OPENAI_BASE_URL | https://api.arzastore.com/v1 | Endpoint URL from Marketplace |
# Thêm vào ~/.bashrc hoặc ~/.zshrc
export OPENAI_API_KEY="sk-your-arzastore-api-key"
export OPENAI_BASE_URL="https://api.arzastore.com/v1"
# Reload shell
source ~/.bashrc # hoặc source ~/.zshrc
# Thiết lập vĩnh viễn (cho user hiện tại)
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-your-arzastore-api-key", "User")
[System.Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", "https://api.arzastore.com/v1", "User")
# Restart terminal để áp dụng
Select Model
Codex CLI supports OpenAI models. You need to subscribe to the corresponding model on Marketplace and call the exact model ID or alias.
| Model | Model ID | Features | Best for |
|---|---|---|---|
| o4-mini | o4-mini | Fast, low cost | Simple tasks, autocomplete |
| GPT-4.1 | gpt-4.1 | Balanced speed/quality | Coding, debug, refactor |
| o3 | o3 | Strong reasoning | Complex analysis |
# Chạy với model mặc định
codex
# Chạy với model cụ thể
codex --model gpt-4.1
# Chạy với prompt trực tiếp
codex --model o4-mini "Giải thích cấu trúc dự án này"
Use aliases for easy management
Useful Commands
Display the list of available options and commands.
Change the model for the current session.
Run with fewer confirmation steps for simple tasks.
Troubleshooting
Error "API key not valid"
- • Check that OPENAI_API_KEY is set correctly
- • Check that the key has not been revoked
- • Check that the account balance is sufficient
Error "Connection refused" / timeout
- • Check that OPENAI_BASE_URL is correct and includes /v1
- • Check network connection
Error "Model not found"
- • Check that the model is subscribed on Marketplace
- • Check that the model ID/alias is correct
Quick debug
# Kiểm tra biến môi trường (an toàn)
[ -n "$OPENAI_API_KEY" ] && echo "OPENAI_API_KEY is set" || echo "OPENAI_API_KEY is missing"
[ -n "$OPENAI_BASE_URL" ] && echo "$OPENAI_BASE_URL" || echo "OPENAI_BASE_URL is missing"
# Test endpoint nhanh (chỉ chạy khi đã cấu hình đủ biến)
if [ -n "$OPENAI_API_KEY" ] && [ -n "$OPENAI_BASE_URL" ]; then
curl -s "$OPENAI_BASE_URL/models" -H "Authorization: Bearer $OPENAI_API_KEY" | head -c 200
fi