Codex-LB - Load Balancer cho ChatGPT
Codex/ChatGPT account load balancer & proxy với usage tracking, dashboard, và OpenCode-compatible endpoints. Pool nhiều tài khoản ChatGPT, theo dõi usage, quản lý API keys.

Tính năng
| Tính năng | Mô tả |
|---|---|
| Account Pooling | Load balance across multiple ChatGPT accounts |
| Usage Tracking | Per-account tokens, cost, 28-day trends |
| API Keys | Per-key rate limits by token, cost, window, model |
| Dashboard Auth | Password + optional TOTP |
| OpenAI-compatible | Codex CLI, OpenCode, any OpenAI client |
| Auto Model Sync | Available models fetched from upstream |
Cài đặt nhanh
Docker (Khuyến nghị)
# Tạo volume và chạy container
docker volume create codex-lb-data
docker run -d --name codex-lb \
-p 2455:2455 -p 1455:1455 \
-v codex-lb-data:/var/lib/codex-lb \
ghcr.io/soju06/codex-lb:latest
# Hoặc dùng uvx
uvx codex-lb
Mở localhost:2455 → Thêm tài khoản → Xong!
Kubernetes
helm install codex-lb oci://ghcr.io/soju06/charts/codex-lb \
--set postgresql.auth.password=changeme \
--set config.databaseMigrateOnStartup=true \
--set migration.schemaGate.enabled=false
kubectl port-forward svc/codex-lb 2455:2455
Kết nối với OpenCode
Cấu hình OpenCode
Edit ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "http://127.0.0.1:2455/v1",
"apiKey": "{env:CODEX_LB_API_KEY}"
},
"models": {
"gpt-5.4": {
"name": "GPT-5.4",
"reasoning": true,
"options": { "reasoningEffort": "high", "reasoningSummary": "detailed" },
"limit": { "context": 1050000, "output": 128000 }
},
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex",
"reasoning": true,
"options": { "reasoningEffort": "high", "reasoningSummary": "detailed" },
"limit": { "context": 272000, "output": 65536 }
},
"gpt-5.1-codex-mini": {
"name": "GPT-5.1 Codex Mini",
"reasoning": true,
"options": { "reasoningEffort": "high", "reasoningSummary": "detailed" },
"limit": { "context": 272000, "output": 65536 }
},
"gpt-5.3-codex-spark": {
"name": "GPT-5.3 Codex Spark",
"reasoning": true,
"options": { "reasoningEffort": "xhigh", "reasoningSummary": "detailed" },
"limit": { "context": 128000, "output": 65536 }
}
}
}
},
"model": "openai/gpt-5.3-codex"
}
Quan trọng: Sử dụng built-in
openaiprovider vớibaseURLoverride — không dùng custom provider với@ai-sdk/openai-compatible. Custom providers dùng Chat Completions API sẽ mất reasoning/thinking content.
Chạy OpenCode
# Export API key từ dashboard
export CODEX_LB_API_KEY="sk-clb-..."
# Chạy OpenCode
opencode
Kết nối với Codex CLI
Edit ~/.codex/config.toml:
model = "gpt-5.3-codex"
model_reasoning_effort = "xhigh"
model_provider = "codex-lb"
[model_providers.codex-lb]
name = "OpenAI" # required — enables remote /responses/compact
base_url = "http://127.0.0.1:2455/backend-api/codex"
wire_api = "responses"
supports_websockets = true
requires_openai_auth = true # required for codex app
Kết nối với OpenAI Python SDK
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:2455/v1",
api_key="sk-clb-...", # from dashboard, or any non-empty string if auth is disabled
)
response = client.chat.completions.create(
model="gpt-5.3-codex",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
API Key Authentication
API key auth disabled by default. Khi enable trong Settings → API Key Auth, clients phải pass key như Bearer token:
Authorization: Bearer sk-clb-...
Dashboard Authentication
Local access (localhost)
Không cần bootstrap token.
Remote access
Lần đầu truy cập dashboard remote, cần bootstrap token từ logs:
docker logs codex-lb
# ============================================
# Dashboard bootstrap token (first-run):
# <token>
# ============================================
Data
| Environment | Path |
|---|---|
| Local / uvx | ~/.codex-lb/ |
| Docker | /var/lib/codex-lb/ |
Backup thư mục này để preserve data.
Links
- 🌐 GitHub: github.com/Soju06/codex-lb
- 📦 Docker:
ghcr.io/soju06/codex-lb:latest - ⭐ Stars: 1072+