You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-6Lines changed: 49 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,10 @@ Run it as a full **PostgreSQL + Redis** production stack or as a single-containe
23
23
24
24
<table>
25
25
<tr><tdwidth="210"><b>One compatible gateway</b></td><td>OpenAI-style Chat Completions / Responses / Images, Anthropic Messages, prefixless compatibility routes, and native Codex Responses forwarding are all exposed through one service.</td></tr>
26
-
<tr><td><b>Account-pool scheduler</b></td><td>Selection is driven by account status, health tier, scheduler score, dynamic concurrency, cooldown recovery, and recent usage so unhealthy accounts are avoided automatically.</td></tr>
27
-
<tr><td><b>Visual admin console</b></td><td>The embedded React / Vite dashboard covers account import and testing, API keys, proxy pools, image studio, prompt filtering, usage analytics, operations, scheduler board, and system settings.</td></tr>
28
-
<tr><td><b>Two deployment shapes</b></td><td>Use PostgreSQL + Redis for production or SQLite + Memory for lightweight single-node deployments; Docker images, source builds, local development, and the interactive deploy script are ready to use.</td></tr>
26
+
<tr><td><b>Account-pool scheduler</b></td><td>Selection is driven by account status, health tier, scheduler score, dynamic concurrency, cooldown recovery, and recent usage so unhealthy accounts are avoided automatically. Supports <code>round_robin</code> and <code>remaining_quota</code> modes, with per-account credit billing flags.</td></tr>
27
+
<tr><td><b>Visual admin console</b></td><td>The embedded React / Vite dashboard covers account import and testing, API keys, proxy pools, image studio (text-to-image + image-to-image), prompt filtering, usage analytics, operations, scheduler board, and system settings.</td></tr>
28
+
<tr><td><b>Two deployment shapes</b></td><td>Use PostgreSQL + Redis for production or SQLite + Memory for lightweight single-node deployments; Docker images, source builds, local development, and the interactive deploy script are ready to use. SQLite mode binds to <code>127.0.0.1</code> by default for security.</td></tr>
29
+
<tr><td><b>Billing and observability</b></td><td>Per-account 5h/7d windowed USD cost tracking, credit quota support, API key usage tracking, OAuth PKCE token acquisition, prompt filtering, and a usage dashboard with request logs and trend charts.</td></tr>
29
30
</table>
30
31
31
32
---
@@ -164,6 +165,7 @@ Notes:
164
165
- Standard and SQLite modes both read `.env`.
165
166
- Before switching deployment modes, replace `.env` with the matching example file.
166
167
- The SQLite lightweight mode runs a single `codex2api` container and stores data at `/data/codex2api.db`.
168
+
-**SQLite compose files bind to `127.0.0.1` by default for security.** To expose the SQLite service on all interfaces, set `BIND_HOST=0.0.0.0` in `.env` or override the port binding in the compose file. The standard compose files bind to `0.0.0.0` by default.
167
169
- The image studio library is stored under `/data/images`; Docker configurations persist `/data`.
168
170
-`docker compose down` does not delete named volumes by default. Data is removed only by commands such as `docker compose down -v`, `docker volume rm`, or `docker volume prune`.
169
171
@@ -262,7 +264,7 @@ The standard `.env.example` declares `DATABASE_DRIVER=postgres` and `CACHE_DRIVE
262
264
263
265
Runtime business settings are stored in the database `SystemSettings` table and can be updated from the admin settings page.
264
266
265
-
Examples include `MaxConcurrency`, `GlobalRPM`, `TestModel`, `TestConcurrency`, `ProxyURL`, `PgMaxConns`, `RedisPoolSize`, `AdminSecret`, and auto-cleanup switches.
267
+
Examples include `MaxConcurrency`, `GlobalRPM`, `TestModel`, `TestConcurrency`, `ProxyURL`, `PgMaxConns`, `RedisPoolSize`, `AdminSecret`, `SchedulerMode`, and auto-cleanup switches.
266
268
267
269
Default settings are written automatically on first startup.
268
270
@@ -284,9 +286,11 @@ Default settings are written automatically on first startup.
|`GET /v1/models`| List available models (includes gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.3-codex, gpt-image-2, etc.) |
288
290
|`GET /health`| Health check |
289
291
292
+
> **Pricing**: gpt-5.5 is billed at $5.00/M input and $30.00/M output (standard tier). Priority tier: $12.50/M input, $75.00/M output. Other models follow pricing rules in the billing engine.
293
+
290
294
See [API.md](docs/API.md) for full request formats, response formats, and error codes.
291
295
292
296
### Token Upload and Account Management
@@ -349,6 +353,27 @@ curl -X POST http://localhost:8080/api/admin/accounts/import \
349
353
350
354
Import endpoints deduplicate tokens automatically. Existing tokens are not inserted again.
351
355
356
+
#### OAuth PKCE Authorization
357
+
358
+
Codex2API supports acquiring Refresh Tokens through the OAuth PKCE flow, useful when manual token extraction is impractical:
359
+
360
+
```bash
361
+
# Step 1: Generate an authorization URL
362
+
curl -X POST http://localhost:8080/api/admin/oauth/generate-auth-url \
363
+
-H "X-Admin-Key: your-admin-secret" \
364
+
-H "Content-Type: application/json" \
365
+
-d '{}'
366
+
367
+
# Step 2: Open the returned auth_url in a browser, complete authorization
368
+
# Step 3: Exchange the authorization code for a token (auto-creates account)
369
+
curl -X POST http://localhost:8080/api/admin/oauth/exchange-code \
| Operations |`/admin/ops`| Runtime monitoring and system overview |
@@ -431,6 +456,24 @@ Observability:
431
456
-`GET /api/admin/ops/overview` shows runtime and connection pool state.
432
457
-`/admin/ops/scheduler` provides the scheduler board.
433
458
459
+
**Scheduler mode** (`scheduler_mode`, via Admin Settings):
460
+
461
+
| Mode | Behavior |
462
+
| --- | --- |
463
+
|`round_robin` (default) | Round-robin across available accounts per health tier, weighted by dispatch score |
464
+
|`remaining_quota`| Prioritizes accounts with lower usage percent; round-robin for ties |
465
+
466
+
**Credit accounts** (per-account flags):
467
+
468
+
When an account has a credit-based billing model instead of a usage-based Free/Pro plan, you can mark it so the scheduler skips usage-window penalties:
469
+
470
+
| Field | Type | Effect |
471
+
| --- | --- | --- |
472
+
|`credit_enabled`| bool | Mark account as credit-based billing |
473
+
|`credit_skip_usage_window`| bool | When true, skip 7d/5h usage-window penalties for this account |
474
+
475
+
**Windowed USD cost**: The accounts table displays per-account billed cost over two windows -- the past 5 hours and the past 7 days -- aligned with each account's usage reset boundaries. This shows actual spending per account rather than estimated token costs.
0 commit comments