import type { ProviderPricingBasis } from "./plan.js"; /** * Synchronous provider billing-basis cost — * the configured-list-rate calculation used when a provider (Azure) reports * usage but not dollars. OpenRouter's provider-reported cost keeps the * existing path in `llm.ts` and never goes through this function. * * Results are USD cents at the inference log's numeric(10, 4) precision. */ export interface BillingBasisUsage { readonly inputTokens: number; /** * Provider-reported cached (discounted) input tokens. Whether this is a * subset of `inputTokens` or a disjoint count is DECLARED by the binding's * `cachedTokenSemantics` — never inferred from the relative sizes. */ readonly cachedInputTokens: number; /** * Provider completion-token total. Already includes reasoning tokens — do * not add them a second time. */ readonly outputTokens: number; } export type BillingBasisResult = Readonly<{ ok: true; costCents: number; }> | Readonly<{ ok: false; reason: string; }>; /** * Compute the list-rate cost in USD cents from usage and configured * per-million-token rates. Rejects internally inconsistent usage rather than * producing a zero-cost call: negative counts, non-integers, * all-zero usage (a request always consumes prompt tokens — zeros mean the * provider's accounting is broken, not that the call was free), and — under * declared `"subset"` semantics — cached counts exceeding total input. * * The uncached-input calculation follows the binding's declared * `cachedTokenSemantics`: * - `"subset"` — cached ⊆ input (OpenAI): uncached = input − cached. * - `"disjoint"` — cached reported alongside input (Grok via Azure AI * Foundry, observed live: cached 192 vs prompt 88): uncached = input. * Either way every token prices exactly once at its own rate. */ export declare function computeConfiguredRatesCostCents(pricing: Extract, usage: BillingBasisUsage): BillingBasisResult;