/** * Cost Tracking Pattern * * Monitors and controls AI spending in real-time, preventing budget overruns * and optimizing costs across your application. * * @example * ```typescript * const result = await costTracking({ * execute: async () => { * const { text, usage } = await generateText({ * model: openai('gpt-4-turbo'), * prompt: longPrompt * }); * return { value: text, tokens: usage.totalTokens }; * }, * costPerToken: ModelCost.GPT4_TURBO, * monthlyBudget: 500, * dailyLimit: 50, * onBudgetWarning: (spent, limit) => { * console.warn(`Budget at 80%: $${spent}/$${limit}`); * }, * tags: { feature: 'chatbot', userId: 'user-123' } * }); * ``` */ import type { CostTrackingConfig, CostResult, CostStorage } from "../types/cost-tracking"; /** * In-memory cost storage implementation using GlobalStorage */ declare class InMemoryCostStorage implements CostStorage { private storage; private readonly namespace; private initialized; constructor(); private ensureInitialized; getSpent(period: "monthly" | "daily" | "hourly"): Promise; addSpent(period: "monthly" | "daily" | "hourly", amount: number): Promise; resetSpent(period: "monthly" | "daily" | "hourly"): Promise; } /** * Execute an operation with cost tracking */ export declare function costTracking(config: CostTrackingConfig): Promise>; /** * Create a cost tracking wrapper function */ export declare function createCostTracker(baseConfig: Omit, "execute">): (execute: () => Promise<{ value: TResult; tokens?: number; }>) => Promise>; /** * Export storage for testing and custom implementations */ export { InMemoryCostStorage }; //# sourceMappingURL=cost-tracking.d.ts.map