OpenAI-compatible local API gateway powered by Codex CLI and built with Hono.
bun(runtime and package manager)codexCLI installed and available in yourPATH, or configured viaCODEX_BIN
- Install dependencies.
bun install- Create your environment file.
cp .env.example .env- Start the API server.
bun run startDefault server address: http://127.0.0.1:8787
GET /healthGET /v1/modelsGET /v1/models/:modelPOST /v1/chat/completions
OPENAI_COMPAT_HOST: Server bind host (default:127.0.0.1).OPENAI_COMPAT_PORT: Server bind port (default:8787).OPENAI_COMPAT_TOKEN: Optional bearer token for/v1/*routes.CODEX_BIN: Codex CLI binary name or absolute path (default:codex).CODEX_DEFAULT_MODEL: Fallback model when the request does not includemodel(default:gpt-5-codex).CODEX_MODELS: Comma-separated list of models exposed by/v1/models.CODEX_REASONING_EFFORT: Reasoning effort for Codex (default:medium; options:none,minimal,low,medium,high,xhigh).CODEX_SYSTEM_PROMPT: Default system prompt prepended to each request. You can override it per request withsystem_prompt.CODEX_EXEC_TIMEOUT_MS: Codex execution timeout in milliseconds (default:180000).CODEX_SANDBOX: Codex sandbox mode (default:read-only).
curl -s http://127.0.0.1:8787/healthcurl -s http://127.0.0.1:8787/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-codex",
"system_prompt": "you are a chatbot. answer directly with code, no tool or filesystem notes.",
"messages": [
{"role":"user","content":"write hello world in go"}
]
}'- Repository: dorangao/article-scripts/local-routers
- Article: Solo Devs: Build a Local AI Router (OpenAI Compatible) that Uses OpenClaw and Codex OAuth Instead
Issues and pull requests are welcome. Please keep changes focused, follow the existing project style, and include clear reproduction steps for bug fixes.
This project is licensed under the MIT License. See LICENSE.