config.toml and let Codex read the API key from either an environment variable or auth.command.
Values
Install Codex CLI
Install first, then run the version check separately. Do not put install, update, and verification commands into one copyable block.- macOS / Linux
- Windows PowerShell
- npm
- Homebrew
Install:Verify:
Recommended: import configuration from an API key
On the Moxus AI API keys page, each key row has an Import configuration action. Choose Codex to generate a terminal script for the selected key and current site address.1
Open the API keys page
Go to the Moxus AI console API keys page and find the key you want Codex to use.
2
Open Import configuration
Open the actions menu for that key, choose Import configuration, then switch to
Codex.3
Copy the script for your system
Use “macOS / Linux terminal” for macOS or Linux. Use “Windows PowerShell” for Windows.
4
Run the script directly in your terminal
Open your terminal, paste the copied script directly into the same terminal window, and press Enter. The script works in both zsh and Bash, and the current terminal can use the new configuration as soon as it finishes.
Use the “macOS / Linux terminal” script for macOS or Linux, and the PowerShell script for Windows. Both can be pasted and run directly in their respective terminals; no temporary file or extra command is required.
Codex config file location
Codex reads.codex/config.toml from your user directory by default. If you set CODEX_HOME, the file moves to $CODEX_HOME/config.toml.
- macOS
- Linux
- Windows
Default path: Open the directory:
/Users/your-name/.codex/config.tomlCreate the directory:config.toml. If you create it with Notepad, make sure it is not saved as config.toml.txt.
Manual config.toml setup
If you do not use Import configuration, create or editconfig.toml manually:
Manually set the API key
Current terminal only
Use this for a temporary test. macOS and Linux replace only the key read during this launch. Windows also overrides the provider for this launch because the Windowsconfig.toml generated by Import configuration uses auth.command to read a key file. The variable disappears when you close the terminal.
- macOS / Linux
- Windows PowerShell
Verify
Confirm that Codex can read the config file and environment variable, then run a small task. Check the key variable:- macOS / Linux
- Windows PowerShell
Troubleshooting
Can I put the API key directly in config.toml?
Can I put the API key directly in config.toml?
Not recommended. The latest Windows Codex script generated from
/keys does not write the plain-text key into config.toml; it stores the key in %USERPROFILE%\.codex\moxus-api-key.txt and reads it through auth.command. macOS and Linux still use environment variables. This keeps the secret out of config.toml and makes key rotation easier.My previous Codex configuration disappeared after Import configuration
My previous Codex configuration disappeared after Import configuration
The
/keys Codex script overwrites config.toml. If you already have custom settings, back up the file first or manually merge [model_providers.custom] into your existing config.How do I remove the Moxus AI configuration for Codex?
How do I remove the Moxus AI configuration for Codex?
If Windows PowerShell:Fully quit and reopen Codex afterwards. On macOS, restart the desktop app as well.
config.toml was created only by the Import configuration script, use these commands to remove the Moxus AI configuration, key, and current-session variable. If you merged other providers or personal settings into that file, do not delete the whole config.toml; remove only the custom provider configuration.macOS / Linux:Authentication fails
Authentication fails
First check which config style you are using. If
config.toml uses env_key = "MOXUS_API_KEY", confirm that the terminal or GUI environment launching Codex can read that variable. Reopen the terminal after terminal setup, and GUI-launched Windows clients may still require a system sign-out/sign-in. If you are using the latest Windows script generated from /keys, confirm that %USERPROFILE%\.codex\moxus-api-key.txt exists and that [model_providers.custom.auth] in config.toml has not been overwritten by an older config. Then fully quit and reopen Codex.After installing on Windows, codex --version says the command cannot be found
After installing on Windows, codex --version says the command cannot be found
This usually means installation completed but the current PowerShell window has not refreshed its Then run
PATH yet. Run:codex --version again. If it still fails, close PowerShell, open a new window, and try again.Model not found
Model not found
Set
model to the exact model name from Models and pricing. Do not use a client display name or shorthand.wire_api or provider fields are unsupported
wire_api or provider fields are unsupported
Your Codex version may use a different custom provider format. Keep the Base URL and API key values, then adjust
wire_api or provider fields according to the current Codex error message.