james-6-23/codex2api

Codex2API 是一个基于 Go + Gin + React/Vite 的 Codex 反向代理与管理后台项目

What it solves

Managing many Codex accounts individually is a pain. Codex2API lets you pool those accounts into a single, always-running service that exposes standard OpenAI and Anthropic API endpoints. Instead of juggling tokens, rate limits, and unhealthy accounts yourself, the gateway handles them automatically, so any compatible client (like the OpenAI SDK, Claude Code, or the Codex CLI) can just point at one URL and get reliable, monitored access.

How it works

Codex2API runs as a long-lived service. You upload your Refresh Tokens / Access Tokens into its account pool. Behind the scenes, it tracks each account's health, usage, and concurrency, and it automatically picks the best account for each request using scheduling modes like round-robin or remaining quota. It detects rate limits and cooldowns, avoids unhealthy accounts, and tracks cost. The gateway exposes standard endpoints (chat completions, responses, images, videos, models) and forwards them to the underlying Codex accounts. It also includes a built-in web dashboard for managing accounts, API keys, proxies, prompts, and settings. You can run it in two deployment styles: a full production stack with PostgreSQL and Redis, or a lightweight single-container version using SQLite and in-memory cache.

Who it's for

Developers or teams who already have multiple Codex accounts and want to share them among tools, automate their use, or monitor them from one place. It's also for self-hosting enthusiasts who want an OpenAI/Anthropic-compatible gateway without paying per-token proxy fees, and for anyone who needs image/video generation via Grok Imagine in addition to text.

Highlights

  • One service exposes OpenAI-style Chat Completions, Responses, Images, plus Anthropic Messages and Grok video endpoints.
  • Account pool scheduler picks the healthiest account based on health tier, dynamic concurrency, cooldown recovery, and usage.
  • Built-in React/Vite admin dashboard covers account import and testing, API keys, proxy pools, image studio, prompt filtering, usage analytics, and system settings.
  • Two deployment shapes: PostgreSQL+Redis for production, or SQLite+memory for a single-node lightweight setup.
  • Billing and observability: per-account USD cost tracking, credit quotas, API key usage logs, and a usage dashboard with trends.
  • A quality check tool that uses a "pelican on a bicycle" animation challenge to compare selected accounts, models, and reasoning effort.
  • Optionally supports an experimental Antigravity (Google) channel with its own OAuth and API key handling.

Related

  • Project
  • Project
  • Project
  • Project
  • Project