Skip to content

[Feature]: Show Mistral API and Vibe budget usage from /v1/billing/budget #8290

Closed

Description

@lidge-jun

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):

  1. GET https://api.mistral.ai/v1/billing/budget with the configured key (x-api-key or Authorization: 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.
  2. GET /v1/billing/subscription for plan_name (FREE / INDIVIDUAL / EDU / TEAM), payg_enabled, vibe_payg_enabled, enterprise, cached with the budget.
  3. Render two windows: "API budget" and "Vibe budget", each as percent used with reset time and the currency amount (usage_percentage × initial_budget of initial_budget). Label the plan. When initial_budget is 0 or the currency is null, show the window as unknown, never as 0% left.
  4. Cache like the other key probes (about 5 minutes, manual refresh), treat 401/403 (missing see_org_inference_usage permission) as "quota unavailable for this key", and never log the key.
  5. 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

  1. added
    enhancement
    provider
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementprovider

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions