feat(usage): report model usage per org with identity and cost (#1855)
Model usage was recorded per call and never read, so an org could not see what it spent. Add the read side: - model_usage carries identity_id. Task calls take it from the task row, chat and curator calls from the calling principal carried in the usage record, so an outbox replay keeps its attribution. Existing task rows are backfilled from tasks. - StatsService.UsageTotals sums the caller org's rows by UTC day, source, provider, model and identity. The org comes from the principal, with no org parameter, so cross-org reads do not exist. - GET /api/usage prices tokens at the catalog's list rate, netting cache hits, and reports calls to unpriced models as tokens only. The published catalog view now carries each model's cost. - A new org Usage page behind a read_usage grant: admin and owner only, with a 7, 30 or 90 day range, totals, the daily series, and model, source and identity breakdowns. The org shell keeps it on the caller's own org.
This commit is contained in:
38 files changed
+1329
-52
No files matched your search
@@ -24,7 +24,7 @@ const error = ref("");
|
||||
|
||||
// Policies and models act on the caller's own org server-side, so an instance
|
||||
// admin looking at another org is sent back rather than editing the wrong one.
|
||||
const OWN_ORG_ONLY = ["/org/audit", "/org/policies", "/org/models", "/org/connections", "/org/repositories"];
|
||||
const OWN_ORG_ONLY = ["/org/audit", "/org/policies", "/org/models", "/org/connections", "/org/repositories", "/org/usage"];
|
||||
const away = computed(() => !!org.value && org.value.id !== homeOrg.value);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
Reference in new issue
Block a user