diff --git a/app/main.py b/app/main.py
index 4818cfc..05b5e28 100644
--- a/app/main.py
+++ b/app/main.py
@@ -413,6 +413,9 @@ PAGE_HTML = """
.key-row:last-child { border-bottom: none; }
.key-name { font-weight: 600; font-size: 14px; }
.key-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
+ .key-chat { color: var(--muted); font-size: 12px; margin-top: 10px; }
+ .key-chat-name { font-weight: 600; }
+ .key-chat-num { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.key-token {
font-family: ui-monospace, 'SF Mono', Menlo, monospace;
font-size: 12px; color: var(--muted);
@@ -597,6 +600,7 @@ PAGE_HTML = """
API keys
Keys let you use the co-op's AI from your own tools. They draw from the same balance as chat.
+
Create key
@@ -692,7 +696,7 @@ async function load() {
renderModels(d.models || []);
renderBoard(d.coop_models || []);
- renderKeys(d.keys || []);
+ renderKeys(d.keys || [], d.key_spend || []);
loadMxid();
} catch (e) {
flash('Could not load usage: ' + e.message, false);
@@ -997,23 +1001,45 @@ function renderBoard(models) {
}).join('');
}
-function renderKeys(keys) {
+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 '
' +
'
' + escapeHtml(k.name) + '
' +
'
' + escapeHtml(created) +
- (fp ? ' · ends …' + escapeHtml(fp) : '') + '
' +
+ (fp ? ' · ends …' + escapeHtml(fp) : '') + escapeHtml(spent) + '
' +
'
' +
'
Revoke ' +
'
';
}).join('');
+ renderChatSpend(keySpend);
+}
+
+function renderChatSpend(keySpend) {
+ const el = $('key-chat');
+ if (!el) return;
+ const chat = (keySpend || []).find(s => s.is_chat);
+ if (!chat) { el.innerHTML = ''; return; }
+ // The built-in chat key is not one of the member's API keys, so its spend is
+ // shown on its own line rather than mixed into the list above.
+ el.innerHTML = 'Chat (built-in) · ' +
+ '' + fmtMoney(chat.spend) + ' spent' +
+ (chat.requests ? ' · ' + chat.requests.toLocaleString() + ' requests' : '');
}
function escapeHtml(s) {