feat: re-add Chat Completions API support for non-OpenAI providers
Resolved 💬 1 comment Opened Jul 4, 2026 by moclaw-dev Closed Jul 4, 2026
Problem
Codex CLI currently only supports the OpenAI Responses API (/v1/responses). The Chat Completions API (/v1/chat/completions) support was removed in commit d2394a249 (Feb 2026, #10157).
This means Codex cannot be used with LLM providers that only support the Chat Completions API format (e.g., many self-hosted models, older proxy servers, and non-OpenAI providers).
Proposed Solution
Re-add Chat Completions API support with an isolation-first approach:
- Add
WireApi::Chatvariant back to theWireApienum - Gate behind a feature flag (
#[cfg(feature = "chat-completions")]) so existing code paths are untouched when not enabled - Restore deleted modules from git history:
codex-rs/codex-api/src/sse/chat.rs(717 lines — SSE streaming parser)codex-rs/codex-api/src/requests/chat.rs(494 lines — request builder)codex-rs/codex-api/src/endpoint/chat.rs(282 lines — ChatClient endpoint)- Test files (~800 lines)
- Adapt restored code to handle new
ResponseItemvariants added since removal (ToolSearchCall,AgentMessage, etc.)
Configuration
# ~/.codex/config.toml
model_provider = "my-provider"
[model_providers.my-provider]
name = "My LLM"
base_url = "https://api.example.com/v1"
env_key = "MY_API_KEY"
wire_api = "chat" # Use Chat Completions API
Scope of Changes
Minimal modifications to existing files (~20 lines):
model-provider-info/src/lib.rs— AddChatvariant toWireApienumcore/src/client.rs— AddWireApi::Chatmatch arm with#[cfg]gateconfig/src/thread_config/remote.rs— Proto mapping forChatcore/config.schema.json— Allow"chat"value
New/restored files (~2000 lines):
- SSE parser, request builder, ChatClient endpoint, tests
References
- Original removal: #10157, commit
d2394a249 - Deprecation discussion: https://github.com/openai/codex/discussions/7782
- Related: #7897 (deprecation notice)
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗