Skip to content

Commit 0771621

Browse files
committed
feat: 更新官方价格快照,新增支持的 Fast 模型及其费率
1 parent da21d6f commit 0771621

7 files changed

Lines changed: 202 additions & 15 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<p align="center">
66
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage" target="_blank" rel="noopener noreferrer"><img alt="npm" src="https://img.shields.io/npm/v/%40chenlongapps%2Fopencode-token-usage?style=flat-square&logo=npm" /></a>
7-
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage" target="_blank" rel="noopener noreferrer"><img alt="npm downloads" src="https://img.shields.io/npm/dy/@chenlongapps/opencode-token-usage" /></a>
7+
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage" target="_blank" rel="noopener noreferrer"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@chenlongapps/opencode-token-usage" /></a>
88
<a href="https://opencode.ai/" target="_blank" rel="noopener noreferrer"><img alt="OpenCode 2" src="https://img.shields.io/badge/OpenCode-2-5A67D8?style=flat-square" /></a>
99
<a href="https://github.com/chenlongapps/opencode-token-usage/actions/workflows/ci.yml" target="_blank" rel="noopener noreferrer"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/chenlongapps/opencode-token-usage/ci.yml?style=flat-square&branch=main&label=ci" /></a>
1010
<a href="LICENSE" target="_blank" rel="noopener noreferrer"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-yellow?style=flat-square" /></a>

‎README.zh-CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<p align="center">
66
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage" target="_blank" rel="noopener noreferrer"><img alt="npm" src="https://img.shields.io/npm/v/%40chenlongapps%2Fopencode-token-usage?style=flat-square&logo=npm" /></a>
7+
<a href="https://www.npmjs.com/package/@chenlongapps/opencode-token-usage" target="_blank" rel="noopener noreferrer"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@chenlongapps/opencode-token-usage" /></a>
78
<a href="https://opencode.ai/" target="_blank" rel="noopener noreferrer"><img alt="OpenCode 2" src="https://img.shields.io/badge/OpenCode-2-5A67D8?style=flat-square" /></a>
89
<a href="https://github.com/chenlongapps/opencode-token-usage/actions/workflows/ci.yml" target="_blank" rel="noopener noreferrer"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/chenlongapps/opencode-token-usage/ci.yml?style=flat-square&branch=main&label=ci" /></a>
910
<a href="LICENSE" target="_blank" rel="noopener noreferrer"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-yellow?style=flat-square" /></a>

‎ROADMAP.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Steps 1,234
9494

9595
* [ ] 添加 `/usage`
9696
* [ ] 显示当前会话及会话树统计
97+
* [ ] 显示 context 各项占比
9798
* [ ] 显示 token 明细与上下文用量
9899
* [ ] 显示模型和价格信息
99100
* [ ] 显示估算费用明细

‎docs/pricing.md‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# 内置官方价格快照
22

3-
插件自 v0.3.0 起,在 OpenCode 当前模型目录没有可用于某条消息的完整价格时,使用本页所列的公开 API 价格补全。若 OpenCode 给出完整零价,而快照能完整计价,则使用快照价格。快照核验于 **2026-09-23**,共收录 79 个模型,金额均为美元 / 100 万 token。
3+
插件自 v0.3.0 起,在 OpenCode 当前模型目录没有可用于某条消息的完整价格时,使用本页所列的公开 API 价格补全。若 OpenCode 给出完整零价,而快照能完整计价,则使用快照价格。快照核验于 **2026-09-23**,共收录 86 个模型,金额均为美元 / 100 万 token。
44

55
## 规则
66

77
- 每条 assistant 与 compaction 消息按自身记录的 `providerID`、模型 ID 和 token 用量分别计算。
88
- OpenCode 当前解析出的完整适用非零价格优先。若完整适用价格为零,则尝试使用内置价格;只有快照能完整覆盖该消息实际使用的 token 类别时才覆盖零价,否则保留 OpenCode 的零价。OpenCode 价格不完整时,整条消息回退到内置价格,不混用两套费率。
9-
- 网关模型只通过精确厂商 ID、精确别名及已知包装格式匹配,例如 `openai/gpt-5.6-luna`、`us.anthropic.claude-opus-5` 和 `claude-opus-5@default`。匹配这些现有形式后,也会尝试仅移除模型 ID 的末尾 `-free` 或 `:free` 再精确匹配基础 ID,例如 `mimo-v2.6-flash-free`、`meta/muse-spark-1.3:free` 和 `muse-spark-1.3-contributor-free`;`-pro`、`-fast`、`-free-preview` 等其他后缀不会剥离。不按相似名称猜测。
9+
- 网关模型只通过精确厂商 ID、精确别名及已知包装格式匹配,例如 `openai/gpt-5.6-luna`、`us.anthropic.claude-opus-5` 和 `claude-opus-5@default`。匹配这些现有形式后,也会尝试仅移除模型 ID 的末尾 `-free` 或 `:free` 再精确匹配基础 ID,例如 `mimo-v2.6-flash-free`、`meta/muse-spark-1.3:free` 和 `muse-spark-1.3-contributor-free`;`-pro`、`-fast`、`-free-preview` 等其他后缀不会剥离。单独列出的 Fast 型号仅按完整 ID 和厂商支持的 provider 精确匹配,不会回退到标准费率。不按相似名称猜测。
1010
- 目录首版只新增 2026-03-22 至 2026-09-22 发布、具有明确 token 费率的模型。后续版本只限制新增窗口,已经收录的条目不会因超过半年而自动删除。
11-
- 采用标准同步 API 的公开价;Meta Contributor 条件价按单独标注的来源记录。不含 Batch、Flex、Fast/Priority、区域溢价、网关加价、企业折扣、工具费和税费,因此 Cost 仍是估算,不代表账单。
11+
- 采用同步 API 的公开价;Meta Contributor 条件价按单独标注的来源记录。仅收录下表明确列出的 Fast 型号,不含 Batch、Flex、其他 Fast/Priority、区域溢价、网关加价、企业折扣、工具费和税费,因此 Cost 仍是估算,不代表账单。
1212
- 任一有用量消息仍无法定价时,已知小计标记 `partial`;全部无法定价时显示 `—`。明确零价才显示 `$0.00`。
1313
- 促销价按核验日官网显示的费率收录(如 `gpt-5.6-sol`、MiniMax-M3 的"长期 5 折"标价),不用划线原价。
1414

@@ -19,16 +19,23 @@
1919
| 模型 | 发布日期 | Input | Output | Cache Read | Cache Write | 长上下文档位 |
2020
| --- | --- | ---: | ---: | ---: | ---: | --- |
2121
| `gpt-5.5` | 2026-04-23 | 5 | 30 | 0.5 | — | >272K:10 / 45 / 1 / — |
22+
| `gpt-5.5-fast`(Fast) | 2026-04-23 | 12.5 | 75 | 1.25 | — | >272K:无官方 Fast 费率 |
2223
| `gpt-5.5-pro` | 2026-04-23 | 30 | 180 | — | — | >272K:60 / 270 / — / — |
2324
| `gpt-5.6-sol` | 2026-07-09 | 4 | 20 | 0.4 | 5 | >272K:8 / 30 / 0.8 / 10 |
25+
| `gpt-5.6-sol-fast`(Fast) | 2026-07-09 | 8 | 40 | 0.8 | 10 | >272K:16 / 60 / 1.6 / 20 |
2426
| `gpt-5.6-terra` | 2026-07-09 | 2 | 12 | 0.2 | 2.5 | >272K:4 / 18 / 0.4 / 5 |
27+
| `gpt-5.6-terra-fast`(Fast) | 2026-07-09 | 4 | 24 | 0.4 | 5 | >272K:8 / 36 / 0.8 / 10 |
2528
| `gpt-5.6-luna` | 2026-07-09 | 0.2 | 1.2 | 0.02 | 0.25 | >272K:0.4 / 1.8 / 0.04 / 0.5 |
29+
| `gpt-5.6-luna-fast`(Fast) | 2026-07-09 | 0.4 | 2.4 | 0.04 | 0.5 | >272K:0.8 / 3.6 / 0.08 / 1 |
2630
| `gpt-6-astra` | 2026-09-04 | 10 | 50 | 1 | 12.5 | >272K:20 / 75 / 2 / 25 |
31+
| `gpt-6-astra-fast`(Fast) | 2026-09-04 | 20 | 100 | 2 | 25 | >272K:40 / 150 / 4 / 50 |
2732
| `gpt-6-sol` | 2026-09-22 | 2 | 10 | 0.2 | 2.5 | >272K:4 / 15 / 0.4 / 5 |
33+
| `gpt-6-sol-fast`(Fast) | 2026-09-22 | 4 | 20 | 0.4 | 5 | >272K:8 / 30 / 0.8 / 10 |
2834
| `gpt-6-luna` | 2026-09-22 | 0.1 | 0.5 | 0.01 | 0.125 | >272K:0.2 / 0.75 / 0.02 / 0.25 |
35+
| `gpt-6-luna-fast`(Fast) | 2026-09-22 | 0.2 | 1 | 0.02 | 0.25 | >272K:0.4 / 1.5 / 0.04 / 0.5 |
2936
| `chat-latest`(别名 `gpt-chat-latest`) | 2026-05-05 | 5 | 30 | 0.5 | — | — |
3037

31-
`gpt-6-sol` 和 `gpt-6-luna` 的发布日期见 [OpenAI API 更新日志](https://developers.openai.com/api/docs/changelog)。表内 OpenAI 长上下文价格在传入 token 超过 272,000 时对整条请求生效。`gpt-5.6-sol` 的当前标准价是限期促销价;快照采用核验日官网显示的费率。`chat-latest` 是官方 ChatGPT SKU,OpenRouter 上的 `gpt-chat-latest` 作为精确别名指向同一条目。
38+
`gpt-6-sol` 和 `gpt-6-luna` 的发布日期见 [OpenAI API 更新日志](https://developers.openai.com/api/docs/changelog)。表内 OpenAI 长上下文价格在传入 token 超过 272,000 时对整条请求生效。Fast 条目对应官方 Fast processing 费率;API 通过基础模型配合 `service_tier: "fast"` 选择该档,因此只有以对应 `-fast` ID 记录的 OpenAI 消息使用 Fast 价格,其他 provider 不匹配这些条目。官方未公布 `gpt-5.5` Fast 长上下文费率,故超过 272,000 个传入 token 时标记为不可估价,不沿用短上下文价。`gpt-5.6-sol` 的当前标准价是限期促销价;快照采用核验日官网显示的费率。`chat-latest` 是官方 ChatGPT SKU,OpenRouter 上的 `gpt-chat-latest` 作为精确别名指向同一条目。
3239

3340
## Anthropic
3441

@@ -38,16 +45,21 @@
3845
| --- | --- | ---: | ---: | ---: | ---: |
3946
| `claude-opus-4-7` | 2026-04-14 | 5 | 25 | 0.5 | 6.25 |
4047
| `claude-opus-4-8` | 2026-05-28 | 5 | 25 | 0.5 | 6.25 |
48+
| `claude-opus-4-8-fast`(Fast) | 2026-05-28 | 10 | 50 | 1 | 12.5 |
4149
| `claude-fable-5` | 2026-06-07 | 10 | 50 | 1 | 12.5 |
4250
| `claude-sonnet-5` | 2026-06-29 | 2 | 10 | 0.2 | 2.5 |
4351
| `claude-opus-5` | 2026-07-24 | 5 | 25 | 0.5 | 6.25 |
52+
| `claude-opus-5-fast`(Fast) | 2026-07-24 | 10 | 50 | 1 | 12.5 |
4453
| `claude-fable-5-1` | 2026-09-01 | 10 | 50 | 0.25 | 12.5 |
4554
| `claude-opus-5-5` | 2026-09-22 | 4 | 20 | 0.2 | 5 |
55+
| `claude-opus-5-5-fast`(Fast) | 2026-09-22 | 8 | 40 | 0.4 | 10 |
4656

4757
Cache Write 采用官方 5 分钟写入价。OpenCode 的聚合字段不区分 5 分钟与 1 小时 TTL,无法从历史消息可靠应用 1 小时写入价。OpenRouter 的 `claude-opus-4.7`、`claude-opus-4.8`、`claude-opus-5.5` 圆点写法注册为对应条目的精确别名。
4858

4959
`claude-opus-5-5` 的 Cache Read 是官方 0.05 倍基础输入价的特殊乘率(多数 Claude 模型为 0.1 倍),按官方标价 $0.20 / M 收录。
5060

61+
表中 Claude Fast 条目仅适用于 Claude API 一方。Fast mode 的 Cache Read 和 5 分钟 Cache Write 分别按 Fast 输入价乘以官方缓存倍率计算;OpenCode 聚合的 Cache Write 无法区分 TTL,因此按 5 分钟写入价估算。Opus 5.5 的 Cache Read 为 Fast 输入价的 0.05 倍,其余表列 Fast 型号为 0.1 倍。
62+
5163
## Google
5264

5365
来源:[Gemini Developer API Pricing](https://ai.google.dev/gemini-api/docs/pricing)
@@ -284,7 +296,7 @@ Fugu Ultra 的编排 token 已包含在 API 返回的 input/output 用量中,
284296

285297
- Realtime、音频、图片、视频、embedding、按页、按分钟和按工具调用收费的模型无法仅由当前五类 token 用量准确计算。
286298
- `grok-4.20`、`grok-4.20-multi-agent` 发布于 2026-03-09,早于目录收录窗口起点 2026-03-22。
287-
- Fast/Priority 等加速档(`claude-opus-*-fast`、`gpt-5.6-*-pro`、`gpt-6-astra-pro`、MiniMax priority 档)不是标准同步价。
299+
- Fast/Priority 等其他未列出的加速档(例如 `claude-opus-4-7-fast`、`gpt-5.5-pro-fast`、`gpt-6-astra-pro` 和 MiniMax priority 档)不收录;上表列出当前快照中官方定价页明确支持的 GPT 与 Claude Fast 型号。
288300
- 其他免费模型(Gemma 系列、`cohere/north-mini-code` 等开源或网关零价款)不设价格条目。
289301
- 无法从厂商官方页面确认标准 token 价格的模型不猜价,包括 OpenRouter stealth/alpha 匿名模型、`z-ai/glm-5v-turbo`、`qwen3.6-plus-preview`、腾讯 `hy3-preview` 与 `hy-mt2-*`、`kwaipilot/kat-coder-pro-v2.5` 及其 Air 版本、除上表 OpenCode Zen SKU 外的 `inclusionai/ling-3.0-*`、`bytedance-seed/seed-2.0-code` 等。这些模型目前只能查到 OpenRouter、AtlasCloud、DeepInfra 等网关或第三方报价,不能据此推断厂商标准价。
290302
- 浮动别名(`-latest` 指针与 OpenRouter `~` 前缀条目)随底层模型漂移,不收录固定价。

‎docs/verification.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# 验证记录
22

3+
## v0.3.3(GPT 与 Claude Fast 价格)
4+
5+
验证日期:2026-09-23。根据 [OpenAI API Pricing](https://developers.openai.com/api/docs/pricing) 与 [Claude Platform Pricing](https://platform.claude.com/docs/en/about-claude/pricing),为当前快照中官方支持 Fast mode 的 GPT-5.5、GPT-5.6 Sol/Terra/Luna、GPT-6 Astra/Sol/Luna,以及 Claude Opus 4.8/5/5.5 分别加入独立 Fast 条目。Fast 费率按官方长上下文档位与缓存倍率记录;GPT-5.5 Fast 未公布长上下文费率,超过 272,000 个传入 token 时显示不可估价。条目分别限制到官方支持 Fast mode 的 OpenAI 与 Anthropic provider;快照由 76 个模型增至 86 个。
6+
7+
| 检查 | 结果 |
8+
| --- | --- |
9+
| `npm run typecheck` | 通过 |
10+
| `npm test` | 51 项通过,覆盖 Fast 费率、缓存倍率、长上下文边界及普通版价格隔离 |
11+
| `npm run build` | 通过 |
12+
13+
本轮只改动价格目录、对应测试及价格说明,未重跑打包集成 smoke 测试。
14+
315
## v0.3.2(GPT-6 Sol / Luna 价格更新,SDK 2.0.11)
416

517
验证日期:2026-09-23。根据 [OpenAI API 更新日志](https://developers.openai.com/api/docs/changelog),`gpt-6-sol` 和 `gpt-6-luna` 于 2026-09-22 发布;[官方定价页](https://developers.openai.com/api/docs/pricing)列出两者的 Standard 短、长上下文四类 token 费率。内置快照由 72 个模型增至 74 个。根据 [Sol](https://developers.openai.com/api/docs/models/gpt-6-sol) 与 [Luna](https://developers.openai.com/api/docs/models/gpt-6-luna) 模型说明,传入 token 超过 272,000 时才使用长上下文价格;同轮也将已有 OpenAI 条目的边界从 271,999 校正为 272,000。

‎src/pricing.ts‎

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export interface OfficialPriceEntry {
77
released: string;
88
/** Exact alternate IDs used by supported gateways or manufacturer aliases. */
99
aliases?: readonly string[];
10-
/** Standard, synchronous API token rates in USD per million tokens. */
10+
/** Provider IDs where this rate is available, when it is not a general model rate. */
11+
providers?: readonly string[];
12+
/** Published API token rates in USD per million tokens. */
1113
prices: readonly Price[];
1214
/** Manufacturer pricing page used to verify the rates. */
1315
source: string;
@@ -17,7 +19,7 @@ export const OFFICIAL_PRICE_SNAPSHOT = {
1719
verified: "2026-09-23",
1820
newModelCutoff: "2026-03-22",
1921
entries: [
20-
// OpenAI standard processing. Tier sizes are exclusive thresholds, so
22+
// OpenAI API rates. Tier sizes are exclusive thresholds, so
2123
// 272,000 implements the official ">272K input tokens" boundary.
2224
{
2325
id: "gpt-5.5", released: "2026-04-23", source: "https://developers.openai.com/api/docs/pricing",
@@ -26,6 +28,14 @@ export const OFFICIAL_PRICE_SNAPSHOT = {
2628
{ tier: { type: "context", size: 272_000 }, input: 10, output: 45, cache: { read: 1 } },
2729
],
2830
},
31+
{
32+
id: "gpt-5.5-fast", providers: ["openai"], released: "2026-04-23", source: "https://developers.openai.com/api/docs/pricing",
33+
prices: [
34+
{ input: 12.5, output: 75, cache: { read: 1.25 } },
35+
// OpenAI publishes no Fast rate for GPT-5.5 above 272K input tokens.
36+
{ tier: { type: "context", size: 272_000 } },
37+
],
38+
},
2939
{
3040
id: "gpt-5.5-pro", released: "2026-04-23", source: "https://developers.openai.com/api/docs/pricing",
3141
prices: [
@@ -75,6 +85,50 @@ export const OFFICIAL_PRICE_SNAPSHOT = {
7585
{ tier: { type: "context", size: 272_000 }, input: 0.2, output: 0.75, cache: { read: 0.02, write: 0.25 } },
7686
],
7787
},
88+
{
89+
// OpenAI Fast processing is a separate exact ID and restricted to the
90+
// first-party provider so ordinary or gateway model IDs keep standard rates.
91+
id: "gpt-6-luna-fast", providers: ["openai"], released: "2026-09-22", source: "https://developers.openai.com/api/docs/pricing",
92+
prices: [
93+
{ input: 0.2, output: 1, cache: { read: 0.02, write: 0.25 } },
94+
{ tier: { type: "context", size: 272_000 }, input: 0.4, output: 1.5, cache: { read: 0.04, write: 0.5 } },
95+
],
96+
},
97+
{
98+
id: "gpt-5.6-sol-fast", providers: ["openai"], released: "2026-07-09", source: "https://developers.openai.com/api/docs/pricing",
99+
prices: [
100+
{ input: 8, output: 40, cache: { read: 0.8, write: 10 } },
101+
{ tier: { type: "context", size: 272_000 }, input: 16, output: 60, cache: { read: 1.6, write: 20 } },
102+
],
103+
},
104+
{
105+
id: "gpt-5.6-terra-fast", providers: ["openai"], released: "2026-07-09", source: "https://developers.openai.com/api/docs/pricing",
106+
prices: [
107+
{ input: 4, output: 24, cache: { read: 0.4, write: 5 } },
108+
{ tier: { type: "context", size: 272_000 }, input: 8, output: 36, cache: { read: 0.8, write: 10 } },
109+
],
110+
},
111+
{
112+
id: "gpt-5.6-luna-fast", providers: ["openai"], released: "2026-07-09", source: "https://developers.openai.com/api/docs/pricing",
113+
prices: [
114+
{ input: 0.4, output: 2.4, cache: { read: 0.04, write: 0.5 } },
115+
{ tier: { type: "context", size: 272_000 }, input: 0.8, output: 3.6, cache: { read: 0.08, write: 1 } },
116+
],
117+
},
118+
{
119+
id: "gpt-6-astra-fast", providers: ["openai"], released: "2026-09-04", source: "https://developers.openai.com/api/docs/pricing",
120+
prices: [
121+
{ input: 20, output: 100, cache: { read: 2, write: 25 } },
122+
{ tier: { type: "context", size: 272_000 }, input: 40, output: 150, cache: { read: 4, write: 50 } },
123+
],
124+
},
125+
{
126+
id: "gpt-6-sol-fast", providers: ["openai"], released: "2026-09-22", source: "https://developers.openai.com/api/docs/pricing",
127+
prices: [
128+
{ input: 4, output: 20, cache: { read: 0.4, write: 5 } },
129+
{ tier: { type: "context", size: 272_000 }, input: 8, output: 30, cache: { read: 0.8, write: 10 } },
130+
],
131+
},
78132
// The official ChatGPT SKU `chat-latest`. OpenRouter serves it under the
79133
// slug `openai/gpt-chat-latest`, which is registered as an exact alias.
80134
{
@@ -105,6 +159,20 @@ export const OFFICIAL_PRICE_SNAPSHOT = {
105159
id: "claude-opus-5", released: "2026-07-24", source: "https://platform.claude.com/docs/en/about-claude/pricing",
106160
prices: [{ input: 5, output: 25, cache: { read: 0.5, write: 6.25 } }],
107161
},
162+
{
163+
// Fast mode is first-party Claude API only. Cache multipliers apply to
164+
// the Fast input price; aggregate cache writes use the 5-minute rate.
165+
id: "claude-opus-5-fast", providers: ["anthropic"], released: "2026-07-24", source: "https://platform.claude.com/docs/en/about-claude/pricing",
166+
prices: [{ input: 10, output: 50, cache: { read: 1, write: 12.5 } }],
167+
},
168+
{
169+
id: "claude-opus-4-8-fast", providers: ["anthropic"], released: "2026-05-28", source: "https://platform.claude.com/docs/en/about-claude/pricing",
170+
prices: [{ input: 10, output: 50, cache: { read: 1, write: 12.5 } }],
171+
},
172+
{
173+
id: "claude-opus-5-5-fast", providers: ["anthropic"], released: "2026-09-22", source: "https://platform.claude.com/docs/en/about-claude/pricing",
174+
prices: [{ input: 8, output: 40, cache: { read: 0.4, write: 10 } }],
175+
},
108176
{
109177
id: "claude-fable-5-1", aliases: ["claude-fable-5.1"], released: "2026-09-01",
110178
source: "https://platform.claude.com/docs/en/about-claude/pricing",
@@ -536,14 +604,20 @@ export function officialPrice(model: ModelRef): OfficialPriceEntry | undefined {
536604
if (slash >= 0) candidates.push(id.slice(slash + 1));
537605
const dot = id.lastIndexOf(".");
538606
if (dot >= 0) candidates.push(id.slice(dot + 1));
539-
for (const candidate of candidates) {
607+
const available = (candidate: string) => {
540608
const entry = index.get(candidate);
609+
return entry && (!entry.providers || entry.providers.some(provider => provider.toLowerCase() === model.providerID.toLowerCase()))
610+
? entry
611+
: undefined;
612+
};
613+
for (const candidate of candidates) {
614+
const entry = available(candidate);
541615
if (entry) return entry;
542616
}
543617
for (const candidate of candidates) {
544618
for (const suffix of ["-free", ":free"]) {
545619
if (!candidate.endsWith(suffix)) continue;
546-
const entry = index.get(candidate.slice(0, -suffix.length));
620+
const entry = available(candidate.slice(0, -suffix.length));
547621
if (entry) return entry;
548622
}
549623
}

0 commit comments

Comments
 (0)