codex-minimax-proxy is a lightweight local proxy for Codex CLI and Codex App. It lets you keep one local base_url while routing each request by model:
- MiniMax models are translated from OpenAI-style Responses API requests into MiniMax Chat Completions.
- OpenAI models are forwarded natively to OpenAI Responses or Chat Completions.
- URL-heavy MiniMax runs can use a proxy-side
web_fetchtool instead of getting stuck trying shell HTTP tools.
This is useful when you want MiniMax available inside Codex without giving up normal GPT-family workflows.
flowchart LR
A[Codex CLI / Codex App] --> B[Local Proxy<br/>http://localhost:4000/v1]
B --> C{Model Router}
C -->|MiniMax model| D[Responses -> Chat Completions translation]
D --> E[MiniMax API]
C -->|OpenAI model| F[Native Responses / Chat Completions pass-through]
F --> G[OpenAI API]
D -. optional web_search .-> H[OpenRouter web model]
D -. optional URL fetch .-> I[Proxy-side web_fetch]
Recent commits shifted this repo from a single-model translator into a multi-provider router with stronger tool handling:
| Commit | Update |
|---|---|
a9bbc6d |
Switched the default OpenRouter search model to nvidia/nemotron-3-super-120b-a12b:free |
f111abc |
Previously switched the search model to Qwen3 Coder, then superseded |
8b55987 |
Added web_fetch loop deduplication, stuck-loop detection, and GitHub auth injection |
d220cb8 |
Added /v1/chat/completions and a tool-call loop circuit breaker |
74c0a0c |
Improved subagent compatibility by removing a tool-call limit and preserving more metadata/events |
70b489f |
Fixed consecutive assistant messages and truncated oversized tool outputs |
40806ab |
Fixed mid-action stalls and added previous_response_id support |
I tightened the latest tool-routing work in proxy.mjs:
web_fetchinjection is now deduplicated instead of blindly appending another function tool definition.- URL detection now uses the same logic in both the Responses and Chat Completions MiniMax paths.
- The proxy also avoids duplicating the
web_fetchinstruction message when it is already present.
That reduces noisy tool payloads and makes behavior more predictable in long or resumed conversations.
This proxy does not convert a ChatGPT subscription login into a generic localhost API.
If your goal is "keep using my normal Codex plan and also have MiniMax available," the clean setup is:
- keep native
codex loginas your default OpenAI path - add a separate MiniMax profile that points at this proxy
- MiniMax Responses -> Chat Completions translation
- OpenAI Responses pass-through
- OpenAI Chat Completions pass-through
- Model-based provider routing
- Combined
/v1/modelsmodel catalog - Streaming support on both routing paths
previous_response_idbridging for responses stored by the proxy- MiniMax tool-call ordering repair
- Tool-call loop circuit breaker
- Proxy-side
web_fetchfor URL-heavy MiniMax turns - Optional OpenRouter fallback for MiniMax
web_search - Zero runtime dependencies
git clone https://github.com/DevvGwardo/codex-minimax-proxy.git
cd codex-minimax-proxy
cp env.example .envSet at least one upstream key:
export MINIMAX_API_KEY="..."
export OPENAI_API_KEY="..."You can set one or both. If both are present, the proxy can route by model name.
node proxy.mjsThe default listener is:
http://localhost:4000/v1
Recommended if you already use native codex login for GPT models:
model = "gpt-5.4"
[profiles.minimax]
model = "MiniMax-M2.7"
model_provider = "minimax_proxy"
[model_providers.minimax_proxy]
name = "MiniMax Proxy"
base_url = "http://localhost:4000/v1"
env_key = "MINIMAX_API_KEY"Use it like this:
codex
codex -p minimaxThis is the safest and simplest setup for most people.
- GPT-family requests keep using your normal Codex login path.
- MiniMax is available only when you opt into the profile.
Use this only if you want all traffic routed through the proxy and you are comfortable using API-key-backed OpenAI access.
model = "gpt-5.4"
model_provider = "local_router"
[model_providers.local_router]
name = "Local Router"
base_url = "http://localhost:4000/v1"
env_key = "MINIMAX_API_KEY"In this mode the proxy uses its own upstream environment variables:
MINIMAX_API_KEYfor MiniMax modelsOPENAI_API_KEYfor OpenAI models
The proxy advertises and routes models from:
MINIMAX_MODELSOPENAI_MODELS
Default values:
MINIMAX_MODELS=MiniMax-M2.7
OPENAI_MODELS=gpt-5.4,gpt-5.4-mini,gpt-5.4-nano,gpt-4o
If a model is not explicitly listed, it can still route to OpenAI by prefix:
OPENAI_MODEL_PREFIXES=gpt-,o1,o3,o4,codex-,chatgpt-
If a request is missing a model or the model is ambiguous, fallback order is:
DEFAULT_PROVIDER, if set and enabled- OpenAI, if enabled
- MiniMax, if enabled
| Variable | Default | Description |
|---|---|---|
PROXY_PORT |
4000 |
Local listen port |
DEFAULT_PROVIDER |
auto | Fallback provider when model is missing or ambiguous |
MINIMAX_API_KEY |
unset | Enables MiniMax routing |
MINIMAX_BASE_URL |
https://api.minimax.io/v1 |
MiniMax upstream base URL |
MINIMAX_MODELS |
MiniMax-M2.7 |
Models exposed as MiniMax |
OPENAI_API_KEY |
unset | Enables OpenAI routing |
OPENAI_BASE_URL |
https://api.openai.com/v1 |
OpenAI upstream base URL |
OPENAI_MODELS |
gpt-5.4,gpt-5.4-mini,gpt-5.4-nano,gpt-4o |
Models exposed as OpenAI |
OPENAI_MODEL_PREFIXES |
gpt-,o1,o3,o4,codex-,chatgpt- |
Prefix heuristics for OpenAI routing |
OPENROUTER_API_KEY |
unset | Optional search fallback for MiniMax web_search |
OPENROUTER_SEARCH_MODEL |
nvidia/nemotron-3-super-120b-a12b:free |
OpenRouter search model |
GITHUB_TOKEN |
auto via gh auth token |
Used for GitHub API fetches in /cop and web_fetch |
| Method | Path | Description |
|---|---|---|
GET |
/health |
Health summary, enabled providers, default provider |
GET |
/v1/models |
Combined model list from enabled providers |
GET |
/cop?url=... |
Quick URL fetch using Jina/raw HTTP |
POST |
/cop |
URL fetch endpoint with method, headers, and body |
POST |
/v1/responses |
Main Codex-compatible endpoint |
POST |
/v1/chat/completions |
Direct Chat Completions endpoint |
When a request routes to MiniMax, the proxy applies MiniMax-oriented normalization:
systemanddeveloperroles are flattened touser- tool results are reordered so they directly follow their tool calls
reasoning_split: trueis injected- older oversized tool outputs are truncated
- long conversations are trimmed more aggressively
- direct URLs can trigger proxy-side
web_fetch web_searchcan be rerouted to OpenRouter if configured
The proxy can bridge previous_response_id across providers only for responses it has already stored locally.
That means:
- MiniMax -> OpenAI works for stored proxy-managed chains
- OpenAI -> MiniMax works for stored proxy-managed chains
- native Codex/OpenAI outside the proxy -> MiniMax through the proxy is not reconstructable automatically
This repo includes helper scripts so users do not have to remember profile flags.
npm run codex:gpt
npm run codex:minimax
npm run codex:app:gpt
npm run codex:app:minimaxNotes:
codex:minimaxauto-starts the local proxy if needed- the MiniMax launcher disables OpenRouter by default unless you opt in
- if you want MiniMax-side
web_search, run:
CODEX_MINIMAX_USE_OPENROUTER=1 npm run codex:minimax
CODEX_MINIMAX_USE_OPENROUTER=1 npm run codex:app:minimaxFor non-technical users, the easiest path is a desktop launcher that opens Codex in the chosen mode.
npm run install:launchers:macCreates a Codex Launchers folder on the Desktop with:
Codex GPT.commandCodex MiniMax.command
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File .\scripts\install-windows-launchers.ps1Creates a Desktop folder with:
Codex GPT.lnkCodex MiniMax.lnk- matching
.cmdand.ps1launchers
curl http://localhost:4000/health
curl http://localhost:4000/v1/modelsExample health response:
{
"status": "ok",
"proxy": "codex-minimax-proxy",
"providers": ["minimax", "openai"],
"default_provider": "openai"
}- Node.js 18+
- at least one upstream API key: MiniMax and/or OpenAI
MIT