/** * DeepSeek API price table and cost estimation. * * Every record is priced with the table that was in force at the moment it was * written — CNY per 1M tokens, from DeepSeek's official pricing page: * * - until 2026-08-17 00:00 Beijing: one flat price per model; * - 2026-08-17 00:00: peak/off-peak pricing — peak windows 09:00–12:00 and * 14:00–18:00 every day, off-peak exactly half of peak; * - 2026-09-10 12:00: the V4.1-Flash price cut (flash 0.04/2/8 peak), and the * peak windows narrow to Monday–Friday; * - 2026-09-14 12:00: `deepseek-v4-pro` requests are served by V4.1-Flash and * billed at Flash rates until a V4.1 Pro ships. * * `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp` are legacy names for * the model now published as `deepseek-flash`; both keep billing at Flash * rates. Images cost tokens rather than a multiplier of their own: they are * converted by size and priced together with the text tokens. Historical days * therefore keep the price that was actually charged. * * Editing this table is the one place to touch when DeepSeek changes prices. */ import type { PricingInfo, PricingRates } from './contract.ts'; /** 2026-08-17 00:00 Beijing time (UTC+8), when peak/off-peak pricing took effect. */ export declare const PEAK_PRICING_FROM_MS: number; /** 2026-09-10 12:00 Beijing, when the V4.1-Flash prices and the weekday-only * peak windows took effect. */ export declare const V41_FLASH_PRICING_FROM_MS: number; /** 2026-09-14 12:00 Beijing, from when `deepseek-v4-pro` requests are routed * to V4.1-Flash and billed at Flash rates. */ export declare const PRO_ROUTED_TO_FLASH_FROM_MS: number; type Tier = 'pro' | 'flash' | 'vision'; /** Which price tier a model name falls into; anything unrecognised is billed * as pro, the conservative (more expensive) guess. Vision is matched first: * `deepseek-v4-flash-vision-exp` also contains "flash". */ export declare function tierOf(model: string): Tier; /** * Image token conversion (DeepSeek official rule, Vision guide): * - Images below roughly 384×384 pixels are scaled UP preserving aspect * ratio; larger images are scaled DOWN so their pixel count is roughly that * of an 800×800 image. * - Tokens are proportional to the (resized) pixel count, capped at 384 * tokens per image, so 2000×2000 and 5000×5000 cost the same. * - Each image is counted independently; `detail: low` caps at 512×512. * * The estimate is for the "how much came from images" breakdown; the exact * provider count is already folded into the usage record's `inputTokens`. * Returns tokens (possibly fractional) — 0 for missing/invalid dimensions. */ export declare function estimateImageTokens(width: number, height: number): number; /** Whether a moment falls in a peak window, judged in Beijing time so the * estimate does not drift with the machine's timezone. */ export declare function isPeak(timeMs: number): boolean; /** Rates applying to one model at one moment. */ export declare function ratesAt(timeMs: number, model: string): PricingRates; /** * What prefix caching saved on one record: the cache-hit tokens re-priced at * the cache-miss rate, minus what they actually cost. */ export declare function cacheSavingOf(timeMs: number, model: string, cache: number): number; /** Estimated CNY cost of one usage record. */ export declare function costOf(timeMs: number, model: string, input: number, cache: number, output: number): number; /** * The same record priced as if it had landed in an idle window — used to * answer "what would shifting work off-peak save me". Prices come from the * newest table, the one in force now: the question is about scheduling the * next batch, not about re-pricing history. */ export declare function costUnderPeakEra(timeMs: number, model: string, input: number, cache: number, output: number, forceOffPeak?: boolean): number; /** The price table to show the user: the two models the official docs list, * so the rows match the page they come from — legacy names, image tokens and * the pro routing live in the small print next to the table. */ export declare function pricingInfo(nowMs: number): PricingInfo; export {};