Configure OpenAI Codex CLI to work with custom model providers that use OpenAI Chat Completions API format (like MiniMax) by setting up a local SSE proxy server.
/v1/chat/completions)Stream disconnected before completion or Model metadata not found~/.codex/config.toml for custom endpointsCodex CLI uses OpenAI Responses API format (/v1/responses) with SSE streaming, but many custom model providers (like MiniMax) use OpenAI Chat Completions API format (/v1/chat/completions). This skill provides a Python proxy server that:
http://127.0.0.1:5005 (configurable)Edit ~/.codex/config.toml:
[model]
model = "MiniMax-M2.7-highspeed"
[api]
base_url = "http://127.0.0.1:5005/v1"
api_key = "YOUR_API_KEY_HERE"
cd ~/.codex
python3 scripts/sse_proxy.py
Or use the bundled script:
python3 ~/.workbuddy/skills/codex-custom-model-proxy/scripts/sse_proxy.py
codex
The proxy script (scripts/sse_proxy.py) supports configuration via environment variables:
# Custom upstream endpoint
export UPSTREAM_HOST="your-upstream-host.com"
export UPSTREAM_PATH="/v1/chat/completions"
export UPSTREAM_TIMEOUT=180
# Custom listen port
export LISTEN_PORT=5005
# API key
export API_KEY="your-api-key-here"
# Start proxy
python3 scripts/sse_proxy.py
Cause: Upstream timeout too short, or proxy not converting SSE format correctly.
Fix:
UPSTREAM_TIMEOUT to 180+ secondsresponse.created, response.in_progress, response.output_text.delta, response.output_text.done, response.completedX-Accel-Buffering: no header is setXXX not found"Cause: Codex can't find model metadata in its model catalog.
Fix (optional, warning only):
~/.codex/model_catalog_gpt55.jsonreferences/model-catalog-schema.md)Note: This is a warning only, Codex will still work with fallback metadata.
Cause: Too many skills enabled, context budget exceeded.
Fix:
codex disable Edit the MODEL_META dict in scripts/sse_proxy.py:
MODEL_META = {
"id": "MiniMax-M2.7-highspeed",
"context_window": 128000,
"max_output_tokens": 4096,
# ... see script for full schema
}
To support multiple models, modify the /v1/models endpoint in the proxy to return all available models.
For HTTPS upstream endpoints, ensure SSL certificates are properly configured. The proxy uses requests library which respects system CA bundles.
scripts/sse_proxy.py - The main proxy server scriptreferences/codex-api-format.md - Codex API format documentationreferences/model-catalog-schema.md - Model catalog JSON schema共 1 个版本