/** * Token-bucket pricing. * * DeepSeek bills three input/output tiers — cache-hit input, cache-miss input and * output — and applies one uniform multiplier off-peak ("空闲时段价格为高峰时段价格 * 的一半"). The table therefore holds **peak** rates only and the schedule supplies * the multiplier, which keeps a single correction factor meaningful across both * periods. `cacheWriteTokens` has no published tier of its own and is priced as * cache-miss input unless a table entry overrides it. * * @module dsh-balance/pricing */ /** The four disjoint provider-reported token buckets. */ export interface TokenBuckets { readonly uncachedInput: number; readonly output: number; readonly cacheRead: number; readonly cacheWrite: number; } /** Relative cost shape used when no price-table entry matches a route. */ export interface TokenWeights { readonly uncachedInput: number; readonly cacheWrite: number; readonly cacheRead: number; readonly output: number; } /** Peak rates for one route, in the table's currency per 1M tokens. */ export interface PriceRates { /** Cache-miss input rate. */ readonly input: number; /** Cache-hit input rate. */ readonly cacheRead: number; /** Output rate. */ readonly output: number; /** Cache-write rate; defaults to {@link PriceRates.input} when omitted. */ readonly cacheWrite?: number; } /** Route key to peak rates. Keys are `"/"` or bare `""`. */ export type PriceTable = Readonly>; /** Weight shape applied to routes the table does not describe. */ export declare const DEFAULT_WEIGHTS: TokenWeights; /** * Built-in peak rates for the models this deployment runs, in CNY per 1M tokens. * Source: the official pricing table (2026-10), whose model ids match the ones * configured by the stock profile. Prices change; the estimator's correction * factor absorbs a uniform drift, and the panel surfaces that drift for review. */ export declare const BUILTIN_PRICE_TABLE: PriceTable; /** The route recorded when no `request/context` was observed for a session. */ export declare const UNKNOWN_ROUTE = "unknown"; /** * Resolve the peak rates for one route. * @param table - the effective price table. * @param route - `"/"` as reported by `request/context`. * @returns the entry, or null when neither the full route nor the bare model matched. */ export declare function resolveRates(table: PriceTable, route: string): PriceRates | null; /** * Merge configured rates over the built-ins so adding one model does not drop the * shipped entries; a configured entry replaces a built-in of the same key. * @param configured - rates from plugin config. * @returns the effective table. */ export declare function mergePriceTables(configured: PriceTable): PriceTable; /** * Price one token bucket. * * @param buckets - tokens accumulated in one bucket set. * @param rates - resolved peak rates, or null to price with `weights`. * @param weights - fallback relative shape, used when `rates` is null. * @param factor - schedule multiplier at the tokens' occurrence time. * @returns the cost in the table's currency, or an arbitrary unit under `weights`. */ export declare function costOf(buckets: TokenBuckets, rates: PriceRates | null, weights: TokenWeights, factor: number): number; /** * Routes among `routes` that no table entry describes. * @param routes - observed `"/"` keys. * @param table - the effective price table. * @returns the unmatched routes, sorted and de-duplicated. */ export declare function unmatchedRoutes(routes: Iterable, table: PriceTable): readonly string[];