Codex CLI setup
Codex CLI (OpenAI's terminal coding agent) supports custom OpenAI-compatible
providers via ~/.codex/config.toml.
Configuration
Save as ~/.codex/config.toml:
model = "deepseek-v4-pro"
model_provider = "mafdet"
[model_providers.mafdet]
name = "Mafdet AI"
base_url = "https://api.mafdet.ai/v1"
env_key = "MAFDET_API_KEY"
wire_api = "chat"
Then export your key in the shell that runs codex:
export MAFDET_API_KEY="sk-mafdet-xxxxxxxxxxxxxxxx"
env_keynames the environment variable holding your key — the config file itself never contains a secretwire_api = "chat"keeps Codex on the Chat Completions protocol, which the gateway servesmodelis a Mafdet AI model ID (see Models overview)
You can also generate this file pre-filled with your model from Console → API Keys → Developer Tools.
Common errors
| Symptom | Meaning | Fix |
|---|---|---|
| 401 | MAFDET_API_KEY not exported | Export it in the same shell that runs codex |
| 429 | Rate limited (RPM/TPM) | Coding agents need a key with a high TPM limit |
| model not found | Wrong model ID | Check Models overview |