@kaitranntt/ccs 5.13.0-dev.1 → 5.13.0-dev.2

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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Model Pricing Registry
3
+ *
4
+ * User-editable pricing configuration for Claude Code usage analytics.
5
+ * Update rates below when new models are released or pricing changes.
6
+ *
7
+ * All rates are in USD per MILLION tokens.
8
+ */
9
+ export interface ModelPricing {
10
+ inputPerMillion: number;
11
+ outputPerMillion: number;
12
+ cacheCreationPerMillion: number;
13
+ cacheReadPerMillion: number;
14
+ }
15
+ export interface TokenUsage {
16
+ inputTokens: number;
17
+ outputTokens: number;
18
+ cacheCreationTokens: number;
19
+ cacheReadTokens: number;
20
+ }
21
+ /**
22
+ * Get pricing for a model with fuzzy matching fallback
23
+ * @param model - Model name (exact or with provider prefix)
24
+ * @returns ModelPricing for the model or fallback pricing
25
+ */
26
+ export declare function getModelPricing(model: string): ModelPricing;
27
+ /**
28
+ * Calculate cost in USD from token usage and model
29
+ * @param usage - Token counts (input, output, cache creation, cache read)
30
+ * @param model - Model name for pricing lookup
31
+ * @returns Cost in USD
32
+ */
33
+ export declare function calculateCost(usage: TokenUsage, model: string): number;
34
+ /**
35
+ * Get list of all known models for UI display
36
+ */
37
+ export declare function getKnownModels(): string[];
38
+ /**
39
+ * Check if a model has custom pricing (not using fallback)
40
+ */
41
+ export declare function hasCustomPricing(model: string): boolean;
42
+ //# sourceMappingURL=model-pricing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-pricing.d.ts","sourceRoot":"","sources":["../../src/web-server/model-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;CACzB;AAqkBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CA6B3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUtE;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKvD"}
@@ -0,0 +1,642 @@
1
+ "use strict";
2
+ /**
3
+ * Model Pricing Registry
4
+ *
5
+ * User-editable pricing configuration for Claude Code usage analytics.
6
+ * Update rates below when new models are released or pricing changes.
7
+ *
8
+ * All rates are in USD per MILLION tokens.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.hasCustomPricing = exports.getKnownModels = exports.calculateCost = exports.getModelPricing = void 0;
12
+ // ============================================================================
13
+ // USER-EDITABLE PRICING TABLE
14
+ // Update rates below (per million tokens in USD)
15
+ // ============================================================================
16
+ const PRICING_REGISTRY = {
17
+ // ---------------------------------------------------------------------------
18
+ // Claude Models (Anthropic) - Source: Official Anthropic pricing
19
+ // cacheCreation = 5min cache writes, cacheRead = cache hits & refreshes
20
+ // ---------------------------------------------------------------------------
21
+ // Claude 3 Haiku ($0.25/$1.25)
22
+ 'claude-3-haiku-20240307': {
23
+ inputPerMillion: 0.25,
24
+ outputPerMillion: 1.25,
25
+ cacheCreationPerMillion: 0.3,
26
+ cacheReadPerMillion: 0.03,
27
+ },
28
+ // Claude 3.5 Haiku ($0.80/$4)
29
+ 'claude-3-5-haiku-20241022': {
30
+ inputPerMillion: 0.8,
31
+ outputPerMillion: 4.0,
32
+ cacheCreationPerMillion: 1.0,
33
+ cacheReadPerMillion: 0.08,
34
+ },
35
+ 'claude-3-5-haiku-latest': {
36
+ inputPerMillion: 0.8,
37
+ outputPerMillion: 4.0,
38
+ cacheCreationPerMillion: 1.0,
39
+ cacheReadPerMillion: 0.08,
40
+ },
41
+ // Claude 4.5 Haiku ($1/$5)
42
+ 'claude-haiku-4-5-20251001': {
43
+ inputPerMillion: 1.0,
44
+ outputPerMillion: 5.0,
45
+ cacheCreationPerMillion: 1.25,
46
+ cacheReadPerMillion: 0.1,
47
+ },
48
+ 'claude-haiku-4-5': {
49
+ inputPerMillion: 1.0,
50
+ outputPerMillion: 5.0,
51
+ cacheCreationPerMillion: 1.25,
52
+ cacheReadPerMillion: 0.1,
53
+ },
54
+ // Claude 3.5 Sonnet (deprecated, same as Sonnet 3.7: $3/$15)
55
+ 'claude-3-5-sonnet-20240620': {
56
+ inputPerMillion: 3.0,
57
+ outputPerMillion: 15.0,
58
+ cacheCreationPerMillion: 3.75,
59
+ cacheReadPerMillion: 0.3,
60
+ },
61
+ 'claude-3-5-sonnet-20241022': {
62
+ inputPerMillion: 3.0,
63
+ outputPerMillion: 15.0,
64
+ cacheCreationPerMillion: 3.75,
65
+ cacheReadPerMillion: 0.3,
66
+ },
67
+ 'claude-3-5-sonnet-latest': {
68
+ inputPerMillion: 3.0,
69
+ outputPerMillion: 15.0,
70
+ cacheCreationPerMillion: 3.75,
71
+ cacheReadPerMillion: 0.3,
72
+ },
73
+ // Claude 3.7 Sonnet (deprecated: $3/$15)
74
+ 'claude-3-7-sonnet-20250219': {
75
+ inputPerMillion: 3.0,
76
+ outputPerMillion: 15.0,
77
+ cacheCreationPerMillion: 3.75,
78
+ cacheReadPerMillion: 0.3,
79
+ },
80
+ 'claude-3-7-sonnet-latest': {
81
+ inputPerMillion: 3.0,
82
+ outputPerMillion: 15.0,
83
+ cacheCreationPerMillion: 3.75,
84
+ cacheReadPerMillion: 0.3,
85
+ },
86
+ // Claude 3 Opus (deprecated: $15/$75)
87
+ 'claude-3-opus-20240229': {
88
+ inputPerMillion: 15.0,
89
+ outputPerMillion: 75.0,
90
+ cacheCreationPerMillion: 18.75,
91
+ cacheReadPerMillion: 1.5,
92
+ },
93
+ 'claude-3-opus-latest': {
94
+ inputPerMillion: 15.0,
95
+ outputPerMillion: 75.0,
96
+ cacheCreationPerMillion: 18.75,
97
+ cacheReadPerMillion: 1.5,
98
+ },
99
+ // Claude 4 Sonnet ($3/$15)
100
+ 'claude-4-sonnet-20250514': {
101
+ inputPerMillion: 3.0,
102
+ outputPerMillion: 15.0,
103
+ cacheCreationPerMillion: 3.75,
104
+ cacheReadPerMillion: 0.3,
105
+ },
106
+ 'claude-sonnet-4-20250514': {
107
+ inputPerMillion: 3.0,
108
+ outputPerMillion: 15.0,
109
+ cacheCreationPerMillion: 3.75,
110
+ cacheReadPerMillion: 0.3,
111
+ },
112
+ 'claude-sonnet-4': {
113
+ inputPerMillion: 3.0,
114
+ outputPerMillion: 15.0,
115
+ cacheCreationPerMillion: 3.75,
116
+ cacheReadPerMillion: 0.3,
117
+ },
118
+ // Claude 4.5 Sonnet ($3/$15)
119
+ 'claude-sonnet-4-5-20250929': {
120
+ inputPerMillion: 3.0,
121
+ outputPerMillion: 15.0,
122
+ cacheCreationPerMillion: 3.75,
123
+ cacheReadPerMillion: 0.3,
124
+ },
125
+ 'claude-sonnet-4-5': {
126
+ inputPerMillion: 3.0,
127
+ outputPerMillion: 15.0,
128
+ cacheCreationPerMillion: 3.75,
129
+ cacheReadPerMillion: 0.3,
130
+ },
131
+ 'claude-sonnet-4-5-thinking': {
132
+ inputPerMillion: 3.0,
133
+ outputPerMillion: 15.0,
134
+ cacheCreationPerMillion: 3.75,
135
+ cacheReadPerMillion: 0.3,
136
+ },
137
+ // Claude 4 Opus ($15/$75)
138
+ 'claude-4-opus-20250514': {
139
+ inputPerMillion: 15.0,
140
+ outputPerMillion: 75.0,
141
+ cacheCreationPerMillion: 18.75,
142
+ cacheReadPerMillion: 1.5,
143
+ },
144
+ 'claude-opus-4-20250514': {
145
+ inputPerMillion: 15.0,
146
+ outputPerMillion: 75.0,
147
+ cacheCreationPerMillion: 18.75,
148
+ cacheReadPerMillion: 1.5,
149
+ },
150
+ 'claude-opus-4': {
151
+ inputPerMillion: 15.0,
152
+ outputPerMillion: 75.0,
153
+ cacheCreationPerMillion: 18.75,
154
+ cacheReadPerMillion: 1.5,
155
+ },
156
+ // Claude 4.1 Opus ($15/$75)
157
+ 'claude-opus-4-1': {
158
+ inputPerMillion: 15.0,
159
+ outputPerMillion: 75.0,
160
+ cacheCreationPerMillion: 18.75,
161
+ cacheReadPerMillion: 1.5,
162
+ },
163
+ 'claude-opus-4-1-20250805': {
164
+ inputPerMillion: 15.0,
165
+ outputPerMillion: 75.0,
166
+ cacheCreationPerMillion: 18.75,
167
+ cacheReadPerMillion: 1.5,
168
+ },
169
+ // Claude 4.5 Opus ($5/$25) - NEW PRICING!
170
+ 'claude-opus-4-5-20251101': {
171
+ inputPerMillion: 5.0,
172
+ outputPerMillion: 25.0,
173
+ cacheCreationPerMillion: 6.25,
174
+ cacheReadPerMillion: 0.5,
175
+ },
176
+ 'claude-opus-4-5': {
177
+ inputPerMillion: 5.0,
178
+ outputPerMillion: 25.0,
179
+ cacheCreationPerMillion: 6.25,
180
+ cacheReadPerMillion: 0.5,
181
+ },
182
+ 'claude-opus-4-5-thinking': {
183
+ inputPerMillion: 5.0,
184
+ outputPerMillion: 25.0,
185
+ cacheCreationPerMillion: 6.25,
186
+ cacheReadPerMillion: 0.5,
187
+ },
188
+ // ---------------------------------------------------------------------------
189
+ // OpenAI Models - Source: better-ccusage
190
+ // ---------------------------------------------------------------------------
191
+ // GPT-4o
192
+ 'gpt-4o': {
193
+ inputPerMillion: 2.5,
194
+ outputPerMillion: 10.0,
195
+ cacheCreationPerMillion: 0.0,
196
+ cacheReadPerMillion: 1.25,
197
+ },
198
+ 'gpt-4o-2024-08-06': {
199
+ inputPerMillion: 2.5,
200
+ outputPerMillion: 10.0,
201
+ cacheCreationPerMillion: 0.0,
202
+ cacheReadPerMillion: 1.25,
203
+ },
204
+ 'gpt-4o-2024-11-20': {
205
+ inputPerMillion: 2.5,
206
+ outputPerMillion: 10.0,
207
+ cacheCreationPerMillion: 0.0,
208
+ cacheReadPerMillion: 1.25,
209
+ },
210
+ 'gpt-4o-mini': {
211
+ inputPerMillion: 0.15,
212
+ outputPerMillion: 0.6,
213
+ cacheCreationPerMillion: 0.0,
214
+ cacheReadPerMillion: 0.075,
215
+ },
216
+ // GPT-4.1
217
+ 'gpt-4.1': {
218
+ inputPerMillion: 2.0,
219
+ outputPerMillion: 8.0,
220
+ cacheCreationPerMillion: 0.0,
221
+ cacheReadPerMillion: 0.5,
222
+ },
223
+ 'gpt-4.1-mini': {
224
+ inputPerMillion: 0.4,
225
+ outputPerMillion: 1.6,
226
+ cacheCreationPerMillion: 0.0,
227
+ cacheReadPerMillion: 0.1,
228
+ },
229
+ 'gpt-4.1-nano': {
230
+ inputPerMillion: 0.1,
231
+ outputPerMillion: 0.4,
232
+ cacheCreationPerMillion: 0.0,
233
+ cacheReadPerMillion: 0.025,
234
+ },
235
+ // GPT-4.5
236
+ 'gpt-4.5-preview': {
237
+ inputPerMillion: 75.0,
238
+ outputPerMillion: 150.0,
239
+ cacheCreationPerMillion: 0.0,
240
+ cacheReadPerMillion: 37.5,
241
+ },
242
+ // GPT-3.5 Turbo
243
+ 'gpt-3.5-turbo': {
244
+ inputPerMillion: 1.5,
245
+ outputPerMillion: 2.0,
246
+ cacheCreationPerMillion: 0.0,
247
+ cacheReadPerMillion: 0.0,
248
+ },
249
+ 'gpt-3.5-turbo-0125': {
250
+ inputPerMillion: 0.5,
251
+ outputPerMillion: 1.5,
252
+ cacheCreationPerMillion: 0.0,
253
+ cacheReadPerMillion: 0.0,
254
+ },
255
+ // o1 Reasoning Models
256
+ o1: {
257
+ inputPerMillion: 15.0,
258
+ outputPerMillion: 60.0,
259
+ cacheCreationPerMillion: 0.0,
260
+ cacheReadPerMillion: 7.5,
261
+ },
262
+ 'o1-preview': {
263
+ inputPerMillion: 15.0,
264
+ outputPerMillion: 60.0,
265
+ cacheCreationPerMillion: 0.0,
266
+ cacheReadPerMillion: 7.5,
267
+ },
268
+ 'o1-mini': {
269
+ inputPerMillion: 3.0,
270
+ outputPerMillion: 12.0,
271
+ cacheCreationPerMillion: 0.0,
272
+ cacheReadPerMillion: 1.5,
273
+ },
274
+ 'o3-mini': {
275
+ inputPerMillion: 1.1,
276
+ outputPerMillion: 4.4,
277
+ cacheCreationPerMillion: 0.0,
278
+ cacheReadPerMillion: 0.55,
279
+ },
280
+ // OpenAI GPT-5 / Codex - Source: better-ccusage
281
+ 'gpt-5': {
282
+ inputPerMillion: 1.25,
283
+ outputPerMillion: 10.0,
284
+ cacheCreationPerMillion: 0.0,
285
+ cacheReadPerMillion: 0.125,
286
+ },
287
+ 'gpt-5-chat': {
288
+ inputPerMillion: 1.25,
289
+ outputPerMillion: 10.0,
290
+ cacheCreationPerMillion: 0.0,
291
+ cacheReadPerMillion: 0.125,
292
+ },
293
+ 'gpt-5-codex': {
294
+ inputPerMillion: 1.25,
295
+ outputPerMillion: 10.0,
296
+ cacheCreationPerMillion: 0.0,
297
+ cacheReadPerMillion: 0.125,
298
+ },
299
+ 'gpt-5-mini': {
300
+ inputPerMillion: 0.25,
301
+ outputPerMillion: 2.0,
302
+ cacheCreationPerMillion: 0.0,
303
+ cacheReadPerMillion: 0.025,
304
+ },
305
+ 'gpt-5-nano': {
306
+ inputPerMillion: 0.05,
307
+ outputPerMillion: 0.4,
308
+ cacheCreationPerMillion: 0.0,
309
+ cacheReadPerMillion: 0.005,
310
+ },
311
+ 'codex-mini-latest': {
312
+ inputPerMillion: 1.5,
313
+ outputPerMillion: 6.0,
314
+ cacheCreationPerMillion: 0.0,
315
+ cacheReadPerMillion: 0.375,
316
+ },
317
+ // ---------------------------------------------------------------------------
318
+ // Google Gemini Models - Source: better-ccusage
319
+ // ---------------------------------------------------------------------------
320
+ // Gemini 2.5
321
+ 'gemini-2.5-flash': {
322
+ inputPerMillion: 0.3,
323
+ outputPerMillion: 2.5,
324
+ cacheCreationPerMillion: 0.0,
325
+ cacheReadPerMillion: 0.075,
326
+ },
327
+ 'gemini-2.5-flash-lite': {
328
+ inputPerMillion: 0.1,
329
+ outputPerMillion: 0.4,
330
+ cacheCreationPerMillion: 0.0,
331
+ cacheReadPerMillion: 0.025,
332
+ },
333
+ 'gemini-2.5-pro': {
334
+ inputPerMillion: 1.25,
335
+ outputPerMillion: 10.0,
336
+ cacheCreationPerMillion: 0.0,
337
+ cacheReadPerMillion: 0.3125,
338
+ },
339
+ // Gemini 2.0
340
+ 'gemini-2.0-flash': {
341
+ inputPerMillion: 0.1,
342
+ outputPerMillion: 0.4,
343
+ cacheCreationPerMillion: 0.0,
344
+ cacheReadPerMillion: 0.025,
345
+ },
346
+ 'gemini-2.0-flash-exp': {
347
+ inputPerMillion: 0.0,
348
+ outputPerMillion: 0.0,
349
+ cacheCreationPerMillion: 0.0,
350
+ cacheReadPerMillion: 0.0,
351
+ },
352
+ // Gemini 1.5
353
+ 'gemini-1.5-flash': {
354
+ inputPerMillion: 0.075,
355
+ outputPerMillion: 0.3,
356
+ cacheCreationPerMillion: 0.0,
357
+ cacheReadPerMillion: 0.0,
358
+ },
359
+ 'gemini-1.5-flash-8b': {
360
+ inputPerMillion: 0.0375,
361
+ outputPerMillion: 0.15,
362
+ cacheCreationPerMillion: 0.0,
363
+ cacheReadPerMillion: 0.0,
364
+ },
365
+ 'gemini-1.5-pro': {
366
+ inputPerMillion: 3.5,
367
+ outputPerMillion: 10.5,
368
+ cacheCreationPerMillion: 0.0,
369
+ cacheReadPerMillion: 0.0,
370
+ },
371
+ // Gemini 3 - Official pricing (Nov 2025): ≤200k ctx: $2/$12, >200k ctx: $4/$18
372
+ // Using standard ≤200k pricing as default
373
+ 'gemini-3-pro-preview': {
374
+ inputPerMillion: 2.0,
375
+ outputPerMillion: 12.0,
376
+ cacheCreationPerMillion: 0.0,
377
+ cacheReadPerMillion: 0.0,
378
+ },
379
+ 'gemini-3-pro': {
380
+ inputPerMillion: 2.0,
381
+ outputPerMillion: 12.0,
382
+ cacheCreationPerMillion: 0.0,
383
+ cacheReadPerMillion: 0.0,
384
+ },
385
+ // High context variant (>200k tokens)
386
+ 'gemini-3-pro-high': {
387
+ inputPerMillion: 4.0,
388
+ outputPerMillion: 18.0,
389
+ cacheCreationPerMillion: 0.0,
390
+ cacheReadPerMillion: 0.0,
391
+ },
392
+ // ---------------------------------------------------------------------------
393
+ // GLM Models (Zhipu AI / Z.AI) - Source: better-ccusage
394
+ // ---------------------------------------------------------------------------
395
+ 'glm-4.6': {
396
+ inputPerMillion: 0.6,
397
+ outputPerMillion: 2.2,
398
+ cacheCreationPerMillion: 0.0,
399
+ cacheReadPerMillion: 0.11,
400
+ },
401
+ 'glm-4.6-cc-max': {
402
+ inputPerMillion: 0.6,
403
+ outputPerMillion: 2.2,
404
+ cacheCreationPerMillion: 0.0,
405
+ cacheReadPerMillion: 0.11,
406
+ },
407
+ 'glm-4.5': {
408
+ inputPerMillion: 0.6,
409
+ outputPerMillion: 2.2,
410
+ cacheCreationPerMillion: 0.0,
411
+ cacheReadPerMillion: 0.11,
412
+ },
413
+ 'glm-4.5-air': {
414
+ inputPerMillion: 0.2,
415
+ outputPerMillion: 1.1,
416
+ cacheCreationPerMillion: 0.0,
417
+ cacheReadPerMillion: 0.03,
418
+ },
419
+ // ---------------------------------------------------------------------------
420
+ // Kimi Models (Moonshot AI) - Source: better-ccusage
421
+ // ---------------------------------------------------------------------------
422
+ 'kimi-for-coding': {
423
+ inputPerMillion: 0.15,
424
+ outputPerMillion: 0.6,
425
+ cacheCreationPerMillion: 0.0,
426
+ cacheReadPerMillion: 0.0,
427
+ },
428
+ 'kimi-k2-0905-preview': {
429
+ inputPerMillion: 0.15,
430
+ outputPerMillion: 0.6,
431
+ cacheCreationPerMillion: 0.0,
432
+ cacheReadPerMillion: 0.0,
433
+ },
434
+ 'kimi-k2-turbo-preview': {
435
+ inputPerMillion: 0.15,
436
+ outputPerMillion: 1.15,
437
+ cacheCreationPerMillion: 0.0,
438
+ cacheReadPerMillion: 0.0,
439
+ },
440
+ 'kimi-k2-thinking': {
441
+ inputPerMillion: 0.15,
442
+ outputPerMillion: 0.6,
443
+ cacheCreationPerMillion: 0.0,
444
+ cacheReadPerMillion: 0.0,
445
+ },
446
+ 'kimi-k2-thinking-turbo': {
447
+ inputPerMillion: 0.15,
448
+ outputPerMillion: 1.15,
449
+ cacheCreationPerMillion: 0.0,
450
+ cacheReadPerMillion: 0.0,
451
+ },
452
+ 'kimi-k2-instruct': {
453
+ inputPerMillion: 1.0,
454
+ outputPerMillion: 3.0,
455
+ cacheCreationPerMillion: 0.0,
456
+ cacheReadPerMillion: 0.0,
457
+ },
458
+ 'kimi-latest': {
459
+ inputPerMillion: 2.0,
460
+ outputPerMillion: 5.0,
461
+ cacheCreationPerMillion: 0.0,
462
+ cacheReadPerMillion: 0.15,
463
+ },
464
+ 'kimi-latest-128k': {
465
+ inputPerMillion: 2.0,
466
+ outputPerMillion: 5.0,
467
+ cacheCreationPerMillion: 0.0,
468
+ cacheReadPerMillion: 0.15,
469
+ },
470
+ 'kimi-latest-32k': {
471
+ inputPerMillion: 1.0,
472
+ outputPerMillion: 3.0,
473
+ cacheCreationPerMillion: 0.0,
474
+ cacheReadPerMillion: 0.15,
475
+ },
476
+ 'kimi-latest-8k': {
477
+ inputPerMillion: 0.2,
478
+ outputPerMillion: 2.0,
479
+ cacheCreationPerMillion: 0.0,
480
+ cacheReadPerMillion: 0.15,
481
+ },
482
+ 'kimi-thinking-preview': {
483
+ inputPerMillion: 30.0,
484
+ outputPerMillion: 30.0,
485
+ cacheCreationPerMillion: 0.0,
486
+ cacheReadPerMillion: 0.0,
487
+ },
488
+ 'moonshot-v1-8k': {
489
+ inputPerMillion: 0.2,
490
+ outputPerMillion: 2.0,
491
+ cacheCreationPerMillion: 0.0,
492
+ cacheReadPerMillion: 0.0,
493
+ },
494
+ 'moonshot-v1-32k': {
495
+ inputPerMillion: 1.0,
496
+ outputPerMillion: 3.0,
497
+ cacheCreationPerMillion: 0.0,
498
+ cacheReadPerMillion: 0.0,
499
+ },
500
+ 'moonshot-v1-128k': {
501
+ inputPerMillion: 2.0,
502
+ outputPerMillion: 5.0,
503
+ cacheCreationPerMillion: 0.0,
504
+ cacheReadPerMillion: 0.0,
505
+ },
506
+ 'moonshot-v1-auto': {
507
+ inputPerMillion: 2.0,
508
+ outputPerMillion: 5.0,
509
+ cacheCreationPerMillion: 0.0,
510
+ cacheReadPerMillion: 0.0,
511
+ },
512
+ // ---------------------------------------------------------------------------
513
+ // DeepSeek Models - Source: better-ccusage
514
+ // ---------------------------------------------------------------------------
515
+ 'deepseek-chat': {
516
+ inputPerMillion: 0.27,
517
+ outputPerMillion: 1.1,
518
+ cacheCreationPerMillion: 0.0,
519
+ cacheReadPerMillion: 0.07,
520
+ },
521
+ 'deepseek-reasoner': {
522
+ inputPerMillion: 0.55,
523
+ outputPerMillion: 2.19,
524
+ cacheCreationPerMillion: 0.0,
525
+ cacheReadPerMillion: 0.14,
526
+ },
527
+ 'deepseek-coder': {
528
+ inputPerMillion: 0.14,
529
+ outputPerMillion: 0.28,
530
+ cacheCreationPerMillion: 0.0,
531
+ cacheReadPerMillion: 0.0,
532
+ },
533
+ // ---------------------------------------------------------------------------
534
+ // Mistral Models - Source: better-ccusage
535
+ // ---------------------------------------------------------------------------
536
+ 'mistral-large-latest': {
537
+ inputPerMillion: 2.0,
538
+ outputPerMillion: 6.0,
539
+ cacheCreationPerMillion: 0.0,
540
+ cacheReadPerMillion: 0.0,
541
+ },
542
+ 'mistral-medium-latest': {
543
+ inputPerMillion: 2.7,
544
+ outputPerMillion: 8.1,
545
+ cacheCreationPerMillion: 0.0,
546
+ cacheReadPerMillion: 0.0,
547
+ },
548
+ 'mistral-small-latest': {
549
+ inputPerMillion: 0.2,
550
+ outputPerMillion: 0.6,
551
+ cacheCreationPerMillion: 0.0,
552
+ cacheReadPerMillion: 0.0,
553
+ },
554
+ 'codestral-latest': {
555
+ inputPerMillion: 0.3,
556
+ outputPerMillion: 0.9,
557
+ cacheCreationPerMillion: 0.0,
558
+ cacheReadPerMillion: 0.0,
559
+ },
560
+ };
561
+ // Default pricing for unknown models
562
+ const UNKNOWN_MODEL_PRICING = {
563
+ inputPerMillion: 3.0,
564
+ outputPerMillion: 15.0,
565
+ cacheCreationPerMillion: 3.75,
566
+ cacheReadPerMillion: 0.3,
567
+ };
568
+ // ============================================================================
569
+ // PRICING FUNCTIONS
570
+ // ============================================================================
571
+ /**
572
+ * Normalize model name for matching
573
+ * Handles variations like provider prefixes and case differences
574
+ */
575
+ function normalizeModelName(model) {
576
+ // Remove provider prefixes (e.g., "anthropic/claude-..." -> "claude-...")
577
+ const normalized = model.toLowerCase().replace(/^[^/]+\//, '');
578
+ return normalized;
579
+ }
580
+ /**
581
+ * Get pricing for a model with fuzzy matching fallback
582
+ * @param model - Model name (exact or with provider prefix)
583
+ * @returns ModelPricing for the model or fallback pricing
584
+ */
585
+ function getModelPricing(model) {
586
+ // Try exact match first
587
+ if (PRICING_REGISTRY[model]) {
588
+ return PRICING_REGISTRY[model];
589
+ }
590
+ // Try normalized match
591
+ const normalized = normalizeModelName(model);
592
+ if (PRICING_REGISTRY[normalized]) {
593
+ return PRICING_REGISTRY[normalized];
594
+ }
595
+ // Try suffix matching (e.g., "claude-sonnet-4-5" matches "*-claude-sonnet-4-5")
596
+ for (const [key, pricing] of Object.entries(PRICING_REGISTRY)) {
597
+ if (normalized.endsWith(key) || key.endsWith(normalized)) {
598
+ return pricing;
599
+ }
600
+ }
601
+ // Try partial matching for model families
602
+ for (const [key, pricing] of Object.entries(PRICING_REGISTRY)) {
603
+ // Match by model family prefix
604
+ if (normalized.startsWith(key.split('-').slice(0, 2).join('-'))) {
605
+ return pricing;
606
+ }
607
+ }
608
+ // Fallback to unknown model pricing
609
+ return UNKNOWN_MODEL_PRICING;
610
+ }
611
+ exports.getModelPricing = getModelPricing;
612
+ /**
613
+ * Calculate cost in USD from token usage and model
614
+ * @param usage - Token counts (input, output, cache creation, cache read)
615
+ * @param model - Model name for pricing lookup
616
+ * @returns Cost in USD
617
+ */
618
+ function calculateCost(usage, model) {
619
+ const pricing = getModelPricing(model);
620
+ const inputCost = (usage.inputTokens / 1000000) * pricing.inputPerMillion;
621
+ const outputCost = (usage.outputTokens / 1000000) * pricing.outputPerMillion;
622
+ const cacheCreationCost = (usage.cacheCreationTokens / 1000000) * pricing.cacheCreationPerMillion;
623
+ const cacheReadCost = (usage.cacheReadTokens / 1000000) * pricing.cacheReadPerMillion;
624
+ return inputCost + outputCost + cacheCreationCost + cacheReadCost;
625
+ }
626
+ exports.calculateCost = calculateCost;
627
+ /**
628
+ * Get list of all known models for UI display
629
+ */
630
+ function getKnownModels() {
631
+ return Object.keys(PRICING_REGISTRY);
632
+ }
633
+ exports.getKnownModels = getKnownModels;
634
+ /**
635
+ * Check if a model has custom pricing (not using fallback)
636
+ */
637
+ function hasCustomPricing(model) {
638
+ return (PRICING_REGISTRY[model] !== undefined ||
639
+ PRICING_REGISTRY[normalizeModelName(model)] !== undefined);
640
+ }
641
+ exports.hasCustomPricing = hasCustomPricing;
642
+ //# sourceMappingURL=model-pricing.js.map