Ensuring accuracy with Codex provider setup
I’ve found that to use Codex with a custom OpenAI-compatible API, you need to set the OPENAI_BASE_URL (or provider’s base URL) and OPENAI_API_KEY. You can also use the --provider flag, but I’m still unsure about the full list of valid provider options. The provider might need to support specific endpoints like /v1/responses.
Confirming Codex compatibility with custom APIs
To use a custom OpenAI-compatible API in Codex CLI, set the OPENAI_BASE_URL and API key via environment variables or config. You also need to specify the model name. However, Codex uses /v1/responses by default, and not all providers support this, which might cause issues. Let me double-check before confirming!
Finalizing the answer
The user wants me to be 100% sure. Based on what I know, I believe the answer is: Set OPENAI_BASE_URL and OPENAI_API_KEY, run codex --provider openai --model <model> for providers that support OpenAI's /v1/responses API. If they only support chat completions, it won’t work. I’m quite confident, but I’ll aim for 100% by confirming with documentation.
Clarifying the answer
I found a snippet in the GitHub readme that mentions Codex CLI supporting providers with the OpenAI Chat Completions API, but an issue later says Codex uses /v1/responses. This creates a contradiction. To be safe, I'll say: "Codex CLI can use any OpenAI-compatible API with OPENAI_BASE_URL and OPENAI_API_KEY. The provider must support /v1/responses for full functionality." I'll cite the relevant issue and documentation.
Thought for 2m 44s