/** * Client for fetching model pricing from models.dev API * * Local-First Strategy: * 1. Try persistent local cache (JSON file on disk) * 2. Try remote API (if online) * 3. Fallback to bundled defaults (always works offline) * * API: https://models.dev/api.json * Returns real-time pricing for 1900+ models from multiple providers */ export interface ModelPricing { id: string; name: string; provider: string; family?: string; /** Input cost per 1M tokens (in USD) */ inputCostPerMillion: number; /** Output cost per 1M tokens (in USD) */ outputCostPerMillion: number; /** Cache read cost per 1M tokens (optional) */ cacheReadCostPerMillion?: number; /** Context window size */ contextWindow?: number; /** Max output tokens */ maxOutputTokens?: number; /** Last updated timestamp */ lastUpdated?: string; } export interface ModelsDevResponse { [providerId: string]: { id: string; name: string; models: { [modelId: string]: { id: string; name: string; family?: string; cost: { input: number; output: number; cache_read?: number; }; limit?: { context?: number; output?: number; }; last_updated?: string; }; }; }; } export declare class ModelsDevClient { private static readonly API_URL; private static readonly MEMORY_CACHE_TTL; private static readonly LOCAL_CACHE_TTL; private static readonly LOCAL_CACHE_FILE; private memoryCache; private memoryCacheTimestamp; /** * Get the local cache file path */ private getLocalCachePath; /** * Load pricing from persistent local cache (JSON on disk) */ private loadLocalCache; /** * Save pricing to persistent local cache */ private saveLocalCache; /** * Get bundled default pricing (always available offline) * * Contains common models with approximate pricing as of 2025. * Used as last-resort fallback when both remote and local cache fail. */ private getBundledDefaults; /** * Fetch all models with pricing * * Local-First Strategy: * 1. Check in-memory cache (fastest) * 2. Check persistent local cache on disk * 3. Try remote API (if online) * 4. Fallback to bundled defaults (always works) */ fetchAllModels(): Promise>; /** * Fetch pricing from remote API */ private fetchRemote; /** * Get pricing for a specific model */ getModelPricing(modelId: string): Promise; /** * Search models by name, provider, or family */ searchModels(query: string): Promise; /** * Get top N most expensive models */ getTopExpensiveModels(limit?: number): Promise; /** * Get statistics about available models */ getStatistics(): Promise<{ totalModels: number; totalProviders: number; avgInputCost: number; avgOutputCost: number; cheapestModel: ModelPricing | null; mostExpensiveModel: ModelPricing | null; }>; /** * Normalize model ID (remove provider prefix, standardize format) */ private normalizeModelId; /** * Add common aliases for a model */ private addCommonAliases; /** * Clear all caches (memory + local file) */ clearCache(): void; /** * Clear all caches including persistent local cache */ clearAllCaches(): Promise; /** * Check if local cache exists and is valid */ hasLocalCache(): Promise; } /** * Get the shared ModelsDevClient instance */ export declare function getModelsDevClient(): ModelsDevClient; //# sourceMappingURL=models-dev-client.d.ts.map