diff --git a/apps/docs/content/learn/analytics.mdx b/apps/docs/content/learn/analytics.mdx new file mode 100644 index 0000000000..1b19b7fc14 --- /dev/null +++ b/apps/docs/content/learn/analytics.mdx @@ -0,0 +1,40 @@ +--- +title: Analytics +description: Break down cost, requests, and tokens by model for any project +icon: ChartArea +--- + +import { ThemedImage } from "@/components/themed-image"; + +The Analytics page shows where a project's spend actually goes. It breaks usage down by model — as a ranking and over time — so you can see which models drive cost, requests, and tokens across any date range. + + + +Open it from the **Analytics** item in the project sidebar. Like the rest of the dashboard, the page respects the shared date-range picker at the top, so every chart reflects the same window. + +## Cost by Model + +A horizontal bar chart that ranks the models used in the selected range. Switch the metric with the tabs above the chart: + +| Tab | What it ranks | +| ------------ | -------------------------------------- | +| **Cost** | Total spend per model, in USD | +| **Requests** | Number of requests routed to the model | +| **Tokens** | Total tokens (input + output) | + +Use it to spot the one or two models responsible for most of your bill, or to confirm that traffic is spread the way you expect. + +## Cost by Model Over Time + +A stacked area chart that plots the same three metrics across the date range, with one band per model. It has the same **Cost / Requests / Tokens** tabs, plus a **Mappings / Canonical** toggle: + +- **Mappings** — each model variant is shown separately, exactly as it was requested (for example a custom provider mapping is kept distinct from the built-in model). +- **Canonical** — variants of the same underlying model are collapsed into one canonical model (the provider prefix and tag are dropped), so `openai/gpt-5.5` and a custom mapping of it count as a single line. + +Switch to **Canonical** when you care about the underlying model's total footprint; stay on **Mappings** when you need to compare specific routes. + +## How the data is computed + +Both charts derive from the same activity data the rest of the dashboard already reads — there is no separate analytics pipeline to wait on. Aggregation happens per time bucket and is timezone-correct, so totals line up with the Activity and Usage pages for the same range. + +For a per-key view of the same breakdowns, see [API Keys](/learn/api-keys#per-key-statistics). For an org-wide, per-person view on the Enterprise plan, see [Member Analytics](/learn/member-analytics). diff --git a/apps/docs/content/learn/api-keys.mdx b/apps/docs/content/learn/api-keys.mdx index 053855a3f1..f88276f88f 100644 --- a/apps/docs/content/learn/api-keys.mdx +++ b/apps/docs/content/learn/api-keys.mdx @@ -117,9 +117,30 @@ For each API key you can: - **Disable or enable**: Pause usage without deleting the key (reactivating an expired key prompts for a new expiration) - **Configure IAM rules**: Restrict which models, providers, or pricing tiers the key can use -- **Open usage details**: Inspect requests and usage tied to that key +- **View Statistics**: Open a dedicated analytics page for that key (see below) - **Delete**: Permanently remove the key +## Per-Key Statistics + +The **View Statistics** action opens a dedicated page scoped to a single API +key, so you can see exactly what that key is doing without filtering the whole +project. + + + +The page respects the shared date-range picker and shows: + +- **Summary cards** — the key's cost, tokens, requests, and error rate for the + selected range. +- **Cost by Model** — a horizontal bar chart ranking the key's models by cost, + requests, or tokens. +- **Cost by Model Over Time** — a stacked area chart of the same metrics, with a + Mappings / Canonical toggle. + +These are the same breakdowns as the project [Analytics](/learn/analytics) page, +narrowed to the one key — useful for confirming a key is healthy and spending on +the models you expect. + ## IAM Rules IAM rules let you narrow what an API key is allowed to access. diff --git a/apps/docs/content/learn/index.mdx b/apps/docs/content/learn/index.mdx index 347f3c0f4b..831ec18d2b 100644 --- a/apps/docs/content/learn/index.mdx +++ b/apps/docs/content/learn/index.mdx @@ -16,7 +16,8 @@ These pages are scoped to a specific project within your organization: - [**Model Usage**](/learn/model-usage) — Usage breakdown by model - [**Model Categories & Fair Use**](/learn/model-categories) — How models are categorized and premium fair-use caps - [**Usage & Metrics**](/learn/usage-metrics) — Requests, errors, cache rates, and cost trends -- [**API Keys**](/learn/api-keys) — Create and manage your API keys +- [**Analytics**](/learn/analytics) — Cost, requests, and tokens broken down by model +- [**API Keys**](/learn/api-keys) — Create and manage your API keys, plus per-key statistics - [**Preferences**](/learn/preferences) — Project-level settings like caching and mode - [**LLM SDK**](/learn/sdk-settings) — Embed AI and credit purchases into your own app @@ -33,6 +34,7 @@ These pages apply to your entire organization: - [**Policies**](/learn/policies) — Data retention configuration - [**Org Preferences**](/learn/org-preferences) — Organization name and billing details - [**Team**](/learn/team) — Manage team members and roles +- [**Member Analytics**](/learn/member-analytics) — Per-member cost and usage breakdowns (Enterprise) - [**Audit Logs**](/learn/audit-logs) — Complete history of organization actions ## Playground diff --git a/apps/docs/content/learn/member-analytics.mdx b/apps/docs/content/learn/member-analytics.mdx new file mode 100644 index 0000000000..38b34e5709 --- /dev/null +++ b/apps/docs/content/learn/member-analytics.mdx @@ -0,0 +1,51 @@ +--- +title: Member Analytics +description: See organization usage and cost broken down per team member +icon: ChartPie +--- + +import { Callout } from "fumadocs-ui/components/callout"; +import { ThemedImage } from "@/components/themed-image"; + +Member Analytics breaks your organization's usage down by person, so you can see who is spending what across every project. It lives on the **Members** page and is available on the **Enterprise** plan. + + + + + Member analytics require the **Enterprise plan** and an organization **owner** + or **admin** role. Non-enterprise organizations see an upgrade card, and + members without admin access see an access notice instead of the data. + + +## Members Table + +The Members page adds a usage table sorted by spend, so the heaviest users surface first. Each row shows that member's totals for the selected date range: + +| Column | Description | +| -------------- | -------------------------------------------- | +| **Member** | Name and email of the team member | +| **Cost** | Total spend attributed to the member, in USD | +| **Tokens** | Total tokens (input + output) | +| **Requests** | Number of requests | +| **Error rate** | Share of the member's requests that failed | +| **API keys** | How many API keys the member created | + +Usage is attributed by **who created each API key** — spend lands on the member who owns the key that made the request, which is the only link between usage and a user. + +## Member Detail + +Click a member to open their detail page, scoped to the same date range: + + + +The detail view includes: + +- **Summary cards** — the member's cost, tokens, requests, and error rate for the range. +- **Most used** — their top model, provider, and app. +- **Cost by model** — the same breakdown as the project [Analytics](/learn/analytics) page, scoped to this member. +- **Top providers and top apps** — tables ranking where the member's traffic goes. + +This makes it easy to attribute cost to a team, investigate a spike, or confirm a member is using the models and providers you expect. diff --git a/apps/docs/content/learn/meta.json b/apps/docs/content/learn/meta.json index 094a2ab105..d4344c5740 100644 --- a/apps/docs/content/learn/meta.json +++ b/apps/docs/content/learn/meta.json @@ -10,6 +10,7 @@ "model-usage", "model-categories", "usage-metrics", + "analytics", "api-keys", "preferences", "sdk-settings", @@ -22,6 +23,7 @@ "policies", "org-preferences", "team", + "member-analytics", "audit-logs", "playground", "playground-group", diff --git a/apps/docs/public/learn/analytics-dark.png b/apps/docs/public/learn/analytics-dark.png new file mode 100644 index 0000000000..3f2751dc0c Binary files /dev/null and b/apps/docs/public/learn/analytics-dark.png differ diff --git a/apps/docs/public/learn/analytics-light.png b/apps/docs/public/learn/analytics-light.png new file mode 100644 index 0000000000..d9d97a9ce0 Binary files /dev/null and b/apps/docs/public/learn/analytics-light.png differ diff --git a/apps/docs/public/learn/api-key-statistics-dark.png b/apps/docs/public/learn/api-key-statistics-dark.png new file mode 100644 index 0000000000..6ae2cf00d7 Binary files /dev/null and b/apps/docs/public/learn/api-key-statistics-dark.png differ diff --git a/apps/docs/public/learn/api-key-statistics-light.png b/apps/docs/public/learn/api-key-statistics-light.png new file mode 100644 index 0000000000..5a32c338ee Binary files /dev/null and b/apps/docs/public/learn/api-key-statistics-light.png differ diff --git a/apps/docs/public/learn/member-analytics-dark.png b/apps/docs/public/learn/member-analytics-dark.png new file mode 100644 index 0000000000..0c79c10336 Binary files /dev/null and b/apps/docs/public/learn/member-analytics-dark.png differ diff --git a/apps/docs/public/learn/member-analytics-detail-dark.png b/apps/docs/public/learn/member-analytics-detail-dark.png new file mode 100644 index 0000000000..50c525e77a Binary files /dev/null and b/apps/docs/public/learn/member-analytics-detail-dark.png differ diff --git a/apps/docs/public/learn/member-analytics-detail-light.png b/apps/docs/public/learn/member-analytics-detail-light.png new file mode 100644 index 0000000000..7f1217d9b3 Binary files /dev/null and b/apps/docs/public/learn/member-analytics-detail-light.png differ diff --git a/apps/docs/public/learn/member-analytics-light.png b/apps/docs/public/learn/member-analytics-light.png new file mode 100644 index 0000000000..7a909aa653 Binary files /dev/null and b/apps/docs/public/learn/member-analytics-light.png differ diff --git a/apps/ui/public/changelog/org-analytics.png b/apps/ui/public/changelog/org-analytics.png new file mode 100644 index 0000000000..aa868b5751 Binary files /dev/null and b/apps/ui/public/changelog/org-analytics.png differ diff --git a/apps/ui/src/content/changelog/2026-06-21-org-analytics.md b/apps/ui/src/content/changelog/2026-06-21-org-analytics.md new file mode 100644 index 0000000000..1bc47c4cef --- /dev/null +++ b/apps/ui/src/content/changelog/2026-06-21-org-analytics.md @@ -0,0 +1,44 @@ +--- +id: "60" +slug: "org-analytics" +date: "2026-06-21" +title: "Usage Analytics by Model, Key and Member" +summary: "See exactly where your spend goes. Every project gets a Cost by Model analytics page, every API key gets its own statistics page, and Enterprise orgs get per-member usage breakdowns — all on the date-range picker you already use. Member analytics are available on Enterprise." +image: + src: "/changelog/org-analytics.png" + alt: "Usage analytics on LLM Gateway: cost by model, per-API-key statistics, and per-member spend breakdowns" + width: 1536 + height: 1024 +--- + +The dashboard could already tell you how much you spent and how many requests you sent — but not where it actually went. Which model is eating the budget? Which API key drives the traffic? Which person on the team? **Analytics** answers all three, with cost, request, and token breakdowns by model, by key, and by member. + +## Cost by model, on every project + +Each project now has an **Analytics** page in the sidebar with two charts: + +- **Cost by Model** — a horizontal bar chart ranking your models, with **Cost / Requests / Tokens** tabs. +- **Cost by Model Over Time** — a stacked area chart over your selected range, with the same tabs plus a **Mappings / Canonical** toggle that collapses provider-tagged variants (e.g. `openai/gpt-5.5` and a custom mapping of the same model) into one canonical model. + +Both derive from the same activity data the dashboard already reads, so they're timezone-correct, respect the shared date-range picker, and need no new data to populate. + +## Per-API-key statistics + +Every API key gets a dedicated statistics page: summary cards for **cost, tokens, requests, and error rate**, plus the two cost-by-model charts scoped to that single key. The **View Statistics** action in the API-keys list now opens it directly, so you can see at a glance whether a key is healthy and what it's spending on. + +## Member analytics + +Enterprise organizations also get usage broken down by person. The **Members** page adds a per-member table sorted by spend, and each member has a detail view: + +| Surface | What it shows | +| ----------------- | ------------------------------------------------------------------- | +| **Members table** | Per member: cost, tokens, requests, error rate, and API-key count. | +| **Summary cards** | That member's cost, tokens, requests, and error rate for the range. | +| **Most used** | Their top model, provider, and app. | +| **Breakdowns** | Cost by model, plus top providers and top apps tables. | + +Usage is attributed by who created each API key, so spend lands on the member who owns the key. Member analytics are exposed through new `GET /analytics/members` and `GET /analytics/members/{userId}` endpoints, restricted to organization owners and admins on the **Enterprise plan** — non-enterprise orgs see an upgrade card, and non-admins see an access notice. + +--- + +**[Cost breakdown docs →](https://docs.llmgateway.io/features/cost-breakdown)** | **[Open your dashboard →](https://llmgateway.io/dashboard)**