Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions profile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Find the best models & prices for your prompts — through a single, OpenAI-comp

<br>

<a href="https://openrouter.ai/models"><picture><source media="(prefers-color-scheme: dark)" srcset="./assets/stat-models-dark.gif"><img src="./assets/stat-models-light.gif" alt="Models on OpenRouter" width="290"></picture></a>
<a href="https://openrouter.ai/models"><picture><source media="(prefers-color-scheme: dark)" srcset="./assets/stat-providers-dark.gif"><img src="./assets/stat-providers-light.gif" alt="Providers on OpenRouter" width="290"></picture></a>
<a href="https://openrouter.ai/rankings"><picture><source media="(prefers-color-scheme: dark)" srcset="./assets/stat-tokens-dark.gif"><img src="./assets/stat-tokens-light.gif" alt="Tokens routed per week" width="290"></picture></a>
<a href="https://openrouter.ai/models"><picture><source media="(prefers-color-scheme: dark)" srcset="./assets/stat-models-dark.gif"><img src="./assets/stat-models-light.gif" alt="Models on OpenRouter" width="272"></picture></a>
<a href="https://openrouter.ai/models"><picture><source media="(prefers-color-scheme: dark)" srcset="./assets/stat-providers-dark.gif"><img src="./assets/stat-providers-light.gif" alt="Providers on OpenRouter" width="272"></picture></a>
<a href="https://openrouter.ai/rankings"><picture><source media="(prefers-color-scheme: dark)" srcset="./assets/stat-tokens-dark.gif"><img src="./assets/stat-tokens-light.gif" alt="Tokens routed per month" width="272"></picture></a>

[![Website](https://img.shields.io/badge/Website-openrouter.ai-1e293b?style=for-the-badge)](https://openrouter.ai)
[![Docs](https://img.shields.io/badge/Docs-openrouter.ai%2Fdocs-1e293b?style=for-the-badge)](https://openrouter.ai/docs)
Expand Down
Binary file modified profile/assets/stat-tokens-dark.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified profile/assets/stat-tokens-light.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 21 additions & 9 deletions stats-cards/scripts/fetch-stats.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,42 @@ const get = async (url) => {
const [models, providers, rankings] = await Promise.all([
get('https://openrouter.ai/api/v1/models'),
get('https://openrouter.ai/api/v1/providers'),
get('https://openrouter.ai/api/frontend/v1/rankings/models?view=week').catch(
// Monthly window to match the homepage's canonical "Monthly Tokens" stat.
get('https://openrouter.ai/api/frontend/v1/rankings/models?view=month').catch(
() => null // undocumented endpoint — tolerate failure
),
]);

const modelCount = models.data.length;
const providerCount = providers.data.length;

let tokensT = 40; // conservative fallback
if (rankings?.data) {
const total = rankings.data.reduce(
(sum, r) =>
sum + (r.total_completion_tokens ?? 0) + (r.total_prompt_tokens ?? 0),
0
let tokensT = 100; // conservative fallback
if (rankings?.data?.length) {
// The response contains multiple date buckets; only the latest one is
// the trailing-month window. Summing all rows would double-count
// stale partial buckets.
const latest = rankings.data.reduce(
(max, r) => (r.date > max ? r.date : max),
rankings.data[0].date
);
if (total > 1e12) tokensT = Math.round((total / 1e12) * 10) / 10;
// Canonical "tokens processed" formula (site's getTotalTokens):
// prompt + completion, excluding reasoning/cached columns.
const total = rankings.data
.filter((r) => r.date === latest)
.reduce(
(sum, r) =>
sum + (r.total_prompt_tokens ?? 0) + (r.total_completion_tokens ?? 0),
0
);
if (total > 1e12) tokensT = Math.round(total / 1e12);
}

await mkdir('out', {recursive: true});

const props = {
models: {value: modelCount, suffix: '+', label: 'Models'},
providers: {value: providerCount, suffix: '+', label: 'Providers'},
tokens: {value: tokensT, suffix: 'T', label: 'Tokens / week'},
tokens: {value: tokensT, suffix: 'T', label: 'Tokens / month'},
};

for (const [id, p] of Object.entries(props)) {
Expand Down
4 changes: 2 additions & 2 deletions stats-cards/src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const STATS = [
},
{
id: 'tokens',
value: 46.8,
value: 189,
suffix: 'T',
label: 'Tokens / week',
label: 'Tokens / month',
sub: 'routed across the network',
},
] as const;
Expand Down
Loading