Verify these three items before editing config
- The key and Base URL have already passed a direct API test.
- Your current Codex CLI version supports the provider / Base URL path you plan to use.
- You know whether you are using env vars or a config file.
Option A: environment variables
Use this for short-term validation in the current shell or project.
export OPENAI_API_KEY=sk-你的Key export OPENAI_BASE_URL=https://monkeytheme.com/v1 export OPENAI_MODEL=gpt-4.1-mini
Option B: config-file workflow
This is better for longer-lived use.
Common Codex mistakes
- Mixing official OpenAI flow with a custom provider flow.
- Assuming another person’s CLI version supports the same fields as yours.
- Supplying only half of the Base URL a specific flow expects.
- Using a nickname instead of the real model name.