Nottybro commited on
Commit
8c37db9
·
1 Parent(s): 419a331

Add daily token cap: 2.5M tokens per UTC day

Browse files

- Counts total_tokens from upstream usage (exact for both stream and
non-stream; stream sniffed via injected stream_options.include_usage)
- chars/4 estimate fallback when upstream omits usage
- Pre-check (used + prompt estimate) rejects with 429 once cap hit
- Counter persists to tempdir (survives app restart; container rebuild resets)
- DAILY_TOKEN_CAP env override; / and /health show today's usage

1 file changed +103 -4
app.py+103-4