Add AI cost export and top target rollups

This commit is contained in:
rcourtman
2025-12-12 12:55:39 +00:00
parent 9c78cf7f84
commit 5c9ebf8d3a
8 changed files with 357 additions and 9 deletions
+5 -1
View File
@@ -51,13 +51,17 @@ export class AIAPI {
}
// Reset AI usage history (admin-only)
static async resetCostHistory(): Promise<{ ok: boolean }> {
static async resetCostHistory(): Promise<{ ok: boolean; backup_file?: string }> {
return apiFetchJSON(`${this.baseUrl}/ai/cost/reset`, {
method: 'POST',
body: JSON.stringify({}),
}) as Promise<{ ok: boolean; backup_file?: string }>;
}
static async exportCostHistory(days = 30, format: 'json' | 'csv' = 'csv'): Promise<Response> {
return apiFetch(`${this.baseUrl}/ai/cost/export?days=${days}&format=${format}`, { method: 'GET' });
}
// Start OAuth flow for Claude Pro/Max subscription
// Returns the authorization URL to redirect the user to
static async startOAuth(): Promise<{ auth_url: string; state: string }> {