Skip to content

Per-provider quota integration (real data, not mock) #132

Description

@yacosta738

Context

Follow-up to the providers UI 3-screen refactor (commit b1eb991) which shipped a placeholder /providers/quota view.

Current state

  • /providers/quota exists and renders a mock summary table
  • Shows: provider kind, connection count, configured models, active/not-configured status
  • Banner: "Per-provider quota tracking is in development. Each provider exposes quota differently."

Goal

Replace the mock data with REAL per-provider quota data.

Why this is hard

Each provider exposes quota differently:

  • OpenAI: account-level hard limits in dashboard, per-organization tier (free/team/enterprise). No public quota API; usage comes from response headers.
  • Anthropic: workspace-level limits in console. No public quota API.
  • Google Gemini: generateContent returns usageMetadata with prompt/candidate token counts, no rate-limit info in body.
  • Groq: returns rate limit headers (x-ratelimit-remaining-requests, x-ratelimit-remaining-tokens).
  • Ollama: no quota (self-hosted), view should degrade gracefully.

Suggested approach

  1. Define a Quota port in rook-core (or extend ProviderPort):
    #[async_trait]
    pub trait QuotaPort: Send + Sync {
        async fn current_usage(&self) -> Result<QuotaSnapshot, CortexError>;
    }
  2. Per-provider implementations wrapping actual usage data:
    • HTTP providers: parse rate-limit headers from last response
    • Local: return None or "local/no quota" stub
  3. Background poller that snapshots every N minutes (similar to health_check)
  4. Storage layer for historical quota data (extend audit-sqlite or new quota-sqlite crate)
  5. Wire to existing usage_recorder — we already record token counts per request; that's the source of truth for "how much I've used". The quota port would aggregate.

Acceptance

  • /providers/quota shows real per-provider data (not mock)
  • Graceful degradation for providers without quota APIs
  • Historical data shown over time (chart or trend)
  • Warnings when usage approaches limits
  • Banner removed from the view

Related

  • Spec: openspec/changes/providers-ui-3-screen-refactor/specs/providers-ui/spec.md REQ-8
  • Design: openspec/changes/providers-ui-3-screen-refactor/design.md section D7
  • Code marker: TODO(issue-XXX) in apps/rook/dashboard/src/views/ProvidersQuotaView.vue

Estimate

Large — 1-2 week piece of work touching 4-5 crates (rook-core, rook-usecases, transport-axum, providers-*, audit-sqlite or new quota-sqlite).

Metadata

Metadata

Assignees

Labels

area/providersProvider integrations (OpenAI, Anthropic, etc.)priority/lowLow priority issue or PR

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions