PromptGate 0.4 — changelog
Archived from CHANGELOG.md, which keeps the unreleased changes and the latest release.
0.4.0 - 2026-10-19
Section titled “0.4.0 - 2026-10-19”The end-user release: one key can now serve many people. Each request
names the end user it is for — in the X-PromptGate-User header or in
the provider’s own field the app already sends — and PromptGate logs it,
reports usage per user, limits and budgets every user on their own, and
can tell OpenAI and Anthropic who it is, hashed. Each key decides
whether user ids are optional, required or ignored.
- End users — a request can name the end user it is for: the
X-PromptGate-Userheader, or the provider’s own body field (OpenAIsafety_identifier/user, Anthropicmetadata.user_id), in a configurable order (users.sources). The id shows in the console asuser=…. Each key decides withusers: optional | required | ignore(promptgate keys create --users required), so a backend key must name a user and a key held by end users can’t claim one. An invalid header gets 400 in the client’s error format; the header is never forwarded.users.log: hashedkeeps only a keyed hash. Seedocs/users.md. - Usage per end user — the request log stores the user
(schema v4, migrated on start),
promptgate logs --user <id>filters by it, andpromptgate stats --by user [--key k] [--top n]lists requests, tokens and cost per user from new daily per-user totals, which stay fast with many users and keep forlogging.stats_retention.metrics.user_label: trueadds auserlabel to the request, token and cost counters (off by default: every user is a series).statsalso gains--top n. - Rate limits per end user —
limits.userswith"*"for every user and named ids for exceptions, counted per key and user, checked after the key’s own limit. About 0.1 µs per check and ≈ 130 bytes per active user at 100,000 users. The 429 names no id, so hashed logs stay free of ids. - Budgets per end user —
budgets.userscaps each user per day and month (USD and/or tokens), counted per key and user; 402 until the period resets. Spend is restored after a restart from the daily per-user totals.promptgate budgetslists the users closest to their limits (--top n), and withmetrics.user_labelthe spend gauges include users. - User passed on to the provider —
users.forward: hashed | plainsets OpenAI’ssafety_identifier(Embeddings, Completions:user) or Anthropic’smetadata.user_id, so the provider’s abuse detection can act on one user instead of the whole API key; also after translation. A value the client set is kept; OpenAI-compatible providers get nothing. - Quality gate for end users — the pgfuzz gate runs three new stages
against every build: users are isolated by their per-user limits, a
requiredkey rejects requests without an id, and anignorekey’s ids are never limited.
Changed
Section titled “Changed”- Faster request parsing — reading
modelandstreamfrom a request body now skips long strings 8 bytes at a time: 2.6 GB/s instead of 0.36 GB/s, so a 26 KB agent request spends about 10 µs instead of 70 µs before it is forwarded.
- The rate limiter’s cleanup of idle counters no longer rescans a full shard on every new counter when none of them is idle — with very many active callers, every new one paid a scan of thousands of entries.
Performance
Section titled “Performance”Every v0.3 feature plus every user feature on at once — a user per
request, per-user limits and budgets, hashed log and forwarding
(bench/results/2026-10-19-go-v0.4.0-release.md). Measured on a busy
machine, so v0.3.0 was run alongside:
- Throughput and latency equal to v0.3.0 at 1 client; at 16 clients within 2–8 %, inside the spread of two v0.3.0 runs.
- The user id costs ≈ 30 ns from the header; a per-user rate check ≈ 0.1 µs with 100,000 active users.
- Reading
modelfrom long requests is ≈ 7× faster (2.6 GB/s). - 16.6 MB binary (6.6 MB gzip), ready in 70–90 ms, ≈ 53 MB RAM at idle.