[FEATURE]: Warn users before free tier quota exhaustion instead of silent 429
Verification Checklist
- [x] I have searched existing issues and this is not a duplicate
- [x] I understand this is a feature request, not a bug report
Problem
When using free models (-free suffix) on OpenCode Zen, users hit FreeUsageLimitError (429) with no prior warning. The only feedback is a sudden "Free usage exceeded, subscribe to Go" dialog. This is especially painful for users behind shared IPs (CGNAT, corporate networks), where the quota may be exhausted by other users on the same IP.
Related issues: #15585 #42029 #42128 #33495
Proposal
Add rate-limit response headers to zen API responses so clients can display a warning when quota is running low.
Only include headers when remaining quota is below a threshold (e.g., <20% remaining). This way:
- Users get advance notice before hitting 429
- The exact total limit is never exposed
- The official team retains full control over the numbers
HTTP/1.1 200 OK
X-RateLimit-Remaining: 8
X-RateLimit-Reset: 1786800000
When above the threshold, no headers are returned (current behavior unchanged).
Why not expose on every request?
This keeps the daily limit opaque while still solving the core UX problem: users know they're running low and can plan accordingly, without learning the exact cap.
Implementation scope
| File | Change |
|---|---|
packages/console/app/src/routes/zen/util/ipRateLimiter.ts |
Return counts from check() |
packages/console/app/src/routes/zen/util/handler.ts |
Write headers when remaining < threshold |
packages/opencode/src/session/retry.ts |
Parse headers for early warning (optional) |
Verification
curl -vzen endpoint, verify headers appear when quota is low- Confirm no headers when quota is high (no info leak)
Note on duplicates
This may overlap with #40588 and #41684. Happy to consolidate there instead if preferred.
This issue does not fully meet our contributing guidelines.
What needs to be fixed:
- The title should start with
[FEATURE]:for feature requests (e.g.,[FEATURE]: Warn users before free tier quota exhaustion instead of silent 429) - The Feature Request template requires a verification checkbox confirming you have searched for existing issues — this is missing
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
- #40588: "OpenCode free tier cuts off service mid-task with no warning - expose remaining allowance / add countdown" — requests the same feature: expose remaining quota via headers/warnings before hitting the free-tier limit
- #41684: "Go plan: free-model congestion + silent quota exhaustion stalls all work with no warning" — reports the same silent quota exhaustion problem with a request for advance warnings
If you believe this was flagged incorrectly, please let a maintainer know.
Thank you for updating the issue! It now meets our contributing guidelines. We appreciate you taking the time to provide a clear problem statement and a well-thought-out proposal.
Thanks for updating the issue! It now clearly follows the feature request template with a well-described problem, proposal, and implementation scope. Everything looks good — appreciate the thorough write-up!
+1
Thanks for the detailed proposal, @thumb2086! Your request is that the Zen API sends a low-quota signal before the free-tier limit runs out, for example X-RateLimit-Remaining / X-RateLimit-Reset headers returned only below a threshold. Clients could then warn you ahead of time instead of hitting a sudden FreeUsageLimitError (429). Maintainers will consider it.
This needs a change on the Zen server, so it can't be done with a plugin today: the API doesn't currently return any remaining-quota information for a client or plugin to read.
Related issues:
- #40588: same request (headers or a warning before the free-tier cutoff). It was closed automatically for inactivity, not rejected, so this issue picks it up.
- #41684: silent quota exhaustion with no warning (Go plan and free models).
- #16017: a Go plan usage/balance API endpoint (a related way to expose quota).
- #15585, #42029, #42128, #33495: reports of hitting
FreeUsageLimitErrorunexpectedly.
+1 — free-tier quota is invisible until the request fails
Same experience as the original report, adding a data point from opencode 2.2.5 (macOS, desktop CLI 2.3.0).
What happens
Mid-session, the next turn dies with no prior signal:
AI.Error.QuotaExceeded: Free usage limit reached. Free models work in OpenCode
(https://opencode.ai); subscribe to OpenCode Go to keep going: https://opencode.ai/go
Captured from the local log (~/.local/share/opencode/log/opencode.log, level=ERROR,
message="Failed to drain Session"). There is no percentage, no remaining count, no
reset time, and nothing in the prompt bar or model selector that distinguishes a
free model from a paid one before it breaks.
Why it is worse for free-tier users specifically
- Free models are the default for users who have not added credits, so hitting the wall is the first feedback they get.
- The quota appears to be per-IP, not per-account (#42765 already notes CGNAT/shared-IP cases). That means the number can drop for reasons the user cannot see or control, making "you used too much" an unfair and untraceable message.
- Docs publish no number for any free model except LongCat 2.5 Free (100 req/day), so users cannot even estimate how much runway they have.
Suggestion (in addition to the headers proposed above)
- Reuse the existing
GET /api/experimental/usage/limitsendpoint (already present in the local server; currently returns401 Authentication requiredand is undocumented) and surface it in the TUI/desktop. - Show a low-quota warning in the prompt bar (< 20% remaining) with the reset time, and a one-keystroke "switch model" action — the failure is not the problem, the silent failure is.
- Mark free models with a "free" badge plus remaining quota in
/modelsso users can pick a different free model instead of being forced to subscribe. - At minimum, make the 429 message actionable: include reset time and the name of a free model that still has quota.
Related: #64334 (same symptom, new session fails with 429), #63916 (CLI command to check remaining limits), #62374 (Usage panel shows context fill, not account usage).
Additional data point for opencode-go/hungerg-free: the model is listed as active with $0 pricing, but no usage cap or reset information is shown. On 2026-11-23, a request failed with AI.Error.QuotaExceeded: Free usage limit reached...; the only recovery offered was subscribing to Go.
Local log:
timestamp=2026-11-23T15:33:02.544Z level=ERROR message="Failed to drain Session" cause="AI.Error.QuotaExceeded: Free usage limit reached..."
Environment: OpenCode Desktop 2.4.2, Windows 11 Pro 10.0.26300 (x64), xterm-256color, cmd.exe, no plugins configured.
Expected: disclose the free usage limit before use, or at least warn before it is reached and include the reset time in the error.