// Estimated public Gemini API pricing in USD. These are PLACEHOLDER figures — // verify against https://ai.google.dev/gemini-api/docs/pricing and update before // relying on the cost numbers. Centralised here so cost math is never inlined. export interface ModelPricing { inputPerMillion: number; // USD per 1M input tokens outputPerMillion: number; // USD per 1M output tokens } export const MODEL_PRICING: Record = { 'gemini-2.5-flash': { inputPerMillion: 0.3, outputPerMillion: 2.5 }, 'gemini-2.5-pro': { inputPerMillion: 1.25, outputPerMillion: 10.0 }, // TTS bills output as audio tokens; treat candidates tokens as output. 'gemini-2.5-flash-preview-tts': { inputPerMillion: 0.5, outputPerMillion: 10.0 }, }; const ZERO_PRICING: ModelPricing = { inputPerMillion: 0, outputPerMillion: 0 }; export function estimateCostUsd( model: string, promptTokens: number, completionTokens: number, ): number { const pricing = MODEL_PRICING[model] ?? ZERO_PRICING; return ( (promptTokens / 1_000_000) * pricing.inputPerMillion + (completionTokens / 1_000_000) * pricing.outputPerMillion ); }