Repository navigation
fix(4.x): Zen member budgets and Ollama balance API - #328
Merged
Merged
Conversation
OpenCode Console retired GET /api/budgets/org (it answers 409), so the
Zen monthly budget showed an error row. Read
GET /api/policies/members/{account id} for the signed-in Console user
instead.
- Carry the active account id from OpenCode's account table. OpenCode
1 stores the Console user id there (the id from GET /api/user).
- Trust the member response only when its userID matches. Show the
applicable monthly budget with the least remaining USD; a $0 member
budget is a blocking 0% budget. Dollar amounts convert to the
existing billing units.
- Member budgets reset at 00:00 UTC on the 1st of the next month.
- If any member budget cannot be safely evaluated (model filter,
per-model limit, unmatched rule, missing amount), use no member
budget: fall back to the credit limit with no error row, and
/quota_status shows member_budget_note.
- Errors name policies/members without the account id; network errors
redact the id and its URL encoding.
- The Zen cache identity includes the account.
Backport of 8e646e6, 8876945 and f15670d from main. 4.x has no
budgetSource field: a member budget is the only source that sets the
reset date, so the provider uses that to keep a $0 member budget.
Refs #320
Co-authored-by: Victor M Varela <vmvarela@gmail.com>
GET https://ollama.com/api/usage no longer returns limits, so Ollama Cloud showed "returned no usable usage data". Read the documented GET https://ollama.com/api/balance with a Bearer API key instead. - Credit plans: a Monthly row with the included credits left and the period's end as its reset time. - Legacy plans: Session and Weekly rows from remaining_percent, with their reset times. - Purchased credits: a "Purchased: $25.00 left" row when there are some, or when Ollama returns nothing else. - /quota_status lists the included, session, weekly and purchased values instead of the old usage fractions. Backport of 15dfc70e2 from main. Docs keep the 4.x prose layout. Refs #321
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backports two provider fixes from main to the 4.x (OpenCode 1) line.
budgets/org(it now returns 409), so the monthly budget was missing. Zen now reads the signed-in member's budget frompolicies/members/{account id}and shows the most restrictive applicable monthly budget, including a shared workspace cap, with its reset at 00:00 UTC on the 1st of next month. If a budget can't be safely evaluated (model filters, per-model limits, missing amounts), it uses the credit limit with no error line, and/quota_statusshows amember_budget_note. The account id comes from OpenCode 1's active Console account and never appears in error or status text. Backport of fix(opencode-zen): use applicable member budget #322 by @vmvarela./api/usageno longer returns limits, so Ollama showed "no usable usage data". It now readsGET https://ollama.com/api/balancewith a Bearer key: Session and Weekly with reset times on older plans, a Monthly row for included credits on credit plans, andPurchased: $X.XX leftwhen purchased credit remains.Linked Issue
Refs #320, refs #321.
OpenCode Validation
opencode-ai). The Zen account id was checked against its source (packages/opencode/src/account/account.tsat v1.19.0):account.idis the Console user id fromGET /api/user, the id the members route expects.Before-and-after evidence
Not applicable for screenshots: no live Console or Ollama account was available, so both fixes are covered by recorded replies in tests. Row names and labels are unchanged except the new
Purchased: $X.XX leftrow and the new Monthly row for Ollama credit plans.Quality Checklist
pnpm verify