Soju06/codex-lb

Codex/ChatGPT multiple account load balancer & proxy with usage tracking, dashboard, and OpenCode-compatible endpoints

codex‑lb – Load‑balancer & proxy for ChatGPT accounts

What it is

  • A self‑hosted service that sits between OpenAI‑compatible clients (Codex CLI, OpenCode, the official OpenAI Python SDK, etc.) and one or more ChatGPT accounts.
  • It distributes requests across a pool of accounts, tracks token usage and cost per account, and lets you enforce per‑API‑key rate limits.
  • All of this is visible in a web dashboard with authentication (password + optional TOTP).

Key features

Feature What it does
Account pooling Register several ChatGPT accounts; the proxy picks the best one for each request, effectively increasing overall quota.
Usage tracking Stores per‑account token counts, cost, and 28‑day trends in a SQLite (default) or PostgreSQL database.
API‑key management Create keys with custom limits (tokens, cost, time window, model) to protect the proxy when exposing it to other users or services.
OpenAI‑compatible endpoints Provides /v1 and /backend-api/codex endpoints that work with any client expecting the official OpenAI API.
Dashboard Web UI (default at http://localhost:2455) showing accounts, usage graphs, and key management.
Auto model sync Pulls the list of available models from OpenAI so the proxy always knows what each account can serve.
Deployable anywhere Docker image, uvx one‑liner, or Nix package; also supports Kubernetes deployment.

Quick start (Docker, the recommended way)

# create a persistent volume for the SQLite DB
docker volume create codex-lb-data
# optional: isolated network for the container
docker network create codex-lb-net
# run the latest image
docker run -d --name codex-lb \
  --network codex-lb-net \
  -p 2455:2455 -p 1455:1455 \
  -v codex-lb-data:/var/lib/codex-lb \
  ghcr.io/soju06/codex-lb:latest

Open http://localhost:2455, add your first ChatGPT account, and you’re ready to point any client at the proxy.

Client configuration example (Codex CLI)

model = "gpt-5.6-sol"
model_reasoning_effort = "xhigh"
model_provider = "codex-lb"

[model_providers.codex-lb]
name = "openai"
base_url = "http://127.0.0.1:2455/backend-api/codex"
wire_api = "responses"
supports_websockets = true
requires_openai_auth = true

Similar setup steps exist for OpenCode, OpenClaw, the official OpenAI Python SDK, and other tools – all documented at https://soju06.github.io/codex-lb/.

Configuration

  • Settings are read from environment variables prefixed with CODEX_LB_ or a .env.local file. An example file (.env.example) is provided.
  • SQLite is used out‑of‑the‑box (/var/lib/codex-lb/ in Docker). For larger deployments you can point CODEX_LB_DATABASE_URL to a PostgreSQL instance.

Development

  • Run the backend with uv run codex-lb (listens on port 2455).
  • The frontend (React/Vite) lives in frontend; start it with bun run dev (port 5173) for hot‑reloading.
  • Docker Compose watch mode and Nix flakes are also supported.

Why you might want it

  • Extend quota: If you have several personal or team ChatGPT accounts, codex‑lb lets you use them as a single logical API endpoint.
  • Cost visibility: See exactly how many tokens each account consumes and the associated monetary cost.
  • Safety: Issue limited‑scope API keys to teammates or CI pipelines, preventing a single user from exhausting the whole pool.
  • Compatibility: No code changes required for existing OpenAI‑compatible tools – just point them at the new base URL.

Further reading

  • Full docs, troubleshooting, and deployment guides: https://soju06.github.io/codex-lb/.
  • Community‑made status‑bar integrations for macOS, Linux, Home Assistant, etc., listed in the README.

Related

  • Project
  • Dispatch
  • Project
  • Project
  • Project