Repository navigation
Description
Area
Provider adapters
What are you trying to accomplish?
See how much of my Mistral plan is left (API budget and Vibe Code budget, with reset date and plan name) in the dashboard quota bar and provider quota report, the same way OpenRouter, DeepSeek, Moonshot, Z.ai and MiniMax keys already show a balance.
What prevents this today?
The Mistral provider has no quota probe. src/providers/mistral-transport.ts reads x-ratelimit-*-minute/-month headers only to classify a 429 as temporary vs unknown; nothing surfaces remaining budget, so a plan key (for example one created from Vibe Code CLI) silently hits its monthly budget and then fails with 402.
What should OpenCodex do?
Add a key-scoped Mistral quota probe in src/providers/quota/vendor-probes-key.ts (canonical https://api.mistral.ai base URL only):
GET https://api.mistral.ai/v1/billing/budgetwith the configured key (x-api-keyorAuthorization: Bearer, both verified to return 200 with a standard inference key on 2026-11-07). Response shape:{api_budget, vibe_budget}where each is{usage_percentage (0-100), initial_budget, currency|null, reset_at (ISO), payg_enabled}, plus top-level mirror fields.GET /v1/billing/subscriptionforplan_name(FREE / INDIVIDUAL / EDU / TEAM),payg_enabled,vibe_payg_enabled,enterprise, cached with the budget.- Render two windows: "API budget" and "Vibe budget", each as percent used with reset time and the currency amount (
usage_percentage × initial_budgetofinitial_budget). Label the plan. Wheninitial_budgetis 0 or the currency is null, show the window as unknown, never as 0% left. - Cache like the other key probes (about 5 minutes, manual refresh), treat 401/403 (missing
see_org_inference_usagepermission) as "quota unavailable for this key", and never log the key. - Map Mistral 402 responses to an out-of-budget quota state distinct from 429 rate limiting.
Example usage or interface
Dashboard Providers / quota bar: Mistral API 0% · Vibe 2% (resets Dec 1) · Education. ocx provider quota report shows the same two windows.
Alternatives or workarounds
The Admin API (/v1/admin/usage, /spend-limit, /rate-limit) is Enterprise-only and rejects standard keys. Console routes under admin.mistral.ai/api/billing/v2/* need a browser session cookie and already drifted once. X-RateLimit-Remaining is documented only in prose, is absent from the OpenAPI spec, and covers per-minute limits, not the plan budget.
Additional context
Sources: Mistral OpenAPI spec https://docs.mistral.ai/openapi.yaml (billing_api_public_get_budget, billing_api_public_get_subscription, security DashboardContextAuth); 402-on-exhausted-balance in https://docs.mistral.ai/admin/billing-usage/billing. Live check on 2026-11-07 with an Education plan key returned 200 with exactly the spec's fields. Prior art: CLIProxyAPI declarative quota_probe (internal/api/handlers/management/plugin_quota.go), CodexBar.
Activity