@chenlongapps/opencode-token-usage 0.2.5 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/README.zh-CN.md +9 -7
- package/ROADMAP.md +11 -6
- package/dist/controller.js +1 -1
- package/dist/pricing.d.ts +142 -0
- package/dist/pricing.js +488 -0
- package/dist/source.d.ts +3 -3
- package/dist/source.js +8 -3
- package/dist/usage.d.ts +14 -2
- package/dist/usage.js +37 -12
- package/docs/pricing.md +282 -0
- package/docs/verification.md +9 -5
- package/package.json +2 -1
package/dist/pricing.js
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
export const OFFICIAL_PRICE_SNAPSHOT = {
|
|
2
|
+
verified: "2026-09-23",
|
|
3
|
+
newModelCutoff: "2026-03-22",
|
|
4
|
+
entries: [
|
|
5
|
+
// OpenAI standard processing. The tier sizes are exclusive thresholds, so
|
|
6
|
+
// 271,999 implements the official "long context at 272K" boundary.
|
|
7
|
+
{
|
|
8
|
+
id: "gpt-5.5", released: "2026-04-23", source: "https://developers.openai.com/api/docs/pricing",
|
|
9
|
+
prices: [
|
|
10
|
+
{ input: 5, output: 30, cache: { read: 0.5 } },
|
|
11
|
+
{ tier: { type: "context", size: 271_999 }, input: 10, output: 45, cache: { read: 1 } },
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "gpt-5.5-pro", released: "2026-04-23", source: "https://developers.openai.com/api/docs/pricing",
|
|
16
|
+
prices: [
|
|
17
|
+
{ input: 30, output: 180 },
|
|
18
|
+
{ tier: { type: "context", size: 271_999 }, input: 60, output: 270 },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "gpt-5.6-sol", released: "2026-07-09", source: "https://developers.openai.com/api/docs/pricing",
|
|
23
|
+
prices: [
|
|
24
|
+
{ input: 4, output: 20, cache: { read: 0.4, write: 5 } },
|
|
25
|
+
{ tier: { type: "context", size: 271_999 }, input: 8, output: 30, cache: { read: 0.8, write: 10 } },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "gpt-5.6-terra", released: "2026-07-09", source: "https://developers.openai.com/api/docs/pricing",
|
|
30
|
+
prices: [
|
|
31
|
+
{ input: 2, output: 12, cache: { read: 0.2, write: 2.5 } },
|
|
32
|
+
{ tier: { type: "context", size: 271_999 }, input: 4, output: 18, cache: { read: 0.4, write: 5 } },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "gpt-5.6-luna", released: "2026-07-09", source: "https://developers.openai.com/api/docs/pricing",
|
|
37
|
+
prices: [
|
|
38
|
+
{ input: 0.2, output: 1.2, cache: { read: 0.02, write: 0.25 } },
|
|
39
|
+
{ tier: { type: "context", size: 271_999 }, input: 0.4, output: 1.8, cache: { read: 0.04, write: 0.5 } },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "gpt-6-astra", released: "2026-09-04", source: "https://developers.openai.com/api/docs/pricing",
|
|
44
|
+
prices: [
|
|
45
|
+
{ input: 10, output: 50, cache: { read: 1, write: 12.5 } },
|
|
46
|
+
{ tier: { type: "context", size: 271_999 }, input: 20, output: 75, cache: { read: 2, write: 25 } },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
// The official ChatGPT SKU `chat-latest`. OpenRouter serves it under the
|
|
50
|
+
// slug `openai/gpt-chat-latest`, which is registered as an exact alias.
|
|
51
|
+
{
|
|
52
|
+
id: "chat-latest", aliases: ["gpt-chat-latest"], released: "2026-05-05",
|
|
53
|
+
source: "https://developers.openai.com/api/docs/pricing",
|
|
54
|
+
prices: [{ input: 5, output: 30, cache: { read: 0.5 } }],
|
|
55
|
+
},
|
|
56
|
+
// Anthropic standard processing and 5-minute cache writes. OpenCode's
|
|
57
|
+
// aggregate cache-write counter cannot distinguish 5-minute from 1-hour TTL.
|
|
58
|
+
{
|
|
59
|
+
id: "claude-opus-4-7", aliases: ["claude-opus-4.7"], released: "2026-04-14", source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
60
|
+
prices: [{ input: 5, output: 25, cache: { read: 0.5, write: 6.25 } }],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "claude-opus-4-8", aliases: ["claude-opus-4.8"], released: "2026-05-28", source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
64
|
+
prices: [{ input: 5, output: 25, cache: { read: 0.5, write: 6.25 } }],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "claude-fable-5", released: "2026-06-07", source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
68
|
+
prices: [{ input: 10, output: 50, cache: { read: 1, write: 12.5 } }],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "claude-sonnet-5", released: "2026-06-29", source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
72
|
+
prices: [{ input: 2, output: 10, cache: { read: 0.2, write: 2.5 } }],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "claude-opus-5", released: "2026-07-24", source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
76
|
+
prices: [{ input: 5, output: 25, cache: { read: 0.5, write: 6.25 } }],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "claude-fable-5-1", aliases: ["claude-fable-5.1"], released: "2026-09-01",
|
|
80
|
+
source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
81
|
+
prices: [{ input: 10, output: 50, cache: { read: 0.25, write: 12.5 } }],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "claude-opus-5-5", aliases: ["claude-opus-5.5"], released: "2026-09-22", source: "https://platform.claude.com/docs/en/about-claude/pricing",
|
|
85
|
+
prices: [{ input: 4, output: 20, cache: { read: 0.2, write: 5 } }],
|
|
86
|
+
},
|
|
87
|
+
// Google paid Standard API rates. Cache storage is billed separately by
|
|
88
|
+
// time and is intentionally not represented as a cache-write token rate.
|
|
89
|
+
{
|
|
90
|
+
id: "gemini-3.1-flash-lite", released: "2026-05-07", source: "https://ai.google.dev/gemini-api/docs/pricing",
|
|
91
|
+
prices: [{ input: 0.25, output: 1.5, cache: { read: 0.025 } }],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "gemini-3.5-flash", released: "2026-05-19", source: "https://ai.google.dev/gemini-api/docs/pricing",
|
|
95
|
+
prices: [{ input: 1.5, output: 9, cache: { read: 0.15 } }],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "gemini-3.5-flash-lite", released: "2026-07-21", source: "https://ai.google.dev/gemini-api/docs/pricing",
|
|
99
|
+
prices: [{ input: 0.3, output: 2.5, cache: { read: 0.03 } }],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "gemini-3.6-flash", released: "2026-07-21", source: "https://ai.google.dev/gemini-api/docs/pricing",
|
|
103
|
+
prices: [{ input: 0.75, output: 3.75, cache: { read: 0.075 } }],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: "gemini-3.7-flash", released: "2026-08-13", source: "https://ai.google.dev/gemini-api/docs/pricing",
|
|
107
|
+
prices: [{ input: 0.75, output: 3.75, cache: { read: 0.075 } }],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "gemini-3.8-flash", released: "2026-09-02", source: "https://ai.google.dev/gemini-api/docs/pricing",
|
|
111
|
+
prices: [{ input: 0.75, output: 3.75, cache: { read: 0.075 } }],
|
|
112
|
+
},
|
|
113
|
+
// xAI standard text API rates. 199,999 implements the official higher
|
|
114
|
+
// price at 200K prompt tokens with OpenCode's exclusive-tier formula.
|
|
115
|
+
{
|
|
116
|
+
id: "grok-build-0.1", released: "2026-04-16", source: "https://docs.x.ai/developers/models",
|
|
117
|
+
prices: [
|
|
118
|
+
{ input: 1, output: 2, cache: { read: 0.2 } },
|
|
119
|
+
{ tier: { type: "context", size: 199_999 }, input: 2, output: 4, cache: { read: 0.4 } },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: "grok-4.3", released: "2026-04-17", source: "https://docs.x.ai/developers/models",
|
|
124
|
+
prices: [
|
|
125
|
+
{ input: 1.25, output: 2.5, cache: { read: 0.2 } },
|
|
126
|
+
{ tier: { type: "context", size: 199_999 }, input: 2.5, output: 5, cache: { read: 0.4 } },
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: "grok-4.5", released: "2026-07-08", source: "https://docs.x.ai/developers/models",
|
|
131
|
+
prices: [
|
|
132
|
+
{ input: 2, output: 6, cache: { read: 0.3 } },
|
|
133
|
+
{ tier: { type: "context", size: 199_999 }, input: 4, output: 12, cache: { read: 0.6 } },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "grok-4.6", released: "2026-08-12", source: "https://docs.x.ai/developers/models",
|
|
138
|
+
prices: [
|
|
139
|
+
{ input: 2, output: 6, cache: { read: 0.5 } },
|
|
140
|
+
{ tier: { type: "context", size: 199_999 }, input: 4, output: 12, cache: { read: 1 } },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "grok-4.7", released: "2026-09-21",
|
|
145
|
+
source: "https://docs.x.ai/developers/models",
|
|
146
|
+
prices: [
|
|
147
|
+
{ input: 2, output: 6, cache: { read: 0.5 } },
|
|
148
|
+
{ tier: { type: "context", size: 199_999 }, input: 4, output: 12, cache: { read: 1 } },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "mistral-medium-3-5-26-04",
|
|
153
|
+
aliases: ["mistral-medium-2604", "mistral-medium-3-5"],
|
|
154
|
+
released: "2026-04-29",
|
|
155
|
+
source: "https://docs.mistral.ai/inference/pricing",
|
|
156
|
+
prices: [{ input: 1.5, output: 7.5, cache: { read: 0.15 } }],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "command-a-plus-05-2026",
|
|
160
|
+
released: "2026-05-20",
|
|
161
|
+
source: "https://cohere.com/pricing",
|
|
162
|
+
prices: [{ input: 2.5, output: 10 }],
|
|
163
|
+
},
|
|
164
|
+
// Meta Model API standard-tier rates. The contributor tier is a separate
|
|
165
|
+
// discounted program that permits training on prompts and completions, so
|
|
166
|
+
// it is intentionally not part of the standard snapshot.
|
|
167
|
+
{
|
|
168
|
+
id: "muse-spark-1.1", released: "2026-07-09", source: "https://ai.developer.meta.com/docs/pricing-rate-limits",
|
|
169
|
+
prices: [{ input: 1.25, output: 4.25, cache: { read: 0.15 } }],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: "muse-spark-1.2", released: "2026-08-05", source: "https://ai.developer.meta.com/docs/pricing-rate-limits",
|
|
173
|
+
prices: [{ input: 1.25, output: 4.25, cache: { read: 0.15 } }],
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "muse-spark-1.3", released: "2026-09-02", source: "https://ai.developer.meta.com/docs/pricing-rate-limits",
|
|
177
|
+
prices: [{ input: 1.25, output: 4.25, cache: { read: 0.15 } }],
|
|
178
|
+
},
|
|
179
|
+
// Inception's current Mercury 2.5 API page shows an 80% launch discount;
|
|
180
|
+
// the snapshot records the billed standard-platform rates on verification
|
|
181
|
+
// day rather than the crossed-out list prices. No cache-write token rate is
|
|
182
|
+
// published.
|
|
183
|
+
{
|
|
184
|
+
id: "mercury-2.5", aliases: ["mercury-2.5-preview"], released: "2026-09-08",
|
|
185
|
+
source: "https://www.inceptionlabs.ai/models",
|
|
186
|
+
prices: [{ input: 0.04, output: 0.15, cache: { read: 0.004 } }],
|
|
187
|
+
},
|
|
188
|
+
// Upstage Solar Pro 4 standard Console API rates. The dated version ID is
|
|
189
|
+
// an exact manufacturer alias; no cache-write token rate is published.
|
|
190
|
+
{
|
|
191
|
+
id: "solar-pro4", aliases: ["solar-pro4-260806"], released: "2026-08-06",
|
|
192
|
+
source: "https://console.upstage.ai/docs/models/solar-pro-4",
|
|
193
|
+
prices: [{ input: 0.3, output: 1.2, cache: { read: 0.06 } }],
|
|
194
|
+
},
|
|
195
|
+
// Arcee AI's hosted API rates for the official Trinity reasoning release.
|
|
196
|
+
// The model is also available as open weights, but only the hosted API
|
|
197
|
+
// price is relevant to this token-cost snapshot.
|
|
198
|
+
{
|
|
199
|
+
id: "trinity-large-thinking", released: "2026-04-01", source: "https://docs.arcee.ai/get-started/pricing",
|
|
200
|
+
prices: [{ input: 0.25, output: 0.8, cache: { read: 0.06 } }],
|
|
201
|
+
},
|
|
202
|
+
// Aion Labs' own model catalog publishes these per-token API rates. The
|
|
203
|
+
// OpenRouter slugs retain the manufacturer's `aion-labs/` prefix, so it is
|
|
204
|
+
// registered as an exact alias rather than inferred from the name.
|
|
205
|
+
{
|
|
206
|
+
id: "aion-3.0", aliases: ["aion-labs/aion-3.0"], released: "2026-05-05",
|
|
207
|
+
source: "https://www.aionlabs.ai/docs/models",
|
|
208
|
+
prices: [{ input: 3, output: 6, cache: { read: 0.75 } }],
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
id: "aion-3.0-mini", aliases: ["aion-labs/aion-3.0-mini"], released: "2026-05-14",
|
|
212
|
+
source: "https://www.aionlabs.ai/docs/models",
|
|
213
|
+
prices: [{ input: 0.7, output: 1.4, cache: { read: 0.18 } }],
|
|
214
|
+
},
|
|
215
|
+
// Z.ai (Zhipu GLM) standard API rates. The page publishes a cache-hit input
|
|
216
|
+
// rate and prices cache storage by time instead of a cache-write token rate,
|
|
217
|
+
// so no cache-write rate is stored for these models.
|
|
218
|
+
{
|
|
219
|
+
id: "glm-5.1", released: "2026-04-06", source: "https://docs.z.ai/guides/overview/pricing",
|
|
220
|
+
prices: [{ input: 1.4, output: 4.4, cache: { read: 0.26 } }],
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "glm-5.2", released: "2026-06-16", source: "https://docs.z.ai/guides/overview/pricing",
|
|
224
|
+
prices: [{ input: 1.4, output: 4.4, cache: { read: 0.26 } }],
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "glm-5.3", released: "2026-08-16", source: "https://docs.z.ai/guides/overview/pricing",
|
|
228
|
+
prices: [{ input: 1.4, output: 4.4, cache: { read: 0.26 } }],
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: "glm-5.3-flash", released: "2026-08-26", source: "https://docs.z.ai/guides/overview/pricing",
|
|
232
|
+
prices: [{ input: 0.15, output: 0.5, cache: { read: 0.03 } }],
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: "glm-5.3-flashx", released: "2026-09-18", source: "https://docs.z.ai/guides/overview/pricing",
|
|
236
|
+
prices: [{ input: 0.37, output: 1.25, cache: { read: 0.075 } }],
|
|
237
|
+
},
|
|
238
|
+
// DeepSeek standard API peak rates. The vendor charges half these rates
|
|
239
|
+
// off-peak; using the peak tier provides a conservative upper-bound
|
|
240
|
+
// estimate because historical messages do not retain the billing hour.
|
|
241
|
+
// Retired V4 Flash and Vision Exp names currently route to V4.1 Flash at
|
|
242
|
+
// the Flash price. The dated 0731 and 0813 IDs are exact gateway aliases.
|
|
243
|
+
{
|
|
244
|
+
id: "deepseek-v4.1-flash",
|
|
245
|
+
aliases: ["deepseek-flash", "deepseek-v4-flash", "deepseek-v4-flash-0731", "deepseek-v4-flash-vision-exp"],
|
|
246
|
+
released: "2026-09-10",
|
|
247
|
+
source: "https://api-docs.deepseek.com/quick_start/pricing",
|
|
248
|
+
prices: [{ input: 0.3, output: 1.2, cache: { read: 0.006 } }],
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
id: "deepseek-v4-pro-0813", aliases: ["deepseek-v4-pro"], released: "2026-08-13",
|
|
252
|
+
source: "https://api-docs.deepseek.com/quick_start/pricing",
|
|
253
|
+
prices: [{ input: 1.32, output: 3.96, cache: { read: 0.044 } }],
|
|
254
|
+
},
|
|
255
|
+
// Moonshot Kimi standard API rates. K3 publishes 5-minute and 1-hour cache
|
|
256
|
+
// writes; following the Anthropic convention, the aggregate counter cannot
|
|
257
|
+
// tell them apart, so the snapshot stores the 5-minute write. The K2 table
|
|
258
|
+
// publishes only a cache-hit input rate and no cache-write price.
|
|
259
|
+
{
|
|
260
|
+
id: "kimi-k3", released: "2026-07-15", source: "https://platform.moonshot.ai/docs/pricing",
|
|
261
|
+
prices: [{ input: 3, output: 15, cache: { read: 0.3, write: 3 } }],
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
id: "kimi-k2.7-code", released: "2026-06-12", source: "https://platform.moonshot.ai/docs/pricing",
|
|
265
|
+
prices: [{ input: 0.95, output: 4, cache: { read: 0.19 } }],
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: "kimi-k2.6", released: "2026-04-20", source: "https://platform.moonshot.ai/docs/pricing",
|
|
269
|
+
prices: [{ input: 0.95, output: 4, cache: { read: 0.16 } }],
|
|
270
|
+
},
|
|
271
|
+
// Alibaba Cloud Model Studio standard (Singapore "International") list
|
|
272
|
+
// prices. Tier sizes implement the official inclusive boundaries
|
|
273
|
+
// ("0<Token≤256K" then "256K<Token≤1M") with the exclusive-threshold formula.
|
|
274
|
+
// Cache Read stores the official implicit-cache hit rate, 20% of the tier
|
|
275
|
+
// input, where the page publishes it. The qwen3.8 max/flash family reports
|
|
276
|
+
// cache rates only in the console, so no cache rate is stored for them, and
|
|
277
|
+
// no cache-write rate is stored anywhere because implicit cache writes bill
|
|
278
|
+
// at 100% of the input price while explicit cache writes bill at 125% and
|
|
279
|
+
// the aggregate counter cannot distinguish the two.
|
|
280
|
+
{
|
|
281
|
+
id: "qwen3.8-max", aliases: ["qwen3.8-max-0902"], released: "2026-08-03",
|
|
282
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
283
|
+
prices: [{ input: 2, output: 6 }],
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: "qwen3.8-2.4t-a95b", released: "2026-08-12",
|
|
287
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
288
|
+
prices: [{ input: 2, output: 6 }],
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
id: "qwen3.8-27b", released: "2026-08-14",
|
|
292
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
293
|
+
prices: [{ input: 0.5, output: 3, cache: { read: 0.1 } }],
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
id: "qwen3.8-flash", released: "2026-08-26",
|
|
297
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
298
|
+
prices: [{ input: 0.15, output: 0.47 }],
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
id: "qwen3.7-max", released: "2026-05-20",
|
|
302
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
303
|
+
prices: [{ input: 2.5, output: 7.5, cache: { read: 0.5 } }],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
id: "qwen3.7-plus", released: "2026-05-26",
|
|
307
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
308
|
+
prices: [
|
|
309
|
+
{ input: 0.4, output: 1.6, cache: { read: 0.08 } },
|
|
310
|
+
{ tier: { type: "context", size: 256_000 }, input: 1.2, output: 4.8, cache: { read: 0.24 } },
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
id: "qwen3.7-flash", released: "2026-07-15",
|
|
315
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
316
|
+
prices: [
|
|
317
|
+
{ input: 0.03, output: 0.13, cache: { read: 0.006 } },
|
|
318
|
+
{ tier: { type: "context", size: 32_000 }, input: 0.1, output: 0.4, cache: { read: 0.02 } },
|
|
319
|
+
{ tier: { type: "context", size: 256_000 }, input: 0.2, output: 0.8, cache: { read: 0.04 } },
|
|
320
|
+
],
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: "qwen3.6-max-preview", released: "2026-04-20",
|
|
324
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
325
|
+
prices: [
|
|
326
|
+
{ input: 1.3, output: 7.8 },
|
|
327
|
+
{ tier: { type: "context", size: 128_000 }, input: 2, output: 12 },
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
id: "qwen3.6-plus", released: "2026-04-02",
|
|
332
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
333
|
+
prices: [
|
|
334
|
+
{ input: 0.5, output: 3 },
|
|
335
|
+
{ tier: { type: "context", size: 256_000 }, input: 2, output: 6 },
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
id: "qwen3.6-flash", released: "2026-04-16",
|
|
340
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
341
|
+
prices: [
|
|
342
|
+
{ input: 0.25, output: 1.5 },
|
|
343
|
+
{ tier: { type: "context", size: 256_000 }, input: 1, output: 4 },
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
id: "qwen3.6-27b", released: "2026-04-22",
|
|
348
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
349
|
+
prices: [{ input: 0.6, output: 3.6 }],
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
id: "qwen3.6-35b-a3b", released: "2026-04-15",
|
|
353
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
354
|
+
prices: [{ input: 0.375, output: 2.25 }],
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
id: "qwen3.5-plus-2026-04-20", aliases: ["qwen3.5-plus-20260420"], released: "2026-04-20",
|
|
358
|
+
source: "https://www.alibabacloud.com/help/en/model-studio/model-pricing",
|
|
359
|
+
prices: [
|
|
360
|
+
{ input: 0.4, output: 2.4 },
|
|
361
|
+
{ tier: { type: "context", size: 256_000 }, input: 0.5, output: 3 },
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
// Xiaomi MiMo overseas USD rates. The MiMo-V2.6 series keeps the V2.5 API
|
|
365
|
+
// pricing. Cache writes are free for a limited time, so no cache-write rate
|
|
366
|
+
// is stored.
|
|
367
|
+
{
|
|
368
|
+
id: "mimo-v2.5", released: "2026-04-22", source: "https://mimo.mi.com/docs/price/pay-as-you-go",
|
|
369
|
+
prices: [{ input: 0.14, output: 0.28, cache: { read: 0.0028 } }],
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
id: "mimo-v2.5-pro", released: "2026-04-22", source: "https://mimo.mi.com/docs/price/pay-as-you-go",
|
|
373
|
+
prices: [{ input: 0.435, output: 0.87, cache: { read: 0.0036 } }],
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
id: "mimo-v2.6-flash", released: "2026-09-21", source: "https://mimo.mi.com/docs/price/pay-as-you-go",
|
|
377
|
+
prices: [{ input: 0.14, output: 0.28, cache: { read: 0.0028 } }],
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
id: "mimo-v2.6-pro", released: "2026-09-21", source: "https://mimo.mi.com/docs/price/pay-as-you-go",
|
|
381
|
+
prices: [{ input: 0.435, output: 0.87, cache: { read: 0.0036 } }],
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: "mimo-v2.6-pro-ultraspeed", released: "2026-09-21", source: "https://mimo.mi.com/docs/price/pay-as-you-go",
|
|
385
|
+
prices: [{ input: 4.35, output: 8.7, cache: { read: 0.036 } }],
|
|
386
|
+
},
|
|
387
|
+
// MiniMax pay-as-you-go billed rates. The page labels the M3 rates as a
|
|
388
|
+
// permanent 50% off and shows the struck-through list price beside them;
|
|
389
|
+
// like the GPT-5.6 Sol promotion, the snapshot stores the billed rates shown
|
|
390
|
+
// on the verification date. Only a prompt-caching read rate is published.
|
|
391
|
+
{
|
|
392
|
+
id: "minimax-m3", released: "2026-05-31", source: "https://platform.minimax.io/docs/guides/pricing-paygo",
|
|
393
|
+
prices: [
|
|
394
|
+
{ input: 0.3, output: 1.2, cache: { read: 0.06 } },
|
|
395
|
+
{ tier: { type: "context", size: 512_000 }, input: 0.6, output: 2.4, cache: { read: 0.12 } },
|
|
396
|
+
],
|
|
397
|
+
},
|
|
398
|
+
// Tencent Cloud TokenHub international (Singapore) USD list prices for the
|
|
399
|
+
// vendor's own Hunyuan models. Cache is the published cache-hit rate; the
|
|
400
|
+
// page publishes no cache-write rate.
|
|
401
|
+
{
|
|
402
|
+
id: "hy3", released: "2026-07-06", source: "https://intl.cloud.tencent.com/document/product/1300/78937",
|
|
403
|
+
prices: [{ input: 0.132, output: 0.528, cache: { read: 0.033 } }],
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
id: "hy4-preview", released: "2026-08-27", source: "https://intl.cloud.tencent.com/document/product/1300/78937",
|
|
407
|
+
prices: [{ input: 0.834, output: 2.501, cache: { read: 0.042 } }],
|
|
408
|
+
},
|
|
409
|
+
// StepFun overseas platform rates. The page publishes a cache-hit input
|
|
410
|
+
// rate. For Step 5 Preview it explicitly states that cache-miss input
|
|
411
|
+
// includes writing new content to the cache, so split cache-write tokens
|
|
412
|
+
// retain the same rate as ordinary cache-miss input.
|
|
413
|
+
{
|
|
414
|
+
id: "step-5-preview", released: "2026-09-21", source: "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
415
|
+
prices: [{ input: 1, output: 2.7, cache: { read: 0.05, write: 1 } }],
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
id: "step-3.7-flash", released: "2026-05-28", source: "https://platform.stepfun.ai/docs/en/guides/pricing/details",
|
|
419
|
+
prices: [{ input: 0.2, output: 1.15, cache: { read: 0.04 } }],
|
|
420
|
+
},
|
|
421
|
+
// ByteDance Seed 2.1 Turbo standard online inference rates on BytePlus
|
|
422
|
+
// ModelArk. The cache-storage fee is time-based rather than a token write
|
|
423
|
+
// rate, so only the published cache-hit input price is represented.
|
|
424
|
+
{
|
|
425
|
+
id: "dola-seed-2-1-turbo",
|
|
426
|
+
aliases: ["seed-2-1-turbo", "dola-seed-2-1-turbo-260628"],
|
|
427
|
+
released: "2026-06-23",
|
|
428
|
+
source: "https://docs.byteplus.com/en/docs/ModelArk/1099320",
|
|
429
|
+
prices: [{ input: 0.5, output: 2.5, cache: { read: 0.1 } }],
|
|
430
|
+
},
|
|
431
|
+
// Sakana Fugu's fixed standard API rates. Fugu Ultra's orchestration
|
|
432
|
+
// tokens are included in the API's input/output usage fields and therefore
|
|
433
|
+
// use the same token rates. Web search/fetch tool fees are not token fees
|
|
434
|
+
// and cannot be represented by the plugin's five usage counters.
|
|
435
|
+
{
|
|
436
|
+
id: "fugu-ultra-v2.0", aliases: ["fugu-ultra-v2"], released: "2026-09-11",
|
|
437
|
+
source: "https://console.sakana.ai/pricing",
|
|
438
|
+
prices: [
|
|
439
|
+
{ input: 5, output: 30, cache: { read: 0.5 } },
|
|
440
|
+
{ tier: { type: "context", size: 271_999 }, input: 10, output: 45, cache: { read: 1 } },
|
|
441
|
+
],
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
id: "fugu-max-v1.0", aliases: ["fugu-max"], released: "2026-09-11",
|
|
445
|
+
source: "https://console.sakana.ai/pricing",
|
|
446
|
+
prices: [{ input: 2, output: 6, cache: { read: 0.25 } }],
|
|
447
|
+
},
|
|
448
|
+
// LongCat's official API page shows both list and limited-time discounted
|
|
449
|
+
// rates. As with the other documented promotions in this snapshot, record
|
|
450
|
+
// the billed discounted rate visible on verification day. Cache storage or
|
|
451
|
+
// cache writes have no separate token rate on the page.
|
|
452
|
+
{
|
|
453
|
+
id: "longcat-2.0", released: "2026-06-30",
|
|
454
|
+
source: "https://longcat.chat/platform/docs/Pricing/LongCat-2.0.html",
|
|
455
|
+
prices: [{ input: 0.3, output: 1.2, cache: { read: 0.006 } }],
|
|
456
|
+
},
|
|
457
|
+
],
|
|
458
|
+
};
|
|
459
|
+
const index = new Map();
|
|
460
|
+
for (const entry of OFFICIAL_PRICE_SNAPSHOT.entries) {
|
|
461
|
+
for (const id of [entry.id, ...(entry.aliases ?? [])]) {
|
|
462
|
+
const key = id.toLowerCase();
|
|
463
|
+
if (index.has(key))
|
|
464
|
+
throw new Error(`Duplicate official price ID: ${id}`);
|
|
465
|
+
index.set(key, entry);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Resolves exact manufacturer IDs through common gateway wrappers. It never
|
|
470
|
+
* performs substring or model-name matching, so similarly named variants do
|
|
471
|
+
* not silently inherit a different model's price.
|
|
472
|
+
*/
|
|
473
|
+
export function officialPrice(model) {
|
|
474
|
+
const id = model.id.toLowerCase().replace(/@default$/, "");
|
|
475
|
+
const candidates = [id];
|
|
476
|
+
const slash = id.lastIndexOf("/");
|
|
477
|
+
if (slash >= 0)
|
|
478
|
+
candidates.push(id.slice(slash + 1));
|
|
479
|
+
const dot = id.lastIndexOf(".");
|
|
480
|
+
if (dot >= 0)
|
|
481
|
+
candidates.push(id.slice(dot + 1));
|
|
482
|
+
for (const candidate of candidates) {
|
|
483
|
+
const entry = index.get(candidate);
|
|
484
|
+
if (entry)
|
|
485
|
+
return entry;
|
|
486
|
+
}
|
|
487
|
+
return undefined;
|
|
488
|
+
}
|
package/dist/source.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OpenCodeClient, SessionInfo } from "@opencode/client";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PriceCatalog, UsageMessage } from "./usage.js";
|
|
3
3
|
export type Session = Pick<SessionInfo, "id" | "parentID" | "fork" | "model" | "location">;
|
|
4
4
|
export interface Page<T> {
|
|
5
5
|
data: T[];
|
|
@@ -8,10 +8,10 @@ export interface Page<T> {
|
|
|
8
8
|
previous?: string | null;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
/** Active model of the viewed session
|
|
11
|
+
/** Active model of the viewed session plus the location's current resolved price catalog. */
|
|
12
12
|
export interface ActiveModel {
|
|
13
13
|
label: string;
|
|
14
|
-
|
|
14
|
+
catalog: PriceCatalog;
|
|
15
15
|
context?: number | undefined;
|
|
16
16
|
}
|
|
17
17
|
export interface UsageSource {
|
package/dist/source.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modelKey } from "./usage.js";
|
|
1
2
|
export function createSource(client) {
|
|
2
3
|
return {
|
|
3
4
|
session: (sessionID, signal) => client.session.get({ sessionID }, { signal }),
|
|
@@ -7,12 +8,16 @@ export function createSource(client) {
|
|
|
7
8
|
async model(session, signal) {
|
|
8
9
|
const input = { location: session.location };
|
|
9
10
|
const selected = session.model;
|
|
11
|
+
const models = (await client.model.list(input, { signal })).data;
|
|
10
12
|
const model = selected
|
|
11
|
-
?
|
|
12
|
-
: (await client.model.default(input, { signal })).data;
|
|
13
|
+
? models.find(m => m.providerID === selected.providerID && m.id === selected.id)
|
|
14
|
+
: (await client.model.default(input, { signal })).data ?? undefined;
|
|
15
|
+
const catalog = new Map(models.map(value => [modelKey(value), value.cost]));
|
|
16
|
+
if (model && !catalog.has(modelKey(model)))
|
|
17
|
+
catalog.set(modelKey(model), model.cost);
|
|
13
18
|
return {
|
|
14
19
|
label: model ? `${model.providerID}/${model.id}` : selected ? `${selected.providerID}/${selected.id}` : "Default model",
|
|
15
|
-
|
|
20
|
+
catalog,
|
|
16
21
|
context: model?.limit?.context,
|
|
17
22
|
};
|
|
18
23
|
},
|
package/dist/usage.d.ts
CHANGED
|
@@ -29,10 +29,19 @@ export interface Price {
|
|
|
29
29
|
write?: number;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
export interface ModelRef {
|
|
33
|
+
providerID: string;
|
|
34
|
+
id: string;
|
|
35
|
+
variant?: string;
|
|
36
|
+
}
|
|
37
|
+
export type PriceCatalog = ReadonlyMap<string, readonly Price[]>;
|
|
38
|
+
export declare const modelKey: (model: Pick<ModelRef, "providerID" | "id">) => string;
|
|
32
39
|
export interface UsageMessage {
|
|
33
40
|
id: string;
|
|
34
41
|
type: string;
|
|
35
42
|
status?: string;
|
|
43
|
+
model?: ModelRef;
|
|
44
|
+
cost?: number;
|
|
36
45
|
tokens?: TokenInput;
|
|
37
46
|
time?: {
|
|
38
47
|
created: number;
|
|
@@ -73,13 +82,16 @@ export declare function estimate(tokens: Tokens, prices?: readonly Price[]): {
|
|
|
73
82
|
cost: number;
|
|
74
83
|
defaultPrice: boolean;
|
|
75
84
|
};
|
|
76
|
-
export
|
|
85
|
+
export type CostStatus = "empty" | "complete" | "partial" | "unavailable";
|
|
86
|
+
/** Prices every call with its recorded model. OpenCode's resolved price wins;
|
|
87
|
+
* the built-in manufacturer snapshot is used only when that price is incomplete. */
|
|
88
|
+
export declare function summarize(messages: Iterable<UsageMessage>, catalog?: PriceCatalog): {
|
|
77
89
|
tokens: Tokens;
|
|
78
90
|
total: number;
|
|
79
91
|
cacheRate: number;
|
|
80
92
|
steps: number;
|
|
81
93
|
cost: number;
|
|
82
|
-
|
|
94
|
+
costStatus: CostStatus;
|
|
83
95
|
};
|
|
84
96
|
export type Summary = ReturnType<typeof summarize>;
|
|
85
97
|
export interface ContextUsage {
|