Skip to content

feat: per-provider credit balance reporting in observability hooks #25

@stackbilt-admin

Description

@stackbilt-admin

Summary

llm-providers should expose per-provider credit/balance visibility through its existing observability hooks surface. Currently AEGIS has no real billing data — SENTINEL alerts about negative credits are heuristic guesses with no ground truth.

Motivation

  • AEGIS SENTINEL flagged "AI credit balance is negative (-50)" with no actual billing data backing it
  • Each provider exposes usage/billing APIs that llm-providers already has credentials for
  • This is a natural extension of the existing circuit breaker + observability hooks — not a new concept

Providers & APIs

Provider Endpoint Notes
Anthropic GET /v1/usage Token counts by model
Groq Usage API Generous free tier
Workers AI CF API Free tier — usage metrics via CF dashboard API
Brave Response headers Monthly quota in X-RateLimit-Remaining

Proposed Surface

  • getProviderBalance(provider?) — returns current credit/quota state per provider
  • Wire into existing health/stats reporting so consumers (AEGIS, dashboards) can query balance without custom integrations
  • Optionally emit low-balance warnings through the existing hook system

Acceptance Criteria

  • At least Anthropic + Groq balance reporting implemented
  • Exposed through observability hooks (same pattern as existing metrics)
  • AEGIS can consume via service binding or direct import

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions