CodeX CLI Installation and Configuration
CodeX CLI Installation and Configuration
Section titled “CodeX CLI Installation and Configuration”Overview of this page
🚀 CodeX Installation and 4All API Configuration Guide
Section titled “🚀 CodeX Installation and 4All API Configuration Guide”CodeX is a powerful terminal-based coding assistant built on OpenAI GPT models. By following the steps below, you can seamlessly configure it to use the 4All API aggregation platform service and enjoy an ultra-fast, fully powered AI coding experience.
If you already have it installed on your computer, just skip ahead. If not, it’s recommended to go with the default installation path to save yourself a lot of trouble.
Step 1: Install CodeX CLI
Section titled “Step 1: Install CodeX CLI”- Download Git: [ https://git-scm.com/downloads/win ] (macOS usually includes it, or you can install it via Homebrew with brew install git )
- Download Node.js: [ https://nodejs.org/zh-cn/download ] (just keep clicking Next)
Step 2: Install CodeX CLI
Section titled “Step 2: Install CodeX CLI”Open the command line (CMD) or terminal (PowerShell), and run the following command to install globally:
# Windows users are advised to run the terminal as Administrator# macOS/Linux users may need to add sudonpm install -g @openai/codex@latestAfter installation, you can verify that it worked by running codex —version . (Note: if Windows says it cannot find the codex command, try launching it temporarily with npx @openai/codex , or check your system’s npm environment variable configuration.)
Step 3: Configure the 4All API aggregation node
Section titled “Step 3: Configure the 4All API aggregation node”CodeX configuration is split across two files: config.toml and auth.json . We’ll use these two files to point both the service endpoint and authentication entirely to 4All API.
- Get an API key:
- Visit the [4All API Console] https://4All API.com .
- Create a new token.
- Copy the generated sk-… key for later use.
- Create the configuration files: Create a hidden folder named .codex in your user home directory:
- Windows: %USERPROFILE%.codex (usually C:\Users\your-username.codex )
- macOS/Linux: ~/.codex
Inside the .codex folder, create the following two files and fill them with the corresponding content:
📄 File 1: config.toml (advanced configuration for full-power reasoning and web search)
disable_response_storage = truemodel = "gpt-5.2"model_provider = "4All API"model_reasoning_effort = "xhigh"model_verbosity = "high"
[features]web_search_request = true
[model_providers.4All API]name = "4All API"# 4All API Singapore high-speed relay nodebase_url = "https://sg.4All API.com/v1"wire_api = "responses"# This must be enabled, together with auth.json, to complete platform authenticationrequires_openai_auth = true📄 File 2: auth.json
{ "OPENAI_API_KEY": "sk-Paste your real key obtained from 4All API here"}⚠️ Important notes:
- Make sure the key format in auth.json is correct, and do not omit the double quotes.
- The base_url in config.toml must include the /v1 path suffix exactly.
Step 4: Launch and use
Section titled “Step 4: Launch and use”Everything is ready! Open a terminal, use the cd command to enter your project’s source code directory, and run the following command to bring up your private coding assistant:
codexThis refactored tutorial flows very smoothly, and it also clearly marks the configuration file locations and common pitfalls.
Step 5: One-click setup script (.bat) launch!
Section titled “Step 5: One-click setup script (.bat) launch!”This script is really well written! In particular, the notepad auto-open logic at the end, which prompts the user to enter their key, is very thoughtful and user-friendly.
I’ve perfectly replaced it with the 4All API configuration, and I’ve also integrated the premium parameters we previously tuned together ( gpt-5.2 , full-power reasoning xhigh , web search, etc.).
Please copy the code below directly and replace your original script content:
@echo offchcp 65001 >nulsetlocal enabledelayedexpansion
echo ========================================echo CodeX Assistant - 4All API One-Click Setup Toolecho ========================================echo.
REM Set the .codex folder pathset "CODEX_PATH=%USERPROFILE%\.codex"
REM Create the .codex folderif not exist "%CODEX_PATH%" ( mkdir "%CODEX_PATH%" echo [√] Folder created: %CODEX_PATH%) else ( echo [!] Folder already exists: %CODEX_PATH%)
REM Create config.toml(echo disable_response_storage = trueecho model_provider = "4All API"echo model = "gpt-5.2"echo model_reasoning_effort = "xhigh"echo model_verbosity = "high"echo.echo [features]echo web_search_request = trueecho.echo [model_providers.4All API]echo name = "4All API"echo base_url = "https://sg.4All API.com/v1"echo wire_api = "responses"echo requires_openai_auth = true) > "%CODEX_PATH%\config.toml"echo [√] Core configuration file created: %CODEX_PATH%\config.toml
REM Create auth.json(echo {echo "OPENAI_API_KEY": "sk-Paste your real key obtained from 4All API.com here"echo }) > "%CODEX_PATH%\auth.json"echo [√] Key configuration file created: %CODEX_PATH%\auth.json
echo.echo ========================================echo The basic configuration framework has been created!echo.echo ⚠️ Final step:echo Please edit the auth.json file and replace the placeholder text with your real API key.echo ========================================echo.
set /p "OPEN=Open the auth.json file now for editing? (Y/N): "if /i "!OPEN!"=="Y" ( notepad "%CODEX_PATH%\auth.json")
pause💡 Script optimization highlights:
Section titled “💡 Script optimization highlights:”- Integrated the strongest parameters: the previously required web_search_request and xhigh reasoning intensity are both written into config.toml via echo .
- Preserved your excellent interaction flow: the feature where pressing Y immediately opens Notepad has been perfectly retained.
- Refined the Chinese prompts: the interface prompts were made clearer to help prevent users from entering the wrong format.