Local translation proxy so Codex and Claude Code can use GreenPT models. GreenPT speaks OpenAI Chat Completions; Codex requires the OpenAI Responses API and Claude Code requires the Anthropic Messages API. This proxy translates both, including streaming and tool calling. One small Rust binary — no Python, no LiteLLM.
Codex ──(/v1/responses)──┐
├── greenpt-proxy ──(/v1/chat/completions)── api.greenpt.ai
Claude Code ─(/v1/messages)┘
cargo install --path .
export GREENPT_API_KEY="your-greenpt-key"
greenpt-proxy # listens on http://127.0.0.1:4000Options: --port N (or PORT env), GREENPT_BASE_URL (default https://api.greenpt.ai/v1).
~/.codex/config.toml (user-level only — project-local provider config is ignored):
model = "glm-5.2"
model_provider = "greenpt"
[model_providers.greenpt]
name = "GreenPT (via greenpt-proxy)"
base_url = "http://localhost:4000/v1"
env_key = "GREENPT_API_KEY"
wire_api = "responses"Restart Codex after config changes. Switch models with codex --model minimax-m2.5.
export ANTHROPIC_BASE_URL="http://localhost:4000"
export ANTHROPIC_AUTH_TOKEN="dummy"
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-5.2"
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-5.2"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="minimax-m2.5"
claudeThe ANTHROPIC_DEFAULT_*_MODEL variables map Claude Code's internal model tiers to
GreenPT model IDs (glm-5.2, minimax-m2.5, kimi-k2.6, kimi-k2.7-code) — the
proxy passes model names through verbatim.
curl -s localhost:4000/v1/messages -H 'content-type: application/json' \
-d '{"model":"glm-5.2","max_tokens":50,"messages":[{"role":"user","content":"Say hi"}]}'
curl -s localhost:4000/v1/responses -H 'content-type: application/json' \
-d '{"model":"glm-5.2","input":"Say hi"}'- Stateless:
previous_response_idis rejected (Codex sends full context each turn). - Unknown request params are dropped, not errored (the
drop_paramsequivalent). - The proxy binds to 127.0.0.1 and does not validate incoming auth headers — the
upstream key comes from
GREENPT_API_KEYonly. Don't expose it beyond localhost. - Token/cost display in the agents is approximate; treat GreenPT's dashboard as the source of truth.