/** * 多厂商价目表(数据与代码分离,改价只动这个文件)。 * * 每一条都逐项核对自厂商官方定价页,核对日期见 PRICING_VERSION。 * **宁可不列,不可写错**:定价结构复杂到无法确信的厂商(例如按输入长度 * 分段计价的),这里不放推测值 —— 未知模型会被标为「未定价」,用户可用 * config.prices 自行补,或提 PR 补进来。 * * 价格按「生效区间」组织:一个模型可以有多段价格,按事件发生的时刻选段, * 历史账单跨调价日各按各价。DeepSeek 2026-08-17 的整表换新就走这条路。 */ /** 单模型单币种费率:每百万 tokens。 */ export interface ModelRates { /** 输入・缓存命中(读取)。 */ hit: number /** 输入・未命中(基础输入价)。 */ miss: number /** 输出。 */ out: number /** * 缓存写入价。缺省时按 `miss` 计 —— DeepSeek 等厂商无独立写入价; * Anthropic 的 5 分钟缓存写入是基础输入价的 1.25 倍,必须显式给出。 */ write?: number } /** * 用量分档:国内厂商普遍按单次请求的输入/输出长度分段计价 * (如 GLM-5.1 输入 <32K 走一档、≥32K 走另一档)。 * 档位按顺序匹配,第一个满足上限的胜出;上限缺省表示不封顶。 */ export interface SizeTier { /** 输入 tokens 上限(不含)。 */ maxInput?: number /** 输出 tokens 上限(不含)。 */ maxOutput?: number rates: ModelRates } /** 一个模型在某价格段的费率。不区分峰谷时两者相同。 */ export interface TieredRates { peak: ModelRates offPeak: ModelRates /** * 按单次请求用量分档的费率(可选)。给出时优先于 peak/offPeak, * 未命中任何档位则回落到 peak。 */ bySize?: readonly SizeTier[] } /** 一段生效期内的价格。 */ export interface PricePeriod { /** 生效起始时刻(含),Unix epoch 毫秒;0 表示「一直以来」。 */ from: number /** 该段是否按高峰/空闲分档计价。 */ tiered: boolean /** 官方人民币报价(仅国内厂商公布)。 */ cny?: TieredRates /** 官方美元报价。 */ usd?: TieredRates } export interface ModelPricing { /** 模型 id 匹配串(小写包含匹配;查价时长匹配串优先)。 */ match: string /** 厂商标识,用于面板分组展示。 */ provider: string /** 展示名。 */ label: string /** 价格段,按 from 升序。 */ periods: readonly PricePeriod[] } /** 价目表版本(对外展示,也是「最后一次逐项核对官方页」的日期)。 */ export const PRICING_VERSION = '2026-08-16' /** * 2026-08-17 00:00(北京时间)= 2026-08-16 16:00 UTC,DeepSeek 新价目生效时刻。 * 官方同时在这一刻开始实施峰谷计价。 */ export const NEW_PRICING_FROM_MS = Date.UTC(2026, 7, 16, 16, 0, 0) /** * 高峰时段(UTC 小时区间,[start, end)): * 北京 9:00-12:00 → UTC 1:00-4:00;北京 14:00-18:00 → UTC 6:00-10:00。 * 目前仅 DeepSeek 采用峰谷计价。 */ export const PEAK_WINDOWS_UTC: readonly [number, number][] = [ [1, 4], [6, 10], ] /** * 汇率兜底:把只有单一币种官方报价的模型换算到展示币种。 * 这是估算,不是官方汇率;用户可用 config.usdToCny 覆盖。 */ export const DEFAULT_USD_TO_CNY = 7.2 /** 不分峰谷的构造助手:两档同价。 */ function flat(rates: ModelRates): TieredRates { return { peak: rates, offPeak: rates } } /** 一直有效、不分峰谷、只有美元官方价的常规条目。 */ function usdOnly(match: string, provider: string, label: string, rates: ModelRates): ModelPricing { return { match, provider, label, periods: [{ from: 0, tiered: false, usd: flat(rates) }] } } /** 一直有效、只有人民币官方价、按用量分档的条目(国内厂商常见)。 */ function cnyTiers(match: string, provider: string, label: string, tiers: readonly SizeTier[]): ModelPricing { return { match, provider, label, periods: [{ from: 0, tiered: false, // 未命中任何档位时的回落价 = 最后一档(通常是最贵的不封顶档)。 cny: { peak: tiers[tiers.length - 1].rates, offPeak: tiers[tiers.length - 1].rates, bySize: tiers }, }], } } /** 一直有效、只有人民币官方价、单一费率的条目。 */ function cnyOnly(match: string, provider: string, label: string, rates: ModelRates): ModelPricing { return { match, provider, label, periods: [{ from: 0, tiered: false, cny: flat(rates) }] } } /** * DeepSeek —— 来源 https://api-docs.deepseek.com/zh-cn/quick_start/pricing * 2026-08-17 00:00(北京时间)起整张表换新,并开始峰谷计价。 */ const DEEPSEEK: readonly ModelPricing[] = [ { match: 'v4-flash', provider: 'deepseek', label: 'DeepSeek V4 Flash', periods: [ { from: 0, tiered: false, cny: flat({ hit: 0.02, miss: 1, out: 2 }), usd: flat({ hit: 0.0028, miss: 0.14, out: 0.28 }), }, { from: NEW_PRICING_FROM_MS, tiered: true, cny: { peak: { hit: 0.10, miss: 3, out: 9 }, offPeak: { hit: 0.05, miss: 1.5, out: 4.5 } }, usd: { peak: { hit: 0.014, miss: 0.44, out: 1.32 }, offPeak: { hit: 0.007, miss: 0.22, out: 0.66 } }, }, ], }, { match: 'v4-pro', provider: 'deepseek', label: 'DeepSeek V4 Pro', periods: [ { from: 0, tiered: false, cny: flat({ hit: 0.025, miss: 3, out: 6 }), usd: flat({ hit: 0.003625, miss: 0.435, out: 0.87 }), }, { from: NEW_PRICING_FROM_MS, tiered: true, cny: { peak: { hit: 0.30, miss: 9, out: 27 }, offPeak: { hit: 0.15, miss: 4.5, out: 13.5 } }, usd: { peak: { hit: 0.044, miss: 1.32, out: 3.96 }, offPeak: { hit: 0.022, miss: 0.66, out: 1.98 } }, }, ], }, // 旧世代模型名,仅供历史数据归因。 { match: 'deepseek-chat', provider: 'deepseek', label: 'DeepSeek Chat (legacy)', periods: [{ from: 0, tiered: false, cny: flat({ hit: 0.2, miss: 2, out: 3 }), usd: flat({ hit: 0.028, miss: 0.28, out: 0.42 }) }], }, { match: 'deepseek-reasoner', provider: 'deepseek', label: 'DeepSeek Reasoner (legacy)', periods: [{ from: 0, tiered: false, cny: flat({ hit: 0.2, miss: 2, out: 3 }), usd: flat({ hit: 0.028, miss: 0.28, out: 0.42 }) }], }, ] /** * Anthropic —— 来源 https://platform.claude.com/docs/en/about-claude/pricing * 缓存写入按 5 分钟档(基础输入价 ×1.25);缓存读取为 ×0.1。 */ const ANTHROPIC: readonly ModelPricing[] = [ usdOnly('claude-fable-5', 'anthropic', 'Claude Fable 5', { hit: 1, miss: 10, out: 50, write: 12.5 }), usdOnly('claude-opus-5', 'anthropic', 'Claude Opus 5', { hit: 0.5, miss: 5, out: 25, write: 6.25 }), usdOnly('claude-opus-4-8', 'anthropic', 'Claude Opus 4.8', { hit: 0.5, miss: 5, out: 25, write: 6.25 }), usdOnly('claude-opus-4-7', 'anthropic', 'Claude Opus 4.7', { hit: 0.5, miss: 5, out: 25, write: 6.25 }), usdOnly('claude-opus-4-6', 'anthropic', 'Claude Opus 4.6', { hit: 0.5, miss: 5, out: 25, write: 6.25 }), usdOnly('claude-opus-4-5', 'anthropic', 'Claude Opus 4.5', { hit: 0.5, miss: 5, out: 25, write: 6.25 }), usdOnly('claude-sonnet-5', 'anthropic', 'Claude Sonnet 5', { hit: 0.2, miss: 2, out: 10, write: 2.5 }), usdOnly('claude-sonnet-4-6', 'anthropic', 'Claude Sonnet 4.6', { hit: 0.3, miss: 3, out: 15, write: 3.75 }), usdOnly('claude-sonnet-4-5', 'anthropic', 'Claude Sonnet 4.5', { hit: 0.3, miss: 3, out: 15, write: 3.75 }), usdOnly('claude-haiku-4-5', 'anthropic', 'Claude Haiku 4.5', { hit: 0.1, miss: 1, out: 5, write: 1.25 }), ] /** * OpenAI —— 来源 https://developers.openai.com/api/docs/pricing(标准档) * 匹配串长者优先,故 gpt-5.6-luna 不会被 gpt-5 抢先命中。 */ const OPENAI: readonly ModelPricing[] = [ usdOnly('gpt-5.6-sol', 'openai', 'GPT-5.6 Sol', { hit: 0.5, miss: 5, out: 30 }), usdOnly('gpt-5.6-terra', 'openai', 'GPT-5.6 Terra', { hit: 0.2, miss: 2, out: 12 }), usdOnly('gpt-5.6-luna', 'openai', 'GPT-5.6 Luna', { hit: 0.02, miss: 0.2, out: 1.2 }), usdOnly('gpt-5.5', 'openai', 'GPT-5.5', { hit: 0.5, miss: 5, out: 30 }), usdOnly('gpt-5.4-mini', 'openai', 'GPT-5.4 mini', { hit: 0.075, miss: 0.75, out: 4.5 }), usdOnly('gpt-5.4-nano', 'openai', 'GPT-5.4 nano', { hit: 0.02, miss: 0.2, out: 1.25 }), usdOnly('gpt-5.4', 'openai', 'GPT-5.4', { hit: 0.25, miss: 2.5, out: 15 }), usdOnly('gpt-5-mini', 'openai', 'GPT-5 mini', { hit: 0.025, miss: 0.25, out: 2 }), usdOnly('gpt-5-nano', 'openai', 'GPT-5 nano', { hit: 0.005, miss: 0.05, out: 0.4 }), usdOnly('gpt-5', 'openai', 'GPT-5', { hit: 0.125, miss: 1.25, out: 10 }), usdOnly('gpt-4o-mini', 'openai', 'GPT-4o mini', { hit: 0.075, miss: 0.15, out: 0.6 }), usdOnly('gpt-4o', 'openai', 'GPT-4o', { hit: 1.25, miss: 2.5, out: 10 }), usdOnly('o3-mini', 'openai', 'o3-mini', { hit: 0.55, miss: 1.1, out: 4.4 }), ] /** * Google Gemini —— 来源 https://ai.google.dev/gemini-api/docs/pricing(付费档) * 2.5 Pro / 2.5 Flash 等按上下文长度或模态分段的价目,这里取基础档; * 长上下文请求的实际单价可能更高,面板金额相应偏低。 */ const GOOGLE: readonly ModelPricing[] = [ usdOnly('gemini-3.7-flash', 'google', 'Gemini 3.7 Flash', { hit: 0.075, miss: 0.75, out: 3.75 }), usdOnly('gemini-3.6-flash', 'google', 'Gemini 3.6 Flash', { hit: 0.075, miss: 0.75, out: 3.75 }), usdOnly('gemini-3.5-flash-lite', 'google', 'Gemini 3.5 Flash-Lite', { hit: 0.03, miss: 0.3, out: 2.5 }), usdOnly('gemini-3.5-flash', 'google', 'Gemini 3.5 Flash', { hit: 0.15, miss: 1.5, out: 9 }), usdOnly('gemini-2.5-flash-lite', 'google', 'Gemini 2.5 Flash-Lite', { hit: 0.01, miss: 0.1, out: 0.4 }), usdOnly('gemini-2.5-flash', 'google', 'Gemini 2.5 Flash', { hit: 0.03, miss: 0.3, out: 2.5 }), usdOnly('gemini-2.5-pro', 'google', 'Gemini 2.5 Pro', { hit: 0.125, miss: 1.25, out: 10 }), ] /** 千 tokens(智谱定价页的长度档位以千 tokens 计)。 */ const K = 1_000 /** * 智谱 GLM —— 来源 https://open.bigmodel.cn/pricing * 按单次请求的输入(部分还看输出)长度分档计价,单位:元/百万 tokens。 * 「缓存存储」按小时计费,与 token 计量模型不同,这里不计入。 */ const ZHIPU: readonly ModelPricing[] = [ cnyOnly('glm-5.2', 'zhipu', 'GLM-5.2', { hit: 2, miss: 8, out: 28 }), cnyTiers('glm-5.1', 'zhipu', 'GLM-5.1', [ { maxInput: 32 * K, rates: { hit: 1.3, miss: 6, out: 24 } }, { rates: { hit: 2, miss: 8, out: 28 } }, ]), cnyTiers('glm-5-turbo', 'zhipu', 'GLM-5-Turbo', [ { maxInput: 32 * K, rates: { hit: 1.2, miss: 5, out: 22 } }, { rates: { hit: 1.8, miss: 7, out: 26 } }, ]), cnyTiers('glm-5', 'zhipu', 'GLM-5', [ { maxInput: 32 * K, rates: { hit: 1, miss: 4, out: 18 } }, { rates: { hit: 1.5, miss: 6, out: 22 } }, ]), cnyTiers('glm-4.7-flashx', 'zhipu', 'GLM-4.7-FlashX', [ { rates: { hit: 0.1, miss: 0.5, out: 3 } }, ]), cnyTiers('glm-4.7-flash', 'zhipu', 'GLM-4.7-Flash', [ { rates: { hit: 0, miss: 0, out: 0 } }, // 官方标注免费 ]), cnyTiers('glm-4.7', 'zhipu', 'GLM-4.7', [ { maxInput: 32 * K, maxOutput: 0.2 * K, rates: { hit: 0.4, miss: 2, out: 8 } }, { maxInput: 32 * K, rates: { hit: 0.6, miss: 3, out: 14 } }, { rates: { hit: 0.8, miss: 4, out: 16 } }, ]), cnyTiers('glm-4.5-air', 'zhipu', 'GLM-4.5-Air', [ { maxInput: 32 * K, maxOutput: 0.2 * K, rates: { hit: 0.16, miss: 0.8, out: 2 } }, { maxInput: 32 * K, rates: { hit: 0.16, miss: 0.8, out: 6 } }, { rates: { hit: 0.24, miss: 1.2, out: 8 } }, ]), ] /** * 月之暗面 Kimi —— 来源 https://platform.kimi.com/docs/pricing/chat * (各模型定价子页逐个核对)。单一费率,不分档。 */ const MOONSHOT: readonly ModelPricing[] = [ cnyOnly('kimi-k3', 'moonshot', 'Kimi K3', { hit: 2, miss: 20, out: 100 }), cnyOnly('kimi-k2.7-code-highspeed', 'moonshot', 'Kimi K2.7 Code HighSpeed', { hit: 2.6, miss: 13, out: 54 }), cnyOnly('kimi-k2.7-code', 'moonshot', 'Kimi K2.7 Code', { hit: 1.3, miss: 6.5, out: 27 }), cnyOnly('kimi-k2.6', 'moonshot', 'Kimi K2.6', { hit: 1.1, miss: 6.5, out: 27 }), ] /** 全部内置价目。查价时按 match 长度降序,长匹配串优先。 */ export const PRICING_TABLE: readonly ModelPricing[] = [ ...DEEPSEEK, ...ANTHROPIC, ...OPENAI, ...GOOGLE, ...ZHIPU, ...MOONSHOT, ] /** 厂商展示名。 */ export const PROVIDER_LABELS: Record = { deepseek: 'DeepSeek', anthropic: 'Anthropic', openai: 'OpenAI', google: 'Google', zhipu: '智谱 GLM', moonshot: '月之暗面 Kimi', }