How can I use custom openai compatible API in code...

생성일: 2025년 9월 3일

답변에 사용된 모델 GPT-5 Thinking by Chat01

질문

How can I use custom openai compatible API in codex cli?

IMPORTANT: ONLY ANSWER THE QUESTIONS IF YOU'RE %100 SURE YOUR ANSWER IS CORRECT, OTHERWISE JUST SAY "I don't know"

사고

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

답변

I don't know

이 Q&A 공유하기