Skip to main content
Codex CLI selects model providers from local configuration. To use Moxus AI, add a custom provider to Codex config.toml and let Codex read the API key from either an environment variable or auth.command.
This page applies to Codex CLI or local Codex environments that support config.toml and custom model_providers. Codex versions can differ. If your version reports unsupported fields, follow the current Codex error message and built-in help.

Values

Install Codex CLI

Install first, then run the version check separately. Do not put install, update, and verification commands into one copyable block.
Install:
Verify:
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.
The generated script does the following:
The current Import configuration script overwrites Codex config.toml. If you already have other providers, models, sandbox settings, or project defaults, back up the file before running the script.
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.
Default path: /Users/your-name/.codex/config.tomlCreate the directory:
Open the directory:
The file name must be 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 edit config.toml manually:
Key fields:

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 Windows config.toml generated by Import configuration uses auth.command to read a key file. The variable disappears when you close the terminal.
For persistent setup or desktop use, choose Codex from Import configuration on the API keys page. The generated script writes both the provider configuration and key, and configures the launch environment for the current operating system.

Verify

Confirm that Codex can read the config file and environment variable, then run a small task. Check the key variable:
Run a test task:
Then open Usage and confirm the request appears under the expected API key.

Troubleshooting

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.
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.
If 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:
Windows PowerShell:
Fully quit and reopen Codex afterwards. On macOS, restart the desktop app as well.
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.
This usually means installation completed but the current PowerShell window has not refreshed its PATH yet. Run:
Then run codex --version again. If it still fails, close PowerShell, open a new window, and try again.
Set model to the exact model name from Models and pricing. Do not use a client display name or shorthand.
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.

Next steps