Before you start
- Create an API Key in a group with a Responses-compatible text model and available balance or quota.
- Prepare a project folder you allow Codex to read. You can use an empty folder for the first test.
- Install a supported Node.js and npm version for the npm method below. See the official Codex installation guide for alternatives.
Set up Codex
1
Install and check the command
Run:Continue once a version number appears. If the command is not found, reopen your terminal and check that npm’s global command directory is in
PATH.2
Prepare your key and model ID
Sign in to aibal.ai, open Use Key in the API Key list, and select Codex. Copy a text model ID supported by the current group. Replace
YOUR_AVAILABLE_MODEL_ID below; it is only a placeholder.3
Edit your user-level config.toml
Open Place the top-level
~/.codex/config.toml, or %USERPROFILE%\.codex\config.toml on native Windows. If you set CODEX_HOME, use the file in that directory. Create the directory and file if absent; otherwise back up the file and merge these fields.model_provider and model fields before the first [table]. Do not duplicate existing fields or [model_providers.aibal]. Keep your other settings. Provider settings belong in your user-level file, not the project’s .codex/config.toml.4
Set the key in your launch terminal
Use hidden input to keep the key out of command history. In Bash or Zsh, run this command and paste the key when prompted; characters will not appear:In Windows PowerShell:This variable applies to this terminal and processes launched from it. Set it again after closing the terminal, or inject it through a trusted secret manager. Never store the real key in project files.
5
Start a new session and verify
Run After a normal answer, check the timestamp, key and model in aibal.ai Usage. A test request may incur charges.
codex in your prepared project folder. Confirm the project trust scope when prompted, then send:Configuration fields
If the console provides a model catalog file or group-specific address, also save that file as instructed in Use Key and use the supplied path and model ID. Do not mix settings from different groups.
Common questions
AIBAL_API_KEY is missing
Startcodex from the terminal where you set the variable. Programs launched from the Dock, Start menu or another terminal may not inherit it. This is a CLI guide; desktop applications may require separate setup.
I still see ChatGPT login or another provider
Check thatmodel_provider = "aibal" is a top-level setting, the user-level file is active, and another configuration manager has not overwritten it. Do not combine this env_key method with an auth.json method from another guide.
The model is missing or requests fail
Replace the placeholder with a model ID your key supports. Check Responses support, duplicate/v1 paths and key quota. See Integration overview for other errors.
An existing session ignores the new settings
Exit the old Codex process and restart from the correctly configured terminal. If using CC Switch, keep editing the same provider there so manual files and managed settings do not overwrite each other.Can I generate images directly from Codex?
Text access does not mean a built-in image tool will automatically use this gateway. If your client supports an image executor, follow the Codex instructions for text to image, select API Key Mode in the console, save the complete matching configuration, and restart the client. Do not mix that configuration with this page’senv_key snippet. You can also explicitly call the image API and save the result as described there. Image tool availability depends on the client and group. For video, see Text to video.