Keys let you use the co-op's AI from your own tools. They draw from the same balance as chat.
+
+ Show
+
+
+
No API keys yet.
-
@@ -1343,6 +1360,7 @@ function renderModels(models) {
// through the broker as aggregate, non-personal numbers. Fetched once at the
// widest range; the toggles re-render client-side without refetching.
let trendsData = null;
+let metricsTotals = null; // the co-op's all-time spend, from /api/metrics
let trendMetric = "members"; // members | requests | spend
let trendDays = 90; // 0 = all time
@@ -1427,6 +1445,9 @@ async function loadMetrics() {
const d = await r.json();
if (d.error) { host.innerHTML = "
" + d.error + "
"; return; }
trendsData = d.series || [];
+ // The co-op's all-time spend, straight from the portal (see the panel: it
+ // and this page now read the same helper, so they cannot disagree).
+ metricsTotals = d.totals || null;
renderCoopTotals();
renderTrends();
} catch (e) {
@@ -1439,13 +1460,18 @@ async function loadMetrics() {
// it (NULL where a day was not measured, so it is skipped rather than counted
// as zero). Both summed over the widest range the series carries (all time).
function renderCoopTotals() {
- let total = 0, own = 0;
- (trendsData || []).forEach(row => {
- if (typeof row.spend_usd === "number") total += row.spend_usd;
- if (typeof row.operator_spend_usd === "number") own += row.operator_spend_usd;
- });
- $("coop-total").textContent = fmtMoney(total);
- $("coop-own").textContent = fmtMoney(own);
+ // The server's figure, not a sum of whatever rows this page happens to hold:
+ // the same number the admin panel shows. Summing the series in the browser
+ // gave $900.51 where the portal's own all-time spend was $941.37 (2026-11-13).
+ const el = $("coop-total");
+ const t = (metricsTotals && typeof metricsTotals.spend_all_time === "number")
+ ? metricsTotals.spend_all_time : null;
+ if (t === null) {
+ // Never invent a number here. If the server did not send one, say so.
+ el.textContent = "—";
+ return;
+ }
+ el.textContent = fmtMoney(t);
}
function setTrendMetric(m) {
@@ -1638,47 +1664,61 @@ function renderBoard(models) {
}).join('');
}
-function renderKeys(keys, keySpend) {
- const el = $('keys');
- // Spend rows come from the portal, keyed by the member's key name; the chat
- // key is carried separately (is_chat) and rendered on its own line.
- const spendFor = {};
- (keySpend || []).forEach(s => { if (!s.is_chat) spendFor[s.name] = s; });
- if (!keys.length) {
- el.innerHTML = '
No API keys yet. Create one below.
';
- renderChatSpend(keySpend);
- return;
- }
- el.innerHTML = keys.map(k => {
- const fp = k.fingerprint || '';
- const created = k.created_at ? ' · created ' + k.created_at.slice(0,10) : '';
- const s = spendFor[k.name];
- // Secondary detail: this key's all-time spend (server-side, from the spend
- // logs — LiteLLM's own per-key counter is period-only).
- const spent = ' · ' + fmtMoney(s ? s.spend : 0) + ' spent';
- return '