import type { ModelPrice, PricingTable } from './types.js'; /** * Prices for models the built-in tables have not caught up with yet. * * A pricing table captured on one date cannot price a model released on the * next, and until now the only remedies were a release or a hand-written * override. Every Claude Code turn on a new model therefore reported its cost as * unavailable, for every user, until one of those happened. * * LiteLLM publishes a community-maintained price list that tracks releases * closely. This module turns the Anthropic first-party entries of that list into * {@link ModelPrice}s and caches them on disk; `src/services/pricing-refresh.ts` * is what downloads it. Two rules keep it honest: * * - It only **fills gaps**. A model the built-in tables price keeps the * built-in price, so a community entry can never change a number this * package already vouches for. * - A model is taken only if the list gives **every** rate the engine needs -- * input, output, cache read, and both cache-write TTLs. A missing rate is not * inherited from a default, because the defaults are exactly what newer * models break: Opus 5.5 reads cache at 0.05x its input rate, not 0.1x. */ /** LiteLLM's price list, as published in its repository. */ export declare const COMMUNITY_PRICING_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"; /** The URL in force: `AI_USAGE_PRICING_URL` points at a mirror, or at a test server. */ export declare function communityPricingUrl(env?: NodeJS.ProcessEnv): string; /** * Why community prices are off, or undefined when they are on. * * `AI_USAGE_NO_UPDATE_CHECK=1` turns this off too. It was documented as turning * off the package's only network request, and somebody who set it for that * reason must not find a new request running after an upgrade. Off means off * entirely: a cached list is not read either, so the prices in force are exactly * the built-in tables plus any override -- reproducible, and what tests rely on. */ export declare function communityPricingDisabledBy(env?: NodeJS.ProcessEnv): string | undefined; /** The converted list, as cached on disk. */ export interface CommunityPricing { /** When the list was downloaded, ISO 8601. */ fetchedAt: string; /** Where it was downloaded from. */ source: string; models: Record; } export interface ConvertedList { models: Record; /** Anthropic entries that were not taken, with the reason. */ skipped: Record; } /** * The Anthropic first-party chat models in a LiteLLM price list. * * Partner platforms (Bedrock, Vertex) carry their own prices under prefixed keys * and are not taken, matching the built-in table's scope. */ export declare function convertLiteLLMPrices(raw: unknown): ConvertedList; /** * The cached list, or undefined when there is none or it cannot be trusted. * * Never throws. Unlike a user's override -- where a typo must stop the tool -- * this file is ours: a corrupt copy just means the next refresh replaces it. * An entry that fails validation is dropped rather than half-used. */ export declare function readCommunityPricing(path: string): CommunityPricing | undefined; /** * Writes the cache through a temporary file, so a CLI starting while the server * refreshes reads the old list or the new one, never half of one. */ export declare function writeCommunityPricing(path: string, pricing: CommunityPricing): void; /** * Adds the community models a base table lacks. * * Returns the base table itself, untouched, when there is nothing to add, so a * list that merely agrees with the built-in tables changes no version string. */ export declare function withCommunityPricing(base: PricingTable, community: CommunityPricing): { table: PricingTable; added: string[]; };