Test the API key first. Then use a named Codex profile, keep the key in $CODEX_HOME/.env, and select a model returned by your account’s live model list.
On 2026-08-02, Codex CLI 0.146.0 loaded monkeyai.config.toml, read a fake key from $CODEX_HOME/.env, and sent the request to https://monkeytheme.com/v1/responses. MonkeyAI returned 401 INVALID_API_KEY, as expected for the fake key. Removing .env changed the error to Missing environment variable: MONKEYAI_API_KEY.
GET /v1/models before writing configuration.curl -fsSL https://monkeytheme.com/install/codex.sh -o /tmp/monkeyai-codex.sh bash -n /tmp/monkeyai-codex.sh bash /tmp/monkeyai-codex.sh
The script hides key input, checks codex --version with a 15-second timeout, tests your key and Base URL, shows currently visible GPT/Codex models, and writes a separate monkeyai profile. It does not overwrite ~/.codex/config.toml.
Create $CODEX_HOME/monkeyai.config.toml (normally ~/.codex/monkeyai.config.toml):
model = "" model_provider = "monkeyai" [model_providers.monkeyai] name = "MonkeyAI" base_url = "https://monkeytheme.com/v1" env_key = "MONKEYAI_API_KEY" wire_api = "responses" requires_openai_auth = false
Set MONKEYAI_API_KEY in $CODEX_HOME/.env, keep the file at mode 600, and replace <CURRENT_VISIBLE_MODEL> with a model returned by your own /v1/models request.
codex --profile monkeyai exec --skip-git-repo-check "Reply with OK only"
--skip-git-repo-check lets this smoke test run outside a repository. For real coding work, open the project directory first and remove that flag.
| Error | Meaning | Fix |
|---|---|---|
codex --version hangs | Old or conflicting Codex installations | Run which -a codex, then reinstall with npm install -g @openai/codex@latest. |
Missing MONKEYAI_API_KEY | Codex did not find the variable in the current environment or $CODEX_HOME/.env | Check CODEX_HOME, the filename and the exact variable name. |
| 401 / invalid API key | The request reached MonkeyAI but the key was rejected | Create or copy a current key from the MonkeyAI dashboard, then rerun /v1/models. |
| 404 | Wrong Base URL or path | Use https://monkeytheme.com/v1; Codex uses the Responses endpoint. |
| model not found | The configured model is not visible to this account | Choose a GPT/Codex model from the current /v1/models response. |
| Provider config ignored | Provider keys were placed in project-local .codex/config.toml | Put the provider in the user-level profile under $CODEX_HOME. |
Codex CLI 0.146.0 loaded MONKEYAI_API_KEY from $CODEX_HOME/.env in a controlled test. Removing that file produced a missing environment variable error.
A profile keeps the MonkeyAI provider separate and avoids replacing an existing Codex setup. Run it with --profile monkeyai.
Use https://monkeytheme.com/v1 and the Responses protocol. The tested request path was /v1/responses.
Select a GPT or Codex model returned by the current account’s /v1/models response. Do not copy a stale model name from an old tutorial.