/** * Agentic QE v3 - LLM Cost Tracker * ADR-011: LLM Provider System for Quality Engineering * * Tracks token usage and costs across all LLM providers. * Supports cost limits, alerts, and detailed breakdowns. */ import { LLMProviderType, TokenUsage, CostInfo, CostPeriod, CostSummary } from './interfaces'; /** * Token pricing per model (cost per 1M tokens in USD) * Prices as of early 2025 - should be updated periodically */ export declare const MODEL_PRICING: Record; /** * Usage record for a single request */ interface UsageRecord { timestamp: Date; provider: LLMProviderType; model: string; usage: TokenUsage; cost: CostInfo; requestId: string; metadata?: Record; } /** * Cost tracker for LLM usage */ export declare class CostTracker { private records; private alerts; private maxRecords; private alertCheckInterval?; constructor(maxRecords?: number); /** * Calculate cost for a given usage */ static calculateCost(model: string, usage: TokenUsage): CostInfo; /** * Get cost per token for a model */ static getCostPerToken(model: string): { input: number; output: number; }; /** * Record a usage event */ recordUsage(provider: LLMProviderType, model: string, usage: TokenUsage, requestId: string, metadata?: Record): CostInfo; /** * Get cost summary for a period */ getSummary(period: CostPeriod): CostSummary; /** * Get current cost for a period */ getCurrentCost(period: CostPeriod): number; /** * Get total tokens used in a period */ getTotalTokens(period: CostPeriod): number; /** * Get usage by provider */ getUsageByProvider(provider: LLMProviderType, period?: CostPeriod): { totalCost: number; totalTokens: number; totalRequests: number; models: Record; }; /** * Add a cost alert */ addAlert(threshold: number, period: CostPeriod, onThreshold: (summary: CostSummary) => void): string; /** * Remove a cost alert by index */ removeAlert(index: number): boolean; /** * Get all records (for export/persistence) */ getRecords(): UsageRecord[]; /** * Import records (from persistence) */ importRecords(records: UsageRecord[]): void; /** * Clear all records */ clear(): void; /** * Get recent requests */ getRecentRequests(count?: number): UsageRecord[]; /** * Estimate cost for a request (before making it) */ estimateCost(model: string, estimatedPromptTokens: number, estimatedCompletionTokens: number): CostInfo; /** * Check if making a request would exceed cost limits */ wouldExceedLimit(model: string, estimatedPromptTokens: number, estimatedCompletionTokens: number, limitUSD: number, period: CostPeriod): boolean; /** * Dispose resources */ dispose(): void; /** * Get the start of a period */ private getPeriodStart; /** * Check all alerts against current costs */ private checkAlerts; } /** * Get the global cost tracker instance */ export declare function getGlobalCostTracker(): CostTracker; /** * Reset the global cost tracker (for testing) */ export declare function resetGlobalCostTracker(): void; export {}; //# sourceMappingURL=cost-tracker.d.ts.map