Skip to main content

Model leaderboard

The model leaderboard ranks the models the gateway served over a date range by requests, spend or tokens, charts the daily totals, and breaks usage down by task type. It reads a per day rollup of every request per model group, deployment model, provider and task type, so it stays fast however many spend log rows exist. The Admin UI shows it on the Model Leaderboard page under Observability, and GET /model-insights returns the same data.

What this is for​

Usage reports per key or team tell you who spends. The leaderboard tells you what they spend it on: which models dominate, whether a new model is taking share, and which model handles each kind of work. It covers the whole deployment, so it is open to proxy admins and admin viewers only, and it needs no license.

Scenario​

A platform team added a cheaper model last month and told teams to try it. They open the leaderboard, pick the last 60 days and the Spend tab, and see the new model's share climb from 0 to 18 percent while the old model's share falls. The By task type card shows the new model already leads summarization but not code generation, so that is where they look next.

Steps​

  1. Open the page. In the Admin UI open Model Leaderboard under Observability. Set From and To above the charts, up to 365 days, both days included and in UTC.

  2. Pick the metric. On the Top models card choose Requests, Spend or Tokens, and Daily or Weekly buckets. The Leaderboard card ranks the top models by their share, with the change between the first and second half of the range. From the command line:

    curl "http://localhost:4000/model-insights?start_date=2026-09-16&end_date=2026-10-16&metric=spend" \
    -H "Authorization: Bearer $SPANWAY_API_KEY"
  3. Tag requests with a task to fill the By task type card, by sending x-spanway-tags: task:code_review or another type from the task catalogue. From the command line:

    curl "http://localhost:4000/model-insights/tasks?start_date=2026-09-16&end_date=2026-10-16&metric=spend" \
    -H "Authorization: Bearer $SPANWAY_API_KEY"

metric is requests, spend or tokens. It defaults to tokens on /model-insights and to spend on /model-insights/tasks. Dates are YYYY-MM-DD, default to the last 365 days, and the range may not exceed 365 days.

Expected result​

{
"start_date": "2026-09-16",
"end_date": "2026-10-16",
"daily": [
{
"date": "2026-10-15",
"model_group": "claude-sonnet-5-5",
"model": "claude-sonnet-5-5",
"provider": "anthropic",
"spend": 41.2,
"prompt_tokens": 9120000,
"completion_tokens": 410000,
"requests": 8120,
"successful_requests": 8098,
"failed_requests": 22
}
],
"daily_totals": [
{"date": "2026-10-15", "spend": 63.9, "prompt_tokens": 14200000, "completion_tokens": 650000, "requests": 12930}
],
"top_models": [
{
"model_group": "claude-sonnet-5-5",
"model": "claude-sonnet-5-5",
"provider": "anthropic",
"spend": 1180.4,
"prompt_tokens": 262000000,
"completion_tokens": 11800000,
"requests": 233000,
"successful_requests": 232400,
"failed_requests": 600
}
]
}

top_models ranks the ten leading model groups by the chosen metric, adding up every deployment of a group, and names the model and provider of the group's largest deployment. daily holds one row per day for each of them, and daily_totals sums every model per day, which is the Gateway total shown when you hover a bar. The page charts daily, ranks top_models and lists the task rows from /model-insights/tasks in the By task type card.

Live deployment speed​

Below the leaderboard, the Live deployment speed card lists latency, time to first token, total time, output tokens per second and provider 429 counts for every deployment over the last 30 minutes, from GET /health/deployments. Unlike the rest of the page it is live, not a daily rollup. See alerts inbox and deployment speed.

Where the numbers come from​

Every request that reaches a provider is added to the rollup together with its spend log, keyed by day, model group, deployment model, provider and task type. The spend writer flushes every proxy_batch_write_at seconds, 10 by default, so a new request shows up within about that time, see the settings reference. Calls the gateway makes for itself, such as shadow eval judges, guardrail judges and background cost checks, are left out so they do not inflate a model's share. Eval runs, playground calls and online scoring judge calls are counted like any other traffic, because they are real model usage billed to a key. Spend is in US dollars and tokens count input plus output.

Errors​

What you seeWhyFix
400 Dates must use YYYY-MM-DDA date was in another format.Send YYYY-MM-DD.
400 Date range must be between 1 and 365 daysThe end is before the start, or the range is longer than a year. The page says "The end date must not be before the start date." or "Pick at most 365 days." and keeps the last data loaded.Narrow the range.
401 Authentication Error, No api key passed in.No key was sent, or it is not valid.Send Authorization: Bearer <key>.
403 Only proxy admins can view deployment-wide model insightsThe key belongs to an org admin, internal user or viewer. The page is hidden from those roles in the nav.Use a proxy admin or admin viewer key.
500 DB not connected. This endpoint needs a database; set DATABASE_URL ...The rollup lives in the database.Set DATABASE_URL.
"Could not load model insights"The gateway refused or failed the request. The message shows the reason.Fix the cause above and reload the page.
An empty chartNo requests in the range.Widen the range, or check that traffic reaches a provider.

The routes answer errors as {"detail": "<message>"}. The error reference lists the same messages.

Logs​

LevelLineMeaningAction
WARNINGSpend tracking - database out of connections or rollup row lock timed out during model usage flush, requeued <n> model usage transactions for the next flush: <error>The rollup write was put off to the next flush, so new usage shows a little later.None when rare. When it repeats on every flush, add database connections or raise SPEND_ROLLUP_LOCK_TIMEOUT_MS (default 5000).
ERRORSpend tracking - model usage flush failed; <n> model usage transactions dropped: <error>That usage is missing from the leaderboard. Spend logs and budgets are not affected.Check the database.