Skip to content

Codex

Codex supports custom model providers. Define a provider named nexoai, use the OpenAI Responses wire API, and store your NexoAI key in Codex's auth file.

Files and paths

PlatformConfigCredential
macOS / Linux~/.codex/config.toml~/.codex/auth.json
Windows%USERPROFILE%\.codex\config.toml%USERPROFILE%\.codex\auth.json

Create the .codex directory if necessary. Merge these values with existing config rather than overwriting unrelated providers or preferences.

Add the nexoai provider

Put this block in config.toml:

toml
model_provider = "nexoai"
model = "gpt-5.4"

[model_providers.nexoai]
base_url = "https://api.nexoai.ma/v1"
wire_api = "responses"
requires_openai_auth = true

The provider base intentionally ends in /v1. Codex builds the Responses API route from this value. The provider name must remain nexoai so it matches model_provider = "nexoai".

To use another catalog model, change only the top-level model value—for example, qwen3-coder-next. Leave the provider block unchanged.

Add the credential

Put the same issued NexoAI key in auth.json:

json
{
  "OPENAI_API_KEY": "sk-your-key"
}

On macOS or Linux, restrict the credential file to your user:

bash
chmod 600 ~/.codex/auth.json

Keep auth.json private

This file contains a live key. Never commit it with a dotfiles repository unless the value is encrypted and excluded from the rendered checkout.

Run Codex

Start Codex in the project directory:

bash
codex

The first request should appear under the named key's usage in the NexoAI dashboard. If you maintain multiple Codex profiles, verify that the active profile does not override model_provider or model.

Troubleshooting

Codex opens a vendor login

Check that requires_openai_auth = true is present and auth.json contains OPENAI_API_KEY. The value is a NexoAI-issued sk-… key; you do not need a separate vendor subscription.

404 or duplicated API version

Use base_url = "https://api.nexoai.ma/v1" exactly once. Do not enter /v1/v1, and do not append /responses yourself because Codex does that through wire_api = "responses".

Model not found

Verify the active NexoAI key first, then compare the configured model with the catalog IDs. A wrong key, wrong host, or typo can all present as model access failures.

One wallet, multiple tools

The key in auth.json can be the same key used by Claude Code, although separate named keys make per-tool caps and usage easier to read.

Next: configure another OpenAI-compatible tool →

Built for developers across MENA.