@agentproto/model-catalog 0.2.0

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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/dist/access/index.d.ts +30 -0
  4. package/dist/access/index.mjs +4 -0
  5. package/dist/access/index.mjs.map +1 -0
  6. package/dist/audio/index.d.ts +84 -0
  7. package/dist/audio/index.mjs +3 -0
  8. package/dist/audio/index.mjs.map +1 -0
  9. package/dist/audio-BzVF_wke.d.ts +92 -0
  10. package/dist/base-BNHcMifc.d.ts +109 -0
  11. package/dist/byok/index.d.ts +33 -0
  12. package/dist/byok/index.mjs +3 -0
  13. package/dist/byok/index.mjs.map +1 -0
  14. package/dist/catalog-aQHd559b.d.ts +594 -0
  15. package/dist/chunk-2LWYZOWB.mjs +643 -0
  16. package/dist/chunk-2LWYZOWB.mjs.map +1 -0
  17. package/dist/chunk-CINXNTU3.mjs +134 -0
  18. package/dist/chunk-CINXNTU3.mjs.map +1 -0
  19. package/dist/chunk-F7OEHYUI.mjs +187 -0
  20. package/dist/chunk-F7OEHYUI.mjs.map +1 -0
  21. package/dist/chunk-GH7PB5FB.mjs +183 -0
  22. package/dist/chunk-GH7PB5FB.mjs.map +1 -0
  23. package/dist/chunk-H6JUTF3U.mjs +33 -0
  24. package/dist/chunk-H6JUTF3U.mjs.map +1 -0
  25. package/dist/chunk-HEDDSOZF.mjs +47 -0
  26. package/dist/chunk-HEDDSOZF.mjs.map +1 -0
  27. package/dist/chunk-HRRG2RZO.mjs +116 -0
  28. package/dist/chunk-HRRG2RZO.mjs.map +1 -0
  29. package/dist/chunk-IJZ4XPO2.mjs +606 -0
  30. package/dist/chunk-IJZ4XPO2.mjs.map +1 -0
  31. package/dist/chunk-IORIAFK2.mjs +227 -0
  32. package/dist/chunk-IORIAFK2.mjs.map +1 -0
  33. package/dist/chunk-OHAMH3ZE.mjs +2629 -0
  34. package/dist/chunk-OHAMH3ZE.mjs.map +1 -0
  35. package/dist/chunk-QHELXPSL.mjs +85 -0
  36. package/dist/chunk-QHELXPSL.mjs.map +1 -0
  37. package/dist/chunk-SGJR6ZQH.mjs +1230 -0
  38. package/dist/chunk-SGJR6ZQH.mjs.map +1 -0
  39. package/dist/chunk-WRUWNKDB.mjs +521 -0
  40. package/dist/chunk-WRUWNKDB.mjs.map +1 -0
  41. package/dist/chunk-WTHHXXIK.mjs +366 -0
  42. package/dist/chunk-WTHHXXIK.mjs.map +1 -0
  43. package/dist/chunk-XFDXTFV3.mjs +28 -0
  44. package/dist/chunk-XFDXTFV3.mjs.map +1 -0
  45. package/dist/cost/index.d.ts +114 -0
  46. package/dist/cost/index.mjs +13 -0
  47. package/dist/cost/index.mjs.map +1 -0
  48. package/dist/curation/index.d.ts +98 -0
  49. package/dist/curation/index.mjs +13 -0
  50. package/dist/curation/index.mjs.map +1 -0
  51. package/dist/evaluate-DisH3H7u.d.ts +84 -0
  52. package/dist/image/index.d.ts +79 -0
  53. package/dist/image/index.mjs +3 -0
  54. package/dist/image/index.mjs.map +1 -0
  55. package/dist/index-BICjPG8H.d.ts +132 -0
  56. package/dist/index-D8nL3fPZ.d.ts +171 -0
  57. package/dist/index.d.ts +94 -0
  58. package/dist/index.mjs +33 -0
  59. package/dist/index.mjs.map +1 -0
  60. package/dist/llm/index.d.ts +48 -0
  61. package/dist/llm/index.mjs +4 -0
  62. package/dist/llm/index.mjs.map +1 -0
  63. package/dist/overlay/index.d.ts +67 -0
  64. package/dist/overlay/index.mjs +3 -0
  65. package/dist/overlay/index.mjs.map +1 -0
  66. package/dist/picker/index.d.ts +11 -0
  67. package/dist/picker/index.mjs +26 -0
  68. package/dist/picker/index.mjs.map +1 -0
  69. package/dist/pricing/index.d.ts +106 -0
  70. package/dist/pricing/index.mjs +3 -0
  71. package/dist/pricing/index.mjs.map +1 -0
  72. package/dist/providers/index.d.ts +78 -0
  73. package/dist/providers/index.mjs +237 -0
  74. package/dist/providers/index.mjs.map +1 -0
  75. package/dist/schema/index.d.ts +627 -0
  76. package/dist/schema/index.mjs +4 -0
  77. package/dist/schema/index.mjs.map +1 -0
  78. package/dist/schema/voice.d.ts +66 -0
  79. package/dist/schema/voice.mjs +3 -0
  80. package/dist/schema/voice.mjs.map +1 -0
  81. package/dist/video/index.d.ts +78 -0
  82. package/dist/video/index.mjs +3 -0
  83. package/dist/video/index.mjs.map +1 -0
  84. package/dist/voice/index.d.ts +1300 -0
  85. package/dist/voice/index.mjs +4 -0
  86. package/dist/voice/index.mjs.map +1 -0
  87. package/package.json +137 -0
@@ -0,0 +1,594 @@
1
+ import { C as CatalogProvider } from './base-BNHcMifc.js';
2
+
3
+ /**
4
+ * LLM Pricing Catalog — per-token costs for all LLM models.
5
+ *
6
+ * Migrated from `packages/core/src/config/llm-pricing.ts` (commit `eeb1acdc`
7
+ * era). The original location now re-exports from here so every existing
8
+ * consumer (orchestrator dynamic imports, agent-analytics) keeps working.
9
+ *
10
+ * Prices in USD per 1M tokens (input and output separated).
11
+ * Credit costs are what we charge users (includes margin).
12
+ */
13
+
14
+ interface LLMPricing {
15
+ /** Provider cost: $ per 1M input tokens */
16
+ inputPer1M: number;
17
+ /** Provider cost: $ per 1M output tokens */
18
+ outputPer1M: number;
19
+ /**
20
+ * Strategic per-model centicredit override for input. Bypasses the
21
+ * default `inputPer1M × text-markup / CC_USD_RATE` formula. Use only
22
+ * for explicit loss-leader / promo models — formula path is
23
+ * cost-plus-margin by construction and self-heals when providers
24
+ * change rates.
25
+ *
26
+ * Unit: **centicredits per 1M input tokens** (1 displayed credit =
27
+ * 100 cc). Example: `overrideCreditInputPer1M: 1000` charges 10
28
+ * displayed credits per 1M input tokens.
29
+ */
30
+ overrideCreditInputPer1M?: number;
31
+ /** Same as `overrideCreditInputPer1M`, for output tokens. Unit: cc/1M. */
32
+ overrideCreditOutputPer1M?: number;
33
+ /**
34
+ * Provider-side discount for cache-read tokens (Anthropic prompt
35
+ * caching: ~10% of base input). Default 1.0 — no cache discount —
36
+ * for providers without prompt caching. Applies to BOTH the
37
+ * provider-cost calculation AND the derived credit cost so the
38
+ * margin holds for cached vs uncached tokens.
39
+ */
40
+ cacheReadMultiplier?: number;
41
+ /**
42
+ * Provider-side premium for cache-creation tokens (Anthropic prompt
43
+ * caching: ~125% of base input — slightly more than uncached, but
44
+ * the savings come from subsequent reads). Default 1.0. Applies to
45
+ * BOTH sides like `cacheReadMultiplier`.
46
+ */
47
+ cacheWriteMultiplier?: number;
48
+ /**
49
+ * Router / SDK used to call the model. Same model can be reachable via
50
+ * multiple providers — `claude-sonnet-4-5` is `provider: "anthropic"`
51
+ * when called through the Anthropic SDK and `provider: "openrouter"`
52
+ * when routed through OpenRouter. Distinct from `vendor`: this is HOW
53
+ * we reach the model, not WHO made it.
54
+ * - bare ids (`claude-sonnet-4-5`, `gpt-4o`, `gemini-2.5-flash`)
55
+ * → `"anthropic" | "openai" | "google"` (direct providers)
56
+ * - slash ids (`anthropic/claude-sonnet-4-5`, `qwen/qwen3-coder`)
57
+ * → `"openrouter"` (always — the slash is the OpenRouter route
58
+ * convention and the OpenRouter SDK is what runs them)
59
+ *
60
+ * The runtime can still pass an explicit `connectorUsed` to
61
+ * `emitUsageEvent` — that wins over this default and covers the
62
+ * edge case where a guild has multiple connectors and the
63
+ * dispatcher routed to a non-default one.
64
+ */
65
+ provider?: CatalogProvider;
66
+ /**
67
+ * Who authored / built the model. Permanent attribute, independent of
68
+ * the router: `claude-sonnet-4-5` is always `vendor: "anthropic"`
69
+ * regardless of whether `provider` is `"anthropic"` (direct) or
70
+ * `"openrouter"` (proxied). Used for display labels, BYOK gating, and
71
+ * analytics grouping. Examples: `anthropic`, `openai`, `google`,
72
+ * `moonshot`, `mistralai`, `minimax`, `meta`, `qwen`, `deepseek`.
73
+ */
74
+ vendor?: string;
75
+ }
76
+ declare const LLM_PRICING_CATALOG: {
77
+ "claude-opus-4-5": {
78
+ inputPer1M: number;
79
+ outputPer1M: number;
80
+ cacheReadMultiplier: number;
81
+ cacheWriteMultiplier: number;
82
+ vendor: string;
83
+ provider: "anthropic";
84
+ };
85
+ "claude-sonnet-4-5": {
86
+ inputPer1M: number;
87
+ outputPer1M: number;
88
+ cacheReadMultiplier: number;
89
+ cacheWriteMultiplier: number;
90
+ vendor: string;
91
+ provider: "anthropic";
92
+ };
93
+ "claude-haiku-4-5": {
94
+ inputPer1M: number;
95
+ outputPer1M: number;
96
+ cacheReadMultiplier: number;
97
+ cacheWriteMultiplier: number;
98
+ vendor: string;
99
+ provider: "anthropic";
100
+ };
101
+ "gemini-2.5-flash": {
102
+ inputPer1M: number;
103
+ outputPer1M: number;
104
+ cacheReadMultiplier: number;
105
+ vendor: string;
106
+ provider: "google";
107
+ };
108
+ "gemini-2.5-pro": {
109
+ inputPer1M: number;
110
+ outputPer1M: number;
111
+ cacheReadMultiplier: number;
112
+ vendor: string;
113
+ provider: "google";
114
+ };
115
+ "gemini-3.5-flash": {
116
+ inputPer1M: number;
117
+ outputPer1M: number;
118
+ cacheReadMultiplier: number;
119
+ vendor: string;
120
+ provider: "google";
121
+ };
122
+ "gemini-2.5-flash-lite": {
123
+ inputPer1M: number;
124
+ outputPer1M: number;
125
+ cacheReadMultiplier: number;
126
+ vendor: string;
127
+ provider: "google";
128
+ };
129
+ "gemini-3.1-pro-preview": {
130
+ inputPer1M: number;
131
+ outputPer1M: number;
132
+ cacheReadMultiplier: number;
133
+ vendor: string;
134
+ provider: "google";
135
+ };
136
+ "gemini-3-flash-preview": {
137
+ inputPer1M: number;
138
+ outputPer1M: number;
139
+ cacheReadMultiplier: number;
140
+ vendor: string;
141
+ provider: "google";
142
+ };
143
+ "gemini-3.1-flash-lite": {
144
+ inputPer1M: number;
145
+ outputPer1M: number;
146
+ cacheReadMultiplier: number;
147
+ vendor: string;
148
+ provider: "google";
149
+ };
150
+ "gpt-5.5": {
151
+ inputPer1M: number;
152
+ outputPer1M: number;
153
+ cacheReadMultiplier: number;
154
+ vendor: string;
155
+ provider: "openai";
156
+ };
157
+ "gpt-5.5-pro": {
158
+ inputPer1M: number;
159
+ outputPer1M: number;
160
+ vendor: string;
161
+ provider: "openai";
162
+ };
163
+ "gpt-5.4": {
164
+ inputPer1M: number;
165
+ outputPer1M: number;
166
+ cacheReadMultiplier: number;
167
+ vendor: string;
168
+ provider: "openai";
169
+ };
170
+ "gpt-5.4-mini": {
171
+ inputPer1M: number;
172
+ outputPer1M: number;
173
+ cacheReadMultiplier: number;
174
+ vendor: string;
175
+ provider: "openai";
176
+ };
177
+ "gpt-5.4-nano": {
178
+ inputPer1M: number;
179
+ outputPer1M: number;
180
+ cacheReadMultiplier: number;
181
+ vendor: string;
182
+ provider: "openai";
183
+ };
184
+ "gpt-5.4-pro": {
185
+ inputPer1M: number;
186
+ outputPer1M: number;
187
+ vendor: string;
188
+ provider: "openai";
189
+ };
190
+ "gpt-5.2": {
191
+ inputPer1M: number;
192
+ outputPer1M: number;
193
+ cacheReadMultiplier: number;
194
+ vendor: string;
195
+ provider: "openai";
196
+ };
197
+ "gpt-5.1": {
198
+ inputPer1M: number;
199
+ outputPer1M: number;
200
+ cacheReadMultiplier: number;
201
+ vendor: string;
202
+ provider: "openai";
203
+ };
204
+ "gpt-5": {
205
+ inputPer1M: number;
206
+ outputPer1M: number;
207
+ cacheReadMultiplier: number;
208
+ vendor: string;
209
+ provider: "openai";
210
+ };
211
+ "gpt-4.1": {
212
+ inputPer1M: number;
213
+ outputPer1M: number;
214
+ vendor: string;
215
+ provider: "openai";
216
+ };
217
+ "gpt-4.1-mini": {
218
+ inputPer1M: number;
219
+ outputPer1M: number;
220
+ vendor: string;
221
+ provider: "openai";
222
+ };
223
+ "gpt-4.1-nano": {
224
+ inputPer1M: number;
225
+ outputPer1M: number;
226
+ cacheReadMultiplier: number;
227
+ vendor: string;
228
+ provider: "openai";
229
+ };
230
+ "gpt-4o": {
231
+ inputPer1M: number;
232
+ outputPer1M: number;
233
+ vendor: string;
234
+ provider: "openai";
235
+ };
236
+ "gpt-4o-mini": {
237
+ inputPer1M: number;
238
+ outputPer1M: number;
239
+ vendor: string;
240
+ provider: "openai";
241
+ };
242
+ o3: {
243
+ inputPer1M: number;
244
+ outputPer1M: number;
245
+ vendor: string;
246
+ provider: "openai";
247
+ };
248
+ "o4-mini": {
249
+ inputPer1M: number;
250
+ outputPer1M: number;
251
+ cacheReadMultiplier: number;
252
+ vendor: string;
253
+ provider: "openai";
254
+ };
255
+ "o3-mini": {
256
+ inputPer1M: number;
257
+ outputPer1M: number;
258
+ vendor: string;
259
+ provider: "openai";
260
+ };
261
+ o1: {
262
+ inputPer1M: number;
263
+ outputPer1M: number;
264
+ cacheReadMultiplier: number;
265
+ vendor: string;
266
+ provider: "openai";
267
+ };
268
+ "o1-mini": {
269
+ inputPer1M: number;
270
+ outputPer1M: number;
271
+ vendor: string;
272
+ provider: "openai";
273
+ };
274
+ "MiniMax-M2": {
275
+ inputPer1M: number;
276
+ outputPer1M: number;
277
+ cacheReadMultiplier: number;
278
+ cacheWriteMultiplier: number;
279
+ vendor: string;
280
+ provider: "minimax";
281
+ };
282
+ "M2-her": {
283
+ inputPer1M: number;
284
+ outputPer1M: number;
285
+ cacheReadMultiplier: number;
286
+ cacheWriteMultiplier: number;
287
+ vendor: string;
288
+ provider: "minimax";
289
+ };
290
+ "MiniMax-M2.1": {
291
+ inputPer1M: number;
292
+ outputPer1M: number;
293
+ cacheReadMultiplier: number;
294
+ cacheWriteMultiplier: number;
295
+ vendor: string;
296
+ provider: "minimax";
297
+ };
298
+ "MiniMax-M2.5": {
299
+ inputPer1M: number;
300
+ outputPer1M: number;
301
+ cacheReadMultiplier: number;
302
+ cacheWriteMultiplier: number;
303
+ vendor: string;
304
+ provider: "minimax";
305
+ };
306
+ "MiniMax-M2.7": {
307
+ inputPer1M: number;
308
+ outputPer1M: number;
309
+ vendor: string;
310
+ provider: "minimax";
311
+ };
312
+ "kimi-k2.6": {
313
+ inputPer1M: number;
314
+ outputPer1M: number;
315
+ cacheReadMultiplier: number;
316
+ vendor: string;
317
+ provider: "moonshot";
318
+ };
319
+ "kimi-k2.5": {
320
+ inputPer1M: number;
321
+ outputPer1M: number;
322
+ cacheReadMultiplier: number;
323
+ vendor: string;
324
+ provider: "moonshot";
325
+ };
326
+ "kimi-k2-0905-preview": {
327
+ inputPer1M: number;
328
+ outputPer1M: number;
329
+ cacheReadMultiplier: number;
330
+ vendor: string;
331
+ provider: "moonshot";
332
+ };
333
+ "kimi-k2-turbo-preview": {
334
+ inputPer1M: number;
335
+ outputPer1M: number;
336
+ cacheReadMultiplier: number;
337
+ vendor: string;
338
+ provider: "moonshot";
339
+ };
340
+ "kimi-k2-thinking": {
341
+ inputPer1M: number;
342
+ outputPer1M: number;
343
+ cacheReadMultiplier: number;
344
+ vendor: string;
345
+ provider: "moonshot";
346
+ };
347
+ "kimi-k2-thinking-turbo": {
348
+ inputPer1M: number;
349
+ outputPer1M: number;
350
+ cacheReadMultiplier: number;
351
+ vendor: string;
352
+ provider: "moonshot";
353
+ };
354
+ "mistral-large-latest": {
355
+ inputPer1M: number;
356
+ outputPer1M: number;
357
+ vendor: string;
358
+ provider: "mistral";
359
+ };
360
+ "mistral-small-creative-latest": {
361
+ inputPer1M: number;
362
+ outputPer1M: number;
363
+ vendor: string;
364
+ provider: "mistral";
365
+ };
366
+ "mistral-small-2501": {
367
+ inputPer1M: number;
368
+ outputPer1M: number;
369
+ vendor: string;
370
+ provider: "mistral";
371
+ };
372
+ "mistral-small-latest": {
373
+ inputPer1M: number;
374
+ outputPer1M: number;
375
+ cacheReadMultiplier: number;
376
+ vendor: string;
377
+ provider: "mistral";
378
+ };
379
+ };
380
+ /**
381
+ * Every canonical catalog model id — derived straight from the pricing
382
+ * map keys (`satisfies` above preserves the literal keys). Downstream
383
+ * curation/config should constrain their ids to this so a typo or a
384
+ * removed model is a build error, not a broken row at runtime.
385
+ */
386
+ type LlmModelId = keyof typeof LLM_PRICING_CATALOG;
387
+ declare const MODEL_ALIASES: {
388
+ "claude-opus-4-6": string;
389
+ "claude-sonnet-4-6": string;
390
+ "claude-4-opus": string;
391
+ "claude-4-sonnet": string;
392
+ "claude-3-5-haiku": string;
393
+ "claude-haiku-4-5-20251001": string;
394
+ "claude-opus-4": string;
395
+ "claude-sonnet-4": string;
396
+ "claude-haiku-3.5": string;
397
+ "gemini-3.1-flash-lite-preview": string;
398
+ "google/gemini-3.1-pro-preview": string;
399
+ "google/gemini-3.5-flash": string;
400
+ "google/gemini-3-flash-preview": string;
401
+ "google/gemini-3.1-flash-lite": string;
402
+ "google/gemini-2.5-flash": string;
403
+ "google/gemini-2.5-flash-lite": string;
404
+ "google/gemini-2.5-pro": string;
405
+ "openai/gpt-4.1": string;
406
+ "openai/gpt-4.1-mini": string;
407
+ "openai/gpt-4.1-nano": string;
408
+ "openai/gpt-5": string;
409
+ "openai/gpt-5.1": string;
410
+ "openai/gpt-5.2": string;
411
+ "openai/gpt-5.4": string;
412
+ "openai/gpt-5.4-mini": string;
413
+ "openai/gpt-5.4-nano": string;
414
+ "openai/gpt-5.5": string;
415
+ "openai/o3": string;
416
+ "openai/o4-mini": string;
417
+ "openai/o3-mini": string;
418
+ "openai/o1": string;
419
+ "openai/o1-mini": string;
420
+ "minimax-m2": string;
421
+ "minimax-m2.1": string;
422
+ "minimax-m2.5": string;
423
+ "minimax-m2.7": string;
424
+ "kimi-k2": string;
425
+ "moonshotai/kimi-k2.5": string;
426
+ "moonshotai/kimi-k2.6": string;
427
+ "mistralai/mistral-large-latest": string;
428
+ "mistralai/mistral-small-latest": string;
429
+ };
430
+ /** Every alias id that resolves to a canonical model — the alias keys. */
431
+ type LlmModelAlias = keyof typeof MODEL_ALIASES;
432
+ /** Any model id the catalog recognises — canonical key or alias. */
433
+ type KnownLlmId = LlmModelId | LlmModelAlias;
434
+ /**
435
+ * Resolves a model id to its pricing entry. Tries direct match → alias →
436
+ * partial-prefix match. Used both for cost computation and BYOK shadow
437
+ * accounting; semantics are load-bearing for migration.
438
+ */
439
+ declare function resolvePricing(modelId: string): LLMPricing | undefined;
440
+ /**
441
+ * Resolves a model id to its canonical catalog key (or the original id if no
442
+ * match). Public surface for consumers that need the canonical id without
443
+ * the pricing payload.
444
+ */
445
+ declare function resolveAlias(modelId: string): string;
446
+ /**
447
+ * Resolve a model id to its DEFAULT provider — the single source of truth for
448
+ * "which SDK reaches this model when no per-model override is set". Reads the
449
+ * resolved catalog entry's `provider` field (direct id → alias → partial
450
+ * prefix, same resolution as `resolvePricing`). Returns undefined for unknown
451
+ * ids so callers can fall back to their own heuristic.
452
+ *
453
+ * This is the abstraction that decouples the provider from the model-id STRING:
454
+ * instead of inferring "claude-* → anthropic" at each call site, the provider
455
+ * is an explicit catalog attribute. A model reachable through more than one
456
+ * provider (e.g. Claude via the direct Anthropic SDK vs. OpenRouter) is held as
457
+ * distinct catalog entries — the bare id (`claude-haiku-4-5`, provider
458
+ * `anthropic`) and the slash route (`anthropic/claude-haiku-4.5`, provider
459
+ * `openrouter`) — each carrying its own `provider`.
460
+ */
461
+ declare function getModelProvider(modelId: string): CatalogProvider | undefined;
462
+ /**
463
+ * The unified registry view of a model: canonical id, default provider, vendor,
464
+ * and pricing — everything the routing + billing layers need from ONE lookup.
465
+ * Returns undefined for unknown ids.
466
+ */
467
+ interface ModelRoute {
468
+ /** Canonical catalog key (post-alias). */
469
+ canonicalId: string;
470
+ /** Default provider — the SDK used when no per-model override is set. */
471
+ provider?: CatalogProvider;
472
+ /** Model author/vendor (permanent; independent of the routing provider). */
473
+ vendor?: string;
474
+ /** Billing pricing entry. */
475
+ pricing: LLMPricing;
476
+ }
477
+ declare function resolveModelRoute(modelId: string): ModelRoute | undefined;
478
+ /**
479
+ * Default fallback: roughly gemini-flash pricing (cheapest). Unknown
480
+ * model ids resolve to this — the formula path then computes credit
481
+ * cost from `inputPer1M`/`outputPer1M`, so unknown models always price
482
+ * at default markup × cheap-model rates, never at zero.
483
+ */
484
+ declare const DEFAULT_PRICING: LLMPricing;
485
+ interface LLMCreditCostResult {
486
+ /**
487
+ * Total **centicredits** to charge — what `useAccountCredits` debits
488
+ * directly (ledger column is cc). Reflects any per-model override or
489
+ * per-app markup; never below `MIN_CREDITS_PER_TURN_CC`.
490
+ *
491
+ * Unit: cc (1 displayed credit = 100 cc). Format for display with
492
+ * `displayCredits(cc) → cr`.
493
+ */
494
+ credits: number;
495
+ /**
496
+ * What the *pure formula* would have charged (provider cost ×
497
+ * text-markup), independent of per-model overrides. Surfaced so
498
+ * `usage_events.calculated_credits` can record the formula-derived
499
+ * value next to the override-applied debit — easy reconciliation
500
+ * against Langfuse traces. Unit: cc.
501
+ */
502
+ calculatedCredits: number;
503
+ /** Breakdown of `credits` (each in cc). */
504
+ inputCredits: number;
505
+ outputCredits: number;
506
+ cacheReadCredits: number;
507
+ cacheWriteCredits: number;
508
+ /** Production cost in USD (true provider cost, with cache multipliers applied). */
509
+ productionCost: number;
510
+ /** Model pricing used */
511
+ pricing: LLMPricing;
512
+ /** Whether fallback pricing was used */
513
+ isFallback: boolean;
514
+ /** Markup actually applied. Same as `pricingRegistry.getMarkup("text", appId)` when no override. */
515
+ markup: number;
516
+ /** True when a per-model `overrideCredit*Per1M` field bypassed the formula. */
517
+ hasOverride: boolean;
518
+ }
519
+ interface LLMUsageBreakdown {
520
+ /**
521
+ * Input tokens that were NOT served from cache. With Anthropic prompt
522
+ * caching, providers often report `inputTokens` already EXCLUDING
523
+ * cached portions — pass the same number you'd pass to the legacy
524
+ * 3-arg signature; cache fields are ADDED on top.
525
+ */
526
+ inputTokens: number;
527
+ outputTokens: number;
528
+ cacheReadInputTokens?: number;
529
+ cacheCreationInputTokens?: number;
530
+ }
531
+ interface CalculateLLMCreditCostOptions {
532
+ /**
533
+ * App invoking the LLM. Routes per-app markup overrides registered
534
+ * via `pricingRegistry.registerApp(appId, ...)`. When omitted, core
535
+ * defaults apply.
536
+ */
537
+ appId?: string;
538
+ /**
539
+ * Direct markup override (escape hatch for tests / one-off
540
+ * reconciliation). When set, bypasses `pricingRegistry` for both
541
+ * formula and `calculatedCredits` math. Takes precedence over
542
+ * `appId`.
543
+ */
544
+ markupOverride?: number;
545
+ }
546
+ declare function calculateLLMCreditCost(modelId: string, inputTokens: number, outputTokens: number): LLMCreditCostResult;
547
+ declare function calculateLLMCreditCost(modelId: string, usage: LLMUsageBreakdown, opts?: CalculateLLMCreditCostOptions): LLMCreditCostResult;
548
+ interface CacheStats {
549
+ /**
550
+ * Cache hit rate as a 0..1 fraction of total input tokens (raw + cache
551
+ * read + cache create). 0 means no cache activity, 1 means everything
552
+ * read from cache, 0 for output-only calls. `null` when there were no
553
+ * input tokens at all.
554
+ */
555
+ cacheHitRate: number | null;
556
+ /**
557
+ * Provider USD we *saved* vs the same input billed at the uncached
558
+ * rate. Cache reads at 0.1× save 0.9× of the input cost; cache writes
559
+ * at 1.25× actually COST 0.25× more than uncached (negative savings).
560
+ * Sum across both. Negative means cache-write overhead exceeded
561
+ * cache-read savings (rare — usually means the prompt prefix was
562
+ * cached on the first turn but never re-used).
563
+ */
564
+ providerCostSavedUsd: number;
565
+ /**
566
+ * Centicredits the user *saved* vs the same input billed at the
567
+ * uncached rate. Same sign convention as `providerCostSavedUsd`.
568
+ * Unit: cc (format with `displayCredits(cc)` for UI).
569
+ */
570
+ creditsSaved: number;
571
+ /**
572
+ * True iff the model carries cache multipliers in its pricing.
573
+ * Useful for explaining "this model doesn't support caching" in UI.
574
+ */
575
+ cacheSupported: boolean;
576
+ }
577
+ /**
578
+ * Turn a credit-cost result into cache-utilisation stats. Pure compute.
579
+ *
580
+ * Use cases:
581
+ * - "Cache saved 87% on this call" in a UI tooltip.
582
+ * - Per-conversation dashboards: "across this conversation, prompt
583
+ * caching saved you $0.42 / 12 credits."
584
+ * - Regression alarms — if cacheHitRate drops below an expected
585
+ * threshold on a known-cacheable workload, something broke in
586
+ * prompt-prefix stability.
587
+ *
588
+ * Returns `cacheSupported: false` for models without cache multipliers
589
+ * (gpt-4o-mini, gemini, mistral) — all fields are zero in that case
590
+ * (no cache activity is possible).
591
+ */
592
+ declare function getCacheStats(modelId: string, usage: LLMUsageBreakdown, opts?: CalculateLLMCreditCostOptions): CacheStats;
593
+
594
+ export { type CacheStats as C, DEFAULT_PRICING as D, type KnownLlmId as K, type LLMCreditCostResult as L, MODEL_ALIASES as M, type CalculateLLMCreditCostOptions as a, type LLMPricing as b, type LLMUsageBreakdown as c, LLM_PRICING_CATALOG as d, type LlmModelAlias as e, type LlmModelId as f, type ModelRoute as g, calculateLLMCreditCost as h, getCacheStats as i, getModelProvider as j, resolveModelRoute as k, resolvePricing as l, resolveAlias as r };