Repository navigation
feat: show Mistral subscription budget in /usage and the footer - #3
Open
postpersonality wants to merge 1 commit into
Open
postpersonality wants to merge 1 commit into
postpersonality wants to merge 1 commit into
Conversation
A Mistral plan is a monthly budget shared by Studio, the API and Vibe Code, not a window of requests, so the provider needs its own adapter. Usage comes from the billing endpoints Vibe Code reads, `GET /v1/billing/subscription` and `GET /v1/billing/budget` on api.mistral.ai. `/usage` lists the Vibe Code and API budgets in dollars with the reset date, the plan and whether pay-as-you-go is on. The footer tracks the Vibe Code budget, where subscription sign-in requests are counted; an account with only an API budget falls back to that one. The adapter answers to `mistral`, which pi-mistral-subscription 0.2.0 registers, and to the deprecated `mistral-subscription` id of earlier releases. A key without the `see_org_inference_usage` permission, or a platform that does not serve billing, reports `Unsupported` with the reason instead of a generic "not supported yet" message. A failing plan read only drops the plan line. Budget amounts in a currency other than USD stay percentages with the allowance in their own currency, and USD amounts now print with a dollar sign in /usage.
postpersonality
force-pushed
the
fix/mistral-subscription-usage
branch
from
November 16, 2026 22:12
67385fc to
a5be50e
Compare
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.
Fixes #2.
/usageansweredUnsupported: mistral is not supported yet.for a configured Mistral subscription, because no adapter answered to themistralprovider id. The quota is reachable: Mistral serves the same billing endpoints Vibe Code reads,GET /v1/billing/subscriptionandGET /v1/billing/budgetonapi.mistral.ai, and a subscription key can read them.Footer:
1m 100% ↻14d2h.What changed
src/providers/mistral.ts: normalizes the two monthly budgets intoUsageBuckets. A plan is a budget, not a window of requests, so the buckets carry dollars (unit: "usd") with the reset date, and the plan and pay-as-you-go state become account metrics. A currency other than USD keeps the exact percentage and shows the allowance in its own currency instead of mislabelling it as dollars.src/query.ts: amistraladapter for the provider idsmistral(pi-mistral-subscription 0.2.0 and later) and the deprecatedmistral-subscription(earlier releases). The footer tracks the Vibe Code budget, where subscription sign-in requests are counted; an account with only an API budget falls back to it. A budget endpoint answering 403 (nosee_org_inference_usagepermission) or 404 (platform without billing) reportsUnsupportedwith the reason, and any other failure stays an error rather than a silent zero. A failing plan read only drops the plan line; its handler is attached immediately, as the Antigravity adapter does.src/format.ts: a bucket withunit: "usd"printed0.22/300without a currency. It now formats throughformatValue, so it reads$0.22/$300.00; other units are unchanged.test/mistral.test.ts: 12 tests covering normalization, the footer group, the legacy top-level budget, the deprecated provider id, a non-USD budget, a missing permission, a failing plan read and a failing budget endpoint.README.md,README.zh-CN.md,package.json: Mistral in the provider table, a provider note with the permission caveat, and the package description and keywords.Verification
node --test test/*.test.ts: 128 pass, 1 fail. The failure istest/claude-bridge.test.ts"extension shows observed Claude usage without any request", which also fails onmainat cff2bdd (its fixture resets are in the past, so the windows read 100%); this branch does not touch it.pi --no-extensions --offline -e ./index.ts --list-modelsloads the extension.Notes for review
requiresOAuth: an API key without the usage permission gets theUnsupportedmessage above instead of an auth error.INDIVIDUAL,TEAMandENTERPRISEto their display names and passes anything else through.