Skip to content

byApiKey usage statistics are inaccurate / miscalculated #2712

Description

@H-TWINKLE

Environment (please complete the following information):

9Router version: v0.5.35

Image

Describe the bug

The usage statistics aggregated under stats.byApiKey in the /api/usage/stats endpoint (or the dashboard UI that consumes it) appear to be incorrect. The token counts, cost breakdowns, or request metadata associated with individual API keys do not match the actual usage.

To Reproduce

Steps to reproduce the behavior:

Send a series of requests using different API keys (or the same key) to various upstream providers.

Call the /api/usage/stats endpoint (or check the dashboard usage page).

Examine the stats.byApiKey object and compare the reported token usage / cost for each key against the actual request logs or provider-side records.

Expected behavior

The byApiKey statistics should accurately reflect the total token usage, cost, and request count for each API key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions