/** * Static USD price table for model providers. Used to populate * `ModelUsage.costUsd` on responses that don't include billing info from the * provider directly (most providers — only `pi-loop-runtime` and a handful of * gateways report cost). * * Prices are stamped with `effectiveAt`. The table is best-effort: real * billing reconciliation should use vendor invoices. Override or extend at * runtime with `registerModelPrices` for custom-rate contracts. */ export interface ModelPriceRow { /** Logical provider id, e.g. 'openai', 'anthropic', 'gemini', 'bedrock', 'cohere'. */ provider: string; /** Model id as the provider sees it (no provider prefix). */ model: string; /** USD per 1M input tokens. */ inputPerMTok: number; /** USD per 1M output tokens. */ outputPerMTok: number; /** Optional cached-input rate (Anthropic prompt cache reads, OpenAI cached prompt). */ cacheReadPerMTok?: number; /** Optional cache-write rate (Anthropic). */ cacheWritePerMTok?: number; /** Audio-input rate for Realtime / voice models. */ audioInputPerMTok?: number; /** Audio-output rate for Realtime / voice models. */ audioOutputPerMTok?: number; /** USD per minute of audio processed by a streaming STT provider. */ sttPerMinute?: number; /** USD per 1M characters synthesized by a streaming TTS provider. */ ttsPerMChar?: number; /** ISO date the rates were captured. */ effectiveAt: string; notes?: string; } export interface ModelPricingUsage { inputTokens?: number; outputTokens?: number; cachedInputTokens?: number; cacheWriteTokens?: number; audioInputTokens?: number; audioOutputTokens?: number; sttSeconds?: number; ttsCharacters?: number; } /** Add or override price rows. Later rows take precedence over earlier ones. */ export declare function registerModelPrices(rows: ModelPriceRow[]): void; /** Reset the registry to the built-in seed (test/utility). */ export declare function resetModelPricesToBuiltins(): void; /** All currently-registered rows (newest-last). Returns a copy. */ export declare function listModelPrices(): ModelPriceRow[]; /** * Look up the most recently-registered row matching `modelRef`. * * `modelRef` can be: * - `'provider/model'` (preferred, e.g. `'openai/gpt-4o'`) * - `'model'` alone (e.g. `'gpt-4o'`) — first row whose model matches wins * * Provider matching is case-insensitive. Model matching is exact. */ export declare function lookupModelPrice(modelRef: string): ModelPriceRow | undefined; /** * Estimate USD cost for a single model call. * * Returns `0` when no row matches `modelRef` — callers should treat 0 as * "unknown" and not overwrite an existing `costUsd` from the provider. */ export declare function estimateCostUsd(modelRef: string, usage: ModelPricingUsage): number; /** * Idempotently populate `usage.costUsd` from the static price table. Mutates * `usage` and returns it. No-op when: * - `usage` is undefined, * - `usage.costUsd` is already set (provider supplied it directly), * - no price row matches `modelRef`. */ export declare function applyEstimatedCost(modelRef: string | undefined, usage: T): T; //# sourceMappingURL=model-pricing.d.ts.map