How to build OpenRouter dashboards in Metabase
OpenRouter is a unified API gateway for hundreds of LLMs that tracks usage, spend, and latency across every model and provider you route through. Metabase is where you turn that LLM telemetry into shared, trustworthy dashboards. This guide covers two complementary paths: a lightweight API + CLI route that pulls live data from the OpenRouter activity API and loads a CSV into Metabase with the Metabase CLI, and a durable pipeline route that syncs OpenRouter rollups into a database so you can build dashboards anyone can read.
How do you connect OpenRouter to Metabase?
Most teams combine both routes: use quick exports and CLI uploads for a fast first pass, then move recurring cost and quality reporting to a warehouse-backed model.
Live data in, quick analysis out
Pair a scripted export against the OpenRouter activity API with the Metabase CLI. Pull a scoped usage slice to CSV, then load it into Metabase as a ready-to-query table and model.
- Quick lookups such as "show me llm spend by model and provider"
- Loading a OpenRouter export into Metabase in seconds
- Spot-checks and one-off analyses without a warehouse
- Great for exploration, not governed cost or quality reporting
- Use read-only or scoped credentials wherever the server supports them
- CSV uploads are snapshots — refresh or move to the pipeline for history
Durable dashboards with history
Sync OpenRouter rollups and metadata into a database or warehouse with an export pipeline or API scripts, then point Metabase at it.
- OpenRouter cost and quality dashboards leaders depend on
- Joining OpenRouter data with revenue, product usage, or infrastructure cost
- Long-run trends for llm spend by model and provider and token usage trends by model
- You own the refresh schedule and the rollup grain
- Sync aggregates and entities — not raw prompt/response payloads
- Cost and quality definitions must stay consistent across apps and teams
What can you analyze from OpenRouter data in Metabase?
Each view below is built from daily usage and spend by model, plus the per-request generation costs, provider routing, and API-key-level usage your sync exposes:
- LLM spend by model and provider
- Token usage trends by model
- Cost per 1M tokens by model
- Requests and reasoning-token growth
- Spend by API key and team member
Which OpenRouter dashboards should you build in Metabase?
Spend overview
The headline spend picture leaders ask for.
- LLM spend per day and per week (line)
- Spend by model (bar)
- Spend by app or team (stacked bar)
- Month-over-month spend growth (number + trend)
Unit costs
Whether efficiency improves as volume grows.
- Cost per 1M tokens by model (bar)
- Cost per request trend (line)
- Prompt vs. completion token ratio (line)
- Cache hit rate and estimated savings (combo)
Cost per user and feature
Where LLM unit economics actually stand.
- Cost per active user (line)
- Cost by feature (bar)
- Top users or tenants by spend (table)
- Cost vs. revenue per feature, where joined (table)
Usage hygiene
Waste and drift to clean up.
- Requests and spend by API key (table)
- Spend on failed or retried requests (bar)
- Traffic still on deprecated or pricier models (table)
- Spend vs. budget (number + trend)
How do you use the OpenRouter MCP server with the Metabase CLI?
Pair the OpenRouter MCP server with the Metabase CLI for fast, hands-on analysis. For usage analytics the scripted API export below does the heavy lifting, and MCP covers interactive lookups; the Metabase CLI's upload command loads CSV data into Metabase and creates a ready-to-query table and model.
Example workflow
- Run the export script against the OpenRouter activity API for daily usage and spend rollups by model and application.
- Export the result as CSV, keeping stable IDs, apps, models, environments, token counts, costs, and timestamps.
- Run
mb upload csvto load it into Metabase as a table and model, then build questions and dashboards on top.
Be honest about the limits
- Scripted exports are excellent for exploration, not scheduled reporting.
- A CSV upload is a snapshot; refresh it with
mb upload replaceor move to the pipeline for real history. - Daily usage rollups are required for spend trends — a single export is a snapshot, and some usage APIs only return a trailing window.
mb upload csvneeds an uploads database configured under Admin → Settings → Uploads.
How do you set up OpenRouter MCP and the Metabase CLI?
OpenRouter MCP serverofficial
- Transport
- Hosted remote MCP via Streamable HTTP
- Auth
- OAuth through OpenRouter
- Best for
- Live scoped lookup and export
Metabase CLIofficial
- Install
npm install -g @metabase/cli- Auth
mb auth login- Load data
mb upload csv --file data.csv- Requires
- An uploads database (Admin → Settings → Uploads)
{
"mcpServers": {
"openrouter": {
"url": "https://mcp.openrouter.ai/mcp"
}
}
}The hosted MCP is developer-assistant oriented — model search, pricing lookups, credits, docs — not an analytics export surface, so this guide's numbers come from the activity API below. Note the OAuth flow mints a scoped API key with a 7-day expiry and a $10 default spend limit.
# Requires a management (provisioning) key, not a regular inference key
curl -s https://openrouter.ai/api/v1/activity \
-H "Authorization: Bearer $OPENROUTER_MANAGEMENT_KEY" \
| jq -r '.data[] | [.date, .model, .provider_name, .requests,
.prompt_tokens, .completion_tokens, .usage] | @csv' \
> openrouter-activity.csvThe activity endpoint returns daily usage per model and endpoint for the last 30 completed UTC days only — schedule the export daily to accumulate history. Check field names against the response; per-request costs reconcile via GET /api/v1/generation.
# Install the Metabase CLI
npm install -g @metabase/cli
# Log in (opens your browser; requires Metabase v62+)
mb auth login --url https://your-metabase.example.com
# Load a daily-usage-and-spend-by-model export — creates a table AND a model
mb upload csv --file openrouter-daily-usage-and-spend-by-model.csv --collection root
# Refresh that same table later from a new export
mb upload replace <table-id> --file openrouter-daily-usage-and-spend-by-model.csvCan you generate a OpenRouter dashboard with AI?
Yes. Use the prompt below with any assistant that can run shell scripts and the Metabase CLI. It works end to end: if OpenRouter tables already exist in Metabase it analyzes those; otherwise it pulls scoped, summarized data, loads it with mb upload csv, then builds the dashboard and caveats any metric that needs missing history.
Create a polished Metabase dashboard for OpenRouter llm cost analytics.
Work end to end: get the data into Metabase if it isn't there yet, then build.
Goal: Help engineering, product, and finance partners understand spend by model and app, unit costs, cost per user, cache savings, and budget tracking from OpenRouter data.
Step 1 — Find or load the data:
- First, check what already exists in Metabase (search for openrouter tables and
models). If durable OpenRouter data is already present — synced from a warehouse
or uploaded earlier — use it and skip to Step 2.
- If nothing is there, run a scripted export against the OpenRouter activity API (this page includes a
working script):
daily usage and spend by model, plus per-request generation costs, provider routing, API-key-level usage.
Prefer aggregated or rollup views over raw traces. Write each result to a CSV,
then load it with the Metabase CLI — run "mb upload csv --file <export>.csv" so
each upload creates a table and a ready-to-query model. Use "mb upload replace
<table-id> --file <export>.csv" to refresh an existing table instead of creating
duplicates.
Step 2 — Inspect before querying:
Do not assume exact table or column names. Inspect available fields, apps, models,
environments, timestamps, and whether rollups or history exist before creating
duration or trend cards.
Important:
- Build on whatever data is present; don't claim Metabase connects natively to
OpenRouter — it reads a database or CLI-uploaded tables.
- Never load raw prompt/response payloads into Metabase; use rollups, trace
summaries, and experiment- or score-grain data.
- Only compute latency percentiles and durations when the required timestamps
or pre-aggregated percentile fields exist.
- Exclude test, staging, and playground traffic from headline cost and quality
cards, and segment by environment where the field exists.
- A single CSV is a point-in-time snapshot: only build trend cards if there is a
usable date column or multiple periods have been uploaded.
Dashboard title: OpenRouter LLM Cost Overview
Sections:
1. Executive summary: Spend last 30 days; MoM growth; Cost per request;
Cost per active user; Cache savings.
2. Spend: Daily/weekly spend by model, app, and team.
3. Unit costs: Cost per 1M tokens by model; prompt vs. completion ratio;
cache hit rate.
4. Users and features: Cost per active user; cost by feature; top tenants.
5. Hygiene: Spend by API key; failed-request spend; deprecated-model traffic.
Filters: Date range, App, Model, Environment, User or team, Status.
Output: Build the dashboard if you have permission; otherwise provide the exact
questions, SQL, model definitions, and layout. Include caveats for any metric
that cannot be calculated from the available data.How do you sync OpenRouter data into a database or warehouse?
For dashboards that need history and reliability, land OpenRouter rollups and metadata in a database first, then connect Metabase to that database.
Connector options
- Direct database or export pipeline — use the vendor's storage or export path when it reaches a database you control.
- Custom pipeline — use the OpenRouter activity API for control over rollup grain, fields, and refresh cadence.
- API + CSV — use this for quick exploration and one-off slices.
No managed connector or warehouse export exists — schedule the activity export daily into your warehouse to build history beyond the API's 30-day window, and use the generation endpoint to reconcile per-request costs. It's a small, well-shaped dataset: one row per day per model per endpoint.
Notes
- Decide the rollup grain first (daily per app/model is the workhorse) — it drives warehouse cost and every trend card.
- Land raw entity tables first, then build clean Metabase models on top.
- Normalize app, model, provider, window-start, token-count, and cost-USD fields.
- Strip or hash prompt/response payloads and user identifiers before they reach the warehouse — cost and quality analytics don't need them.
How should you model OpenRouter data in Metabase?
Core tables
| Table | Grain | Key columns |
|---|---|---|
llm_request_rollups | one row per model per endpoint per day | model, provider_name, window_start, requests, prompt_tokens, completion_tokens, reasoning_tokens, cost_usd |
llm_generations | one row per reconciled generation (sampled or audited) | id, model, provider_name, created_at, native_prompt_tokens, native_completion_tokens, cost_usd |
llm_api_key_rollups | one row per API key per day | api_key_hash, window_start, requests, total_tokens, cost_usd |
Modeling advice
- Build a clean
llm_request_rollupsmodel with common columns across tools, so multi-source dashboards don't fork definitions. - Separate entity tables (apps, models, datasets, prompts) from time-series rollups and trace- or score-grain tables.
- Exclude test, staging, and playground traffic from headline cost and quality metrics; keep environment as an explicit column.
- Use stable IDs for app, model, and experiment joins; display names and model aliases change.
Which OpenRouter metrics should you track in Metabase?
| Metric | Definition | Notes |
|---|---|---|
| Cost per 1M tokens | Blended spend divided by total tokens, normalized per million. | The cleanest way to compare models and catch price drift. |
| LLM cost per user | LLM spend divided by active users of LLM features. | The unit-economics headline — pair it with revenue per user. |
| Cache hit rate | Cached responses or tokens divided by total, per app. | Cache reads are discounted, not free — model the real rate. |
| Token usage | Prompt and completion tokens per period, by model and app. | Watch the prompt:completion ratio — bloated prompts hide there. |
What SQL powers OpenRouter dashboards in Metabase?
These assume a cleaned analytical model in a warehouse (PostgreSQL dialect). Adjust table and column names to match your pipeline.
Where the money goes, from daily rollups.
SELECT
date_trunc('month', window_start) AS month,
model,
ROUND(SUM(cost_usd), 2) AS cost_usd,
SUM(prompt_tokens + completion_tokens) AS total_tokens
FROM llm_request_rollups
GROUP BY 1, model
ORDER BY 1, cost_usd DESC;The normalized unit cost that makes models comparable.
SELECT
model,
ROUND(SUM(cost_usd), 2) AS cost_usd,
SUM(prompt_tokens + completion_tokens) AS total_tokens,
ROUND(
1e6 * SUM(cost_usd)
/ NULLIF(SUM(prompt_tokens + completion_tokens), 0), 2
) AS cost_per_1m_tokens
FROM llm_request_rollups
WHERE window_start >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY model
ORDER BY cost_usd DESC;The unit-economics headline from user-grain rollups.
SELECT
date_trunc('month', window_start) AS month,
ROUND(SUM(cost_usd), 2) AS cost_usd,
COUNT(DISTINCT user_id) AS active_users,
ROUND(
SUM(cost_usd) / NULLIF(COUNT(DISTINCT user_id), 0), 4
) AS cost_per_active_user
FROM llm_user_rollups
GROUP BY 1
ORDER BY 1;