@juspay/neurolink 12.5.0 → 12.5.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/dist/adapters/providerImageAdapter.js +43 -19
  3. package/dist/browser/neurolink.min.js +414 -414
  4. package/dist/cli/commands/setup.d.ts +12 -7
  5. package/dist/cli/commands/setup.js +17 -16
  6. package/dist/cli/proxy-clients/openCode.js +16 -3
  7. package/dist/constants/contextWindows.js +23 -95
  8. package/dist/constants/enums.d.ts +111 -216
  9. package/dist/constants/enums.js +124 -240
  10. package/dist/factories/providerDescriptors.d.ts +2 -4
  11. package/dist/factories/providerDescriptors.js +83 -127
  12. package/dist/models/manifestRegistry.js +53 -4
  13. package/dist/providers/catalog/cerebras.json +75 -0
  14. package/dist/providers/catalog/cloudflare.json +121 -0
  15. package/dist/providers/catalog/fireworks.json +124 -0
  16. package/dist/providers/catalog/groq.json +127 -0
  17. package/dist/providers/catalog/index.generated.d.ts +3 -0
  18. package/dist/providers/catalog/index.generated.js +33 -0
  19. package/dist/providers/catalog/loader.d.ts +6 -0
  20. package/dist/providers/catalog/loader.js +115 -0
  21. package/dist/providers/catalog/mistral.json +244 -0
  22. package/dist/providers/catalog/perplexity.json +103 -0
  23. package/dist/providers/catalog/provider-catalog.schema.json +351 -0
  24. package/dist/providers/catalog/sambanova.json +129 -0
  25. package/dist/providers/catalog/schema.d.ts +123 -0
  26. package/dist/providers/catalog/schema.js +310 -0
  27. package/dist/providers/catalog/together-ai.json +172 -0
  28. package/dist/providers/catalog/xai.json +108 -0
  29. package/dist/providers/openaiCompatCatalog.d.ts +13 -13
  30. package/dist/providers/openaiCompatCatalog.js +15 -326
  31. package/dist/types/index.d.ts +2 -0
  32. package/dist/types/index.js +2 -0
  33. package/dist/types/providerCatalog.d.ts +149 -0
  34. package/dist/types/providerCatalog.generated.d.ts +2 -0
  35. package/dist/types/providerCatalog.generated.js +1 -0
  36. package/dist/types/providerCatalog.js +7 -0
  37. package/dist/types/providers.d.ts +14 -14
  38. package/dist/utils/modelChoices.d.ts +11 -3
  39. package/dist/utils/modelChoices.js +84 -190
  40. package/dist/utils/pricing.js +92 -127
  41. package/dist/utils/providerConfig.d.ts +1 -1
  42. package/dist/utils/providerConfig.js +24 -108
  43. package/package.json +2 -1
  44. package/dist/models/manifests/cerebras.d.ts +0 -9
  45. package/dist/models/manifests/cerebras.js +0 -19
  46. package/dist/models/manifests/sambanova.d.ts +0 -11
  47. package/dist/models/manifests/sambanova.js +0 -42
@@ -2,10 +2,45 @@
2
2
  * Centralized model choices for CLI commands
3
3
  * Derives choices from model enums to ensure consistency
4
4
  */
5
- import { AIProviderName, OpenAIModels, AnthropicModels, GoogleAIModels, BedrockModels, VertexModels, MistralModels, OllamaModels, AzureOpenAIModels, LiteLLMModels, HuggingFaceModels, SageMakerModels, OpenRouterModels, DeepSeekModels, NvidiaNimModels, XaiModels, GroqModels, CerebrasModels, SambanovaModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
5
+ import { AIProviderName, OpenAIModels, AnthropicModels, GoogleAIModels, BedrockModels, VertexModels, OllamaModels, AzureOpenAIModels, LiteLLMModels, HuggingFaceModels, SageMakerModels, OpenRouterModels, DeepSeekModels, NvidiaNimModels, CohereModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
6
+ import { getCatalogJsonEntries } from "../providers/catalog/loader.js";
7
+ /**
8
+ * Looks up the JSON catalog entry for a provider, if it is one of the 9
9
+ * JSON-catalog providers. Used to short-circuit the hand tables below so a
10
+ * catalog provider's models are always sourced from its catalog JSON, never
11
+ * from stale hand-written duplicates.
12
+ */
13
+ function catalogEntryFor(provider) {
14
+ return getCatalogJsonEntries().find((entry) => entry.id === provider);
15
+ }
16
+ /**
17
+ * Derives CLI-prompt entries for a catalog provider. Uses the curated
18
+ * `models.topModels` ordering when the JSON provides one (mapping each id to
19
+ * its own `models.catalog[id].description`); falls back to the full
20
+ * `models.catalog` in file key-order when `topModels` is absent, matching
21
+ * the loader's documented fallback contract.
22
+ */
23
+ function catalogTopModels(entry) {
24
+ if (entry.models.topModels) {
25
+ return entry.models.topModels.map((model) => ({
26
+ model,
27
+ description: entry.models.catalog[model].description,
28
+ }));
29
+ }
30
+ return Object.entries(entry.models.catalog).map(([model, spec]) => ({
31
+ model,
32
+ description: spec.description,
33
+ }));
34
+ }
6
35
  /**
7
36
  * Top models per provider with descriptions for CLI prompts
8
37
  * These are curated lists of the most commonly used/recommended models
38
+ *
39
+ * Covers every provider EXCEPT the 9 JSON-catalog providers (cerebras,
40
+ * cloudflare, fireworks, groq, mistral, perplexity, sambanova, together-ai,
41
+ * xai) — their entries are derived from `models.catalog[*].description` by
42
+ * `catalogTopModels()` and merged in at the accessor-function level below,
43
+ * never hand-duplicated here.
9
44
  */
10
45
  const TOP_MODELS_CONFIG = {
11
46
  [AIProviderName.OPENAI]: [
@@ -125,25 +160,6 @@ const TOP_MODELS_CONFIG = {
125
160
  },
126
161
  { model: AzureOpenAIModels.GPT_3_5_TURBO, description: "Legacy model" },
127
162
  ],
128
- [AIProviderName.MISTRAL]: [
129
- {
130
- model: MistralModels.MISTRAL_LARGE_LATEST,
131
- description: "Recommended - Flagship model",
132
- },
133
- {
134
- model: MistralModels.MISTRAL_SMALL_LATEST,
135
- description: "Cost-effective",
136
- },
137
- {
138
- model: MistralModels.CODESTRAL_LATEST,
139
- description: "Specialized for code",
140
- },
141
- {
142
- model: MistralModels.MAGISTRAL_MEDIUM_LATEST,
143
- description: "Reasoning model",
144
- },
145
- { model: MistralModels.MISTRAL_NEMO, description: "Efficient base model" },
146
- ],
147
163
  [AIProviderName.OLLAMA]: [
148
164
  {
149
165
  model: OllamaModels.LLAMA4_LATEST,
@@ -270,75 +286,6 @@ const TOP_MODELS_CONFIG = {
270
286
  description: "Use whatever model llama-server has loaded",
271
287
  },
272
288
  ],
273
- [AIProviderName.XAI]: [
274
- {
275
- model: XaiModels.GROK_3,
276
- description: "Recommended - Latest flagship Grok",
277
- },
278
- { model: XaiModels.GROK_3_MINI, description: "Faster + cheaper Grok 3" },
279
- {
280
- model: XaiModels.GROK_2_VISION_LATEST,
281
- description: "Multimodal (text + images)",
282
- },
283
- { model: XaiModels.GROK_2_LATEST, description: "Previous flagship" },
284
- { model: XaiModels.GROK_BETA, description: "Pre-release / experimental" },
285
- ],
286
- [AIProviderName.GROQ]: [
287
- {
288
- model: GroqModels.LLAMA_3_3_70B_VERSATILE,
289
- description: "Recommended - Production default; sub-100ms",
290
- },
291
- {
292
- model: GroqModels.LLAMA_3_1_8B_INSTANT,
293
- description: "Lowest latency tier",
294
- },
295
- {
296
- model: GroqModels.LLAMA_3_2_90B_VISION_PREVIEW,
297
- description: "Multimodal (vision)",
298
- },
299
- { model: GroqModels.GEMMA_2_9B_IT, description: "Google Gemma 2 9B" },
300
- {
301
- model: GroqModels.MIXTRAL_8X7B_32768,
302
- description: "Mistral 8x7B MoE, 32K context",
303
- },
304
- ],
305
- [AIProviderName.SAMBANOVA]: [
306
- {
307
- model: SambanovaModels.META_LLAMA_3_3_70B_INSTRUCT,
308
- description: "Recommended - Meta Llama 3.3 70B; production, 128K context",
309
- },
310
- {
311
- model: SambanovaModels.GPT_OSS_120B,
312
- description: "OpenAI GPT-OSS 120B (open-weight)",
313
- },
314
- {
315
- model: SambanovaModels.DEEPSEEK_V3_1,
316
- description: "DeepSeek V3.1 (reasoning)",
317
- },
318
- {
319
- model: SambanovaModels.DEEPSEEK_V3_2,
320
- description: "DeepSeek V3.2 (reasoning; vendor preview, 32K context)",
321
- },
322
- {
323
- model: SambanovaModels.MINIMAX_M2_7,
324
- description: "MiniMax M2.7, 192K context",
325
- },
326
- { model: SambanovaModels.MINIMAX_M3, description: "MiniMax M3 (vision)" },
327
- {
328
- model: SambanovaModels.GEMMA_4_31B_IT,
329
- description: "Google Gemma 4 31B IT (vision; vendor preview)",
330
- },
331
- ],
332
- [AIProviderName.CEREBRAS]: [
333
- {
334
- model: CerebrasModels.GPT_OSS_120B,
335
- description: "Recommended - OpenAI GPT-OSS 120B (open-weight); wafer-scale speed",
336
- },
337
- {
338
- model: CerebrasModels.GEMMA_4_31B,
339
- description: "Google Gemma 4 31B",
340
- },
341
- ],
342
289
  [AIProviderName.COHERE]: [
343
290
  {
344
291
  model: CohereModels.COMMAND_R_PLUS,
@@ -347,74 +294,6 @@ const TOP_MODELS_CONFIG = {
347
294
  { model: CohereModels.COMMAND_R, description: "Smaller RAG-tuned chat" },
348
295
  { model: CohereModels.COMMAND_R7B, description: "Most compact" },
349
296
  ],
350
- [AIProviderName.TOGETHER_AI]: [
351
- {
352
- model: TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO,
353
- description: "Recommended - Llama 3.3 70B Turbo",
354
- },
355
- {
356
- model: TogetherAIModels.LLAMA_3_1_405B_INSTRUCT_TURBO,
357
- description: "Flagship 405B",
358
- },
359
- {
360
- model: TogetherAIModels.QWEN_2_5_72B_INSTRUCT_TURBO,
361
- description: "Qwen 2.5 72B Turbo",
362
- },
363
- {
364
- model: TogetherAIModels.DEEPSEEK_R1,
365
- description: "DeepSeek R1 reasoning",
366
- },
367
- {
368
- model: TogetherAIModels.MIXTRAL_8X22B_INSTRUCT,
369
- description: "Mistral 8x22B MoE",
370
- },
371
- ],
372
- [AIProviderName.FIREWORKS]: [
373
- {
374
- model: FireworksModels.DEEPSEEK_V4_PRO,
375
- description: "Recommended - DeepSeek V4 Pro",
376
- },
377
- { model: FireworksModels.GLM_5P1, description: "GLM 5.1 (Zhipu)" },
378
- { model: FireworksModels.KIMI_K2P6, description: "Kimi K2.6 (Moonshot)" },
379
- { model: FireworksModels.GPT_OSS_120B, description: "GPT-OSS 120B" },
380
- ],
381
- [AIProviderName.PERPLEXITY]: [
382
- {
383
- model: PerplexityModels.SONAR,
384
- description: "Recommended - Sonar with web grounding",
385
- },
386
- { model: PerplexityModels.SONAR_PRO, description: "Better reasoning" },
387
- {
388
- model: PerplexityModels.SONAR_REASONING,
389
- description: "Explicit reasoning traces",
390
- },
391
- {
392
- model: PerplexityModels.SONAR_REASONING_PRO,
393
- description: "Flagship reasoning + web",
394
- },
395
- {
396
- model: PerplexityModels.SONAR_DEEP_RESEARCH,
397
- description: "Long-form research with citations",
398
- },
399
- ],
400
- [AIProviderName.CLOUDFLARE]: [
401
- {
402
- model: CloudflareModels.LLAMA_3_3_70B_FAST,
403
- description: "Recommended - Llama 3.3 70B FP8 fast",
404
- },
405
- {
406
- model: CloudflareModels.LLAMA_3_1_70B_INSTRUCT,
407
- description: "Llama 3.1 70B",
408
- },
409
- {
410
- model: CloudflareModels.LLAMA_3_1_8B_FAST,
411
- description: "Llama 3.1 8B fast",
412
- },
413
- {
414
- model: CloudflareModels.LLAMA_3_2_11B_VISION,
415
- description: "Multimodal (vision)",
416
- },
417
- ],
418
297
  [AIProviderName.REPLICATE]: [
419
298
  {
420
299
  model: "meta/meta-llama-3-70b-instruct",
@@ -517,7 +396,15 @@ const TOP_MODELS_CONFIG = {
517
396
  [AIProviderName.AUTO]: [],
518
397
  };
519
398
  /**
520
- * Default models per provider (first choice/recommended)
399
+ * Default models per provider (first choice/recommended).
400
+ *
401
+ * Covers every provider EXCEPT the 9 JSON-catalog providers — those default
402
+ * models come from `models.default` in the catalog JSON, read directly by
403
+ * `getDefaultModel()` below. (Two of the 9 — cerebras, sambanova — never had
404
+ * a hand entry here at all; `getDefaultModel()` now resolves them too.)
405
+ *
406
+ * AUTO is also excluded — it never had an entry here either (matches
407
+ * pre-existing behavior: `getDefaultModel(AUTO)` returns `undefined`).
521
408
  */
522
409
  export const DEFAULT_MODELS = {
523
410
  [AIProviderName.OPENAI]: OpenAIModels.GPT_4O,
@@ -526,7 +413,6 @@ export const DEFAULT_MODELS = {
526
413
  [AIProviderName.VERTEX]: VertexModels.GEMINI_2_5_FLASH,
527
414
  [AIProviderName.BEDROCK]: BedrockModels.CLAUDE_4_5_SONNET,
528
415
  [AIProviderName.AZURE]: AzureOpenAIModels.GPT_4O,
529
- [AIProviderName.MISTRAL]: MistralModels.MISTRAL_LARGE_LATEST,
530
416
  [AIProviderName.OLLAMA]: OllamaModels.LLAMA4_LATEST,
531
417
  [AIProviderName.LITELLM]: LiteLLMModels.OPENAI_GPT_4O,
532
418
  [AIProviderName.HUGGINGFACE]: HuggingFaceModels.LLAMA_3_3_70B_INSTRUCT,
@@ -539,13 +425,7 @@ export const DEFAULT_MODELS = {
539
425
  // an empty default is the documented signal to use that path.
540
426
  [AIProviderName.LM_STUDIO]: "",
541
427
  [AIProviderName.LLAMACPP]: "",
542
- [AIProviderName.XAI]: XaiModels.GROK_3,
543
- [AIProviderName.GROQ]: GroqModels.LLAMA_3_3_70B_VERSATILE,
544
428
  [AIProviderName.COHERE]: CohereModels.COMMAND_R_PLUS,
545
- [AIProviderName.TOGETHER_AI]: TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO,
546
- [AIProviderName.FIREWORKS]: FireworksModels.DEEPSEEK_V4_PRO,
547
- [AIProviderName.PERPLEXITY]: PerplexityModels.SONAR,
548
- [AIProviderName.CLOUDFLARE]: CloudflareModels.LLAMA_3_3_70B_FAST,
549
429
  [AIProviderName.REPLICATE]: "meta/meta-llama-3-70b-instruct",
550
430
  [AIProviderName.VOYAGE]: VoyageModels.VOYAGE_3_5,
551
431
  [AIProviderName.JINA]: JinaModels.JINA_EMBEDDINGS_V3,
@@ -554,7 +434,11 @@ export const DEFAULT_MODELS = {
554
434
  [AIProviderName.RECRAFT]: RecraftModels.RECRAFT_V3,
555
435
  };
556
436
  /**
557
- * Model enum mappings for getAllModels
437
+ * Model enum mappings for getAllModels.
438
+ *
439
+ * Covers every provider EXCEPT the 9 JSON-catalog providers — those model
440
+ * lists come from `Object.keys(models.catalog)` in the catalog JSON, read
441
+ * directly by `getAllModels()` below.
558
442
  */
559
443
  const MODEL_ENUMS = {
560
444
  [AIProviderName.OPENAI]: OpenAIModels,
@@ -563,7 +447,6 @@ const MODEL_ENUMS = {
563
447
  [AIProviderName.VERTEX]: VertexModels,
564
448
  [AIProviderName.BEDROCK]: BedrockModels,
565
449
  [AIProviderName.AZURE]: AzureOpenAIModels,
566
- [AIProviderName.MISTRAL]: MistralModels,
567
450
  [AIProviderName.OLLAMA]: OllamaModels,
568
451
  [AIProviderName.LITELLM]: LiteLLMModels,
569
452
  [AIProviderName.HUGGINGFACE]: HuggingFaceModels,
@@ -574,15 +457,7 @@ const MODEL_ENUMS = {
574
457
  [AIProviderName.NVIDIA_NIM]: NvidiaNimModels,
575
458
  [AIProviderName.LM_STUDIO]: null,
576
459
  [AIProviderName.LLAMACPP]: null,
577
- [AIProviderName.XAI]: XaiModels,
578
- [AIProviderName.GROQ]: GroqModels,
579
- [AIProviderName.CEREBRAS]: CerebrasModels,
580
- [AIProviderName.SAMBANOVA]: SambanovaModels,
581
460
  [AIProviderName.COHERE]: CohereModels,
582
- [AIProviderName.TOGETHER_AI]: TogetherAIModels,
583
- [AIProviderName.FIREWORKS]: FireworksModels,
584
- [AIProviderName.PERPLEXITY]: PerplexityModels,
585
- [AIProviderName.CLOUDFLARE]: CloudflareModels,
586
461
  [AIProviderName.REPLICATE]: ReplicateModels,
587
462
  [AIProviderName.VOYAGE]: VoyageModels,
588
463
  [AIProviderName.JINA]: JinaModels,
@@ -600,7 +475,10 @@ const MODEL_ENUMS = {
600
475
  * @returns Array of ModelChoice objects for CLI prompts
601
476
  */
602
477
  export function getTopModelChoices(provider, limit = 5) {
603
- const config = TOP_MODELS_CONFIG[provider];
478
+ const catalogEntry = catalogEntryFor(provider);
479
+ const config = catalogEntry
480
+ ? catalogTopModels(catalogEntry)
481
+ : TOP_MODELS_CONFIG[provider];
604
482
  if (!config || config.length === 0) {
605
483
  return [];
606
484
  }
@@ -632,6 +510,10 @@ export function getTopModelChoices(provider, limit = 5) {
632
510
  * @returns Array of model identifier strings
633
511
  */
634
512
  export function getAllModels(provider) {
513
+ const catalogEntry = catalogEntryFor(provider);
514
+ if (catalogEntry) {
515
+ return Object.keys(catalogEntry.models.catalog);
516
+ }
635
517
  const modelEnum = MODEL_ENUMS[provider];
636
518
  if (!modelEnum) {
637
519
  return [];
@@ -662,6 +544,10 @@ export function getAllProviderChoices() {
662
544
  * @returns Default model string for the provider
663
545
  */
664
546
  export function getDefaultModel(provider) {
547
+ const catalogEntry = catalogEntryFor(provider);
548
+ if (catalogEntry) {
549
+ return catalogEntry.models.default;
550
+ }
665
551
  return DEFAULT_MODELS[provider];
666
552
  }
667
553
  /**
@@ -714,23 +600,31 @@ export function getModelChoicesWithDefault(provider, currentModel, limit = 5) {
714
600
  */
715
601
  export function getPopularModelsAcrossProviders() {
716
602
  const popularModels = [];
603
+ // Take top 2 from each provider, ignoring blank auto-discovery sentinels.
604
+ // (Auto-discovery is surfaced separately by `getTopModelChoices` for
605
+ // LM Studio / llama.cpp; we don't want it to appear in the cross-
606
+ // provider popular-models list as an empty value.)
607
+ const pushTop2 = (provider, config) => {
608
+ config
609
+ .filter((item) => item.model.length > 0)
610
+ .slice(0, 2)
611
+ .forEach((item) => {
612
+ popularModels.push({
613
+ provider,
614
+ model: item.model,
615
+ description: item.description,
616
+ });
617
+ });
618
+ };
717
619
  for (const [provider, config] of Object.entries(TOP_MODELS_CONFIG)) {
718
620
  if (config && config.length > 0) {
719
- // Take top 2 from each provider, ignoring blank auto-discovery sentinels.
720
- // (Auto-discovery is surfaced separately by `getTopModelChoices` for
721
- // LM Studio / llama.cpp; we don't want it to appear in the cross-
722
- // provider popular-models list as an empty value.)
723
- config
724
- .filter((item) => item.model.length > 0)
725
- .slice(0, 2)
726
- .forEach((item) => {
727
- popularModels.push({
728
- provider: provider,
729
- model: item.model,
730
- description: item.description,
731
- });
732
- });
621
+ pushTop2(provider, config);
733
622
  }
734
623
  }
624
+ // JSON-catalog providers are excluded from TOP_MODELS_CONFIG above; merge
625
+ // their models in here, derived the same way getTopModelChoices() does.
626
+ for (const entry of getCatalogJsonEntries()) {
627
+ pushTop2(entry.id, catalogTopModels(entry));
628
+ }
735
629
  return popularModels;
736
630
  }
@@ -1,4 +1,69 @@
1
1
  import { getManifestForProvider, resolveManifestEntryExact, } from "../models/manifestRegistry.js";
2
+ import { getCatalogJsonEntries } from "../providers/catalog/loader.js";
3
+ /**
4
+ * Per-model pricing for the JSON-catalog providers, derived from
5
+ * models.catalog[*].pricingPerMTok (dollars-per-million → dollars-per-token,
6
+ * matching this file's unit convention). `_default` is the rate of the
7
+ * provider's own models.default model — mirroring what every hand-written
8
+ * catalog-provider block already did pre-migration (e.g. xai's `_default`
9
+ * was always grok-3's rate, xai's default model).
10
+ *
11
+ * `pricingPerMTok.cachedInput`, where present, maps to this file's
12
+ * `cacheRead` field — same semantics (price for a cached-read hit), just a
13
+ * different field name in the two shapes.
14
+ *
15
+ * A provider contributes no block here when its catalog carries zero
16
+ * `pricingPerMTok` data anywhere — fireworks (a fully refreshed model
17
+ * roster with no sourced pricing yet) and cloudflare (bills per "neuron",
18
+ * not per token — there's no USD-per-token figure to source). Both stay
19
+ * entirely hand-written below with their pre-existing symbolic/estimated
20
+ * rates, since the JSON has nothing to derive. Mistral's catalog likewise
21
+ * has no pricingPerMTok data, and its hand block below uses coarse model
22
+ * names ("mistral-large", "codestral", …) that don't match the JSON's real
23
+ * ids ("mistral-large-latest", "codestral-latest", …) — it stays
24
+ * hand-written too.
25
+ */
26
+ const CATALOG_PRICING = Object.fromEntries(getCatalogJsonEntries().flatMap((entry) => {
27
+ const priced = Object.fromEntries(Object.entries(entry.models.catalog).flatMap(([modelId, spec]) => spec.pricingPerMTok
28
+ ? [
29
+ [
30
+ modelId,
31
+ {
32
+ input: spec.pricingPerMTok.input / 1_000_000,
33
+ output: spec.pricingPerMTok.output / 1_000_000,
34
+ ...(spec.pricingPerMTok.cachedInput !== undefined
35
+ ? { cacheRead: spec.pricingPerMTok.cachedInput / 1_000_000 }
36
+ : {}),
37
+ },
38
+ ],
39
+ ]
40
+ : []));
41
+ if (Object.keys(priced).length === 0) {
42
+ return [];
43
+ }
44
+ const defaultRate = entry.models.catalog[entry.models.default]?.pricingPerMTok;
45
+ return [
46
+ [
47
+ entry.id,
48
+ {
49
+ ...(defaultRate
50
+ ? {
51
+ _default: {
52
+ input: defaultRate.input / 1_000_000,
53
+ output: defaultRate.output / 1_000_000,
54
+ // Without this, a request falling back to `_default`
55
+ // bills cached tokens at the full input rate.
56
+ ...(defaultRate.cachedInput !== undefined
57
+ ? { cacheRead: defaultRate.cachedInput / 1_000_000 }
58
+ : {}),
59
+ },
60
+ }
61
+ : {}),
62
+ ...priced,
63
+ },
64
+ ],
65
+ ];
66
+ }));
2
67
  /**
3
68
  * Per-token pricing data (USD per token). Updated Feb 2026.
4
69
  * Sources:
@@ -483,65 +548,9 @@ const PRICING = {
483
548
  llamacpp: {
484
549
  _default: { input: 0, output: 0 },
485
550
  },
486
- xai: {
487
- _default: { input: 3.0 / 1_000_000, output: 15.0 / 1_000_000 },
488
- "grok-3": { input: 3.0 / 1_000_000, output: 15.0 / 1_000_000 },
489
- "grok-3-mini": { input: 0.3 / 1_000_000, output: 0.5 / 1_000_000 },
490
- "grok-2-latest": { input: 2.0 / 1_000_000, output: 10.0 / 1_000_000 },
491
- "grok-2-vision-latest": {
492
- input: 2.0 / 1_000_000,
493
- output: 10.0 / 1_000_000,
494
- },
495
- "grok-beta": { input: 5.0 / 1_000_000, output: 15.0 / 1_000_000 },
496
- },
497
- groq: {
498
- _default: { input: 0.59 / 1_000_000, output: 0.79 / 1_000_000 },
499
- "llama-3.3-70b-versatile": {
500
- input: 0.59 / 1_000_000,
501
- output: 0.79 / 1_000_000,
502
- },
503
- "llama-3.1-8b-instant": {
504
- input: 0.05 / 1_000_000,
505
- output: 0.08 / 1_000_000,
506
- },
507
- "llama-3.2-90b-vision-preview": {
508
- input: 0.9 / 1_000_000,
509
- output: 0.9 / 1_000_000,
510
- },
511
- "llama-3.2-11b-vision-preview": {
512
- input: 0.18 / 1_000_000,
513
- output: 0.18 / 1_000_000,
514
- },
515
- "gemma2-9b-it": { input: 0.2 / 1_000_000, output: 0.2 / 1_000_000 },
516
- "mixtral-8x7b-32768": {
517
- input: 0.24 / 1_000_000,
518
- output: 0.24 / 1_000_000,
519
- },
520
- },
521
- // inference-docs.cerebras.ai model pages, checked 2026-08-27. The
522
- // gemma-4-31b page's prose and structured data disagree ($2.15/$2.70 vs
523
- // $0.99/$1.49); the structured data feeds the vendor's rendered pricing
524
- // card, so it's used here.
525
- cerebras: {
526
- _default: { input: 0.35 / 1_000_000, output: 0.75 / 1_000_000 },
527
- "gpt-oss-120b": { input: 0.35 / 1_000_000, output: 0.75 / 1_000_000 },
528
- "gemma-4-31b": { input: 0.99 / 1_000_000, output: 1.49 / 1_000_000 },
529
- },
530
- // cloud.sambanova.ai/plans/pricing, checked 2026-08-27. MiniMax-M2.7
531
- // also has a $0.06/M cached-input rate the flat model here can't express.
532
- sambanova: {
533
- _default: { input: 0.6 / 1_000_000, output: 1.2 / 1_000_000 },
534
- "Meta-Llama-3.3-70B-Instruct": {
535
- input: 0.6 / 1_000_000,
536
- output: 1.2 / 1_000_000,
537
- },
538
- "gpt-oss-120b": { input: 0.22 / 1_000_000, output: 0.59 / 1_000_000 },
539
- "DeepSeek-V3.1": { input: 3.0 / 1_000_000, output: 4.5 / 1_000_000 },
540
- "DeepSeek-V3.2": { input: 3.0 / 1_000_000, output: 4.5 / 1_000_000 },
541
- "MiniMax-M2.7": { input: 0.6 / 1_000_000, output: 2.4 / 1_000_000 },
542
- "MiniMax-M3": { input: 0.6 / 1_000_000, output: 2.4 / 1_000_000 },
543
- "gemma-4-31B-it": { input: 0.38 / 1_000_000, output: 1.15 / 1_000_000 },
544
- },
551
+ // xai, groq, cerebras, sambanova — derived from the JSON catalog, see
552
+ // CATALOG_PRICING above.
553
+ ...CATALOG_PRICING,
545
554
  cohere: {
546
555
  _default: { input: 2.5 / 1_000_000, output: 10.0 / 1_000_000 },
547
556
  "command-r-plus": { input: 2.5 / 1_000_000, output: 10.0 / 1_000_000 },
@@ -551,45 +560,7 @@ const PRICING = {
551
560
  output: 0.15 / 1_000_000,
552
561
  },
553
562
  },
554
- "together-ai": {
555
- _default: { input: 0.88 / 1_000_000, output: 0.88 / 1_000_000 },
556
- "meta-llama/Llama-3.3-70B-Instruct-Turbo": {
557
- input: 0.88 / 1_000_000,
558
- output: 0.88 / 1_000_000,
559
- },
560
- "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo": {
561
- input: 3.5 / 1_000_000,
562
- output: 3.5 / 1_000_000,
563
- },
564
- "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo": {
565
- input: 0.88 / 1_000_000,
566
- output: 0.88 / 1_000_000,
567
- },
568
- "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo": {
569
- input: 0.18 / 1_000_000,
570
- output: 0.18 / 1_000_000,
571
- },
572
- "mistralai/Mixtral-8x22B-Instruct-v0.1": {
573
- input: 1.2 / 1_000_000,
574
- output: 1.2 / 1_000_000,
575
- },
576
- "mistralai/Mixtral-8x7B-Instruct-v0.1": {
577
- input: 0.6 / 1_000_000,
578
- output: 0.6 / 1_000_000,
579
- },
580
- "Qwen/Qwen2.5-72B-Instruct-Turbo": {
581
- input: 1.2 / 1_000_000,
582
- output: 1.2 / 1_000_000,
583
- },
584
- "deepseek-ai/DeepSeek-R1": {
585
- input: 7.0 / 1_000_000,
586
- output: 7.0 / 1_000_000,
587
- },
588
- "deepseek-ai/DeepSeek-V3": {
589
- input: 1.25 / 1_000_000,
590
- output: 1.25 / 1_000_000,
591
- },
592
- },
563
+ // together-ai — derived from the JSON catalog, see CATALOG_PRICING above.
593
564
  fireworks: {
594
565
  _default: { input: 0.9 / 1_000_000, output: 0.9 / 1_000_000 },
595
566
  "accounts/fireworks/models/llama-v3p1-70b-instruct": {
@@ -625,20 +596,7 @@ const PRICING = {
625
596
  output: 3.0 / 1_000_000,
626
597
  },
627
598
  },
628
- perplexity: {
629
- _default: { input: 1.0 / 1_000_000, output: 1.0 / 1_000_000 },
630
- sonar: { input: 1.0 / 1_000_000, output: 1.0 / 1_000_000 },
631
- "sonar-pro": { input: 3.0 / 1_000_000, output: 15.0 / 1_000_000 },
632
- "sonar-reasoning": { input: 1.0 / 1_000_000, output: 5.0 / 1_000_000 },
633
- "sonar-reasoning-pro": {
634
- input: 2.0 / 1_000_000,
635
- output: 8.0 / 1_000_000,
636
- },
637
- "sonar-deep-research": {
638
- input: 2.0 / 1_000_000,
639
- output: 8.0 / 1_000_000,
640
- },
641
- },
599
+ // perplexity — derived from the JSON catalog, see CATALOG_PRICING above.
642
600
  cloudflare: {
643
601
  // Cloudflare bills per "neuron"; symbolic per-token rate so cost
644
602
  // attribution dashboards have non-zero values.
@@ -679,6 +637,20 @@ const PRICING = {
679
637
  _default: { input: 0, output: 0.04 / 1_000 },
680
638
  },
681
639
  };
640
+ /**
641
+ * Derives the catalog-provider rows of PROVIDER_ALIASES from each entry's
642
+ * own `id` and `aliases` — the same stripped-lowercase key format the hand
643
+ * rows below use ("together-ai" -> "togetherai", "workers-ai" -> "workersai").
644
+ */
645
+ function buildCatalogProviderAliases() {
646
+ return Object.fromEntries(getCatalogJsonEntries().flatMap((entry) => {
647
+ const stripped = (s) => s.toLowerCase().replace(/[^a-z]/g, "");
648
+ return [
649
+ [stripped(entry.id), entry.id],
650
+ ...entry.aliases.map((alias) => [stripped(alias), entry.id]),
651
+ ];
652
+ }));
653
+ }
682
654
  /**
683
655
  * Map of normalized provider aliases to canonical PRICING keys.
684
656
  * After stripping non-alpha characters, e.g. "google-ai" becomes "googleai".
@@ -691,8 +663,6 @@ const PROVIDER_ALIASES = {
691
663
  openai: "openai",
692
664
  vertex: "vertex",
693
665
  google: "google",
694
- mistral: "mistral",
695
- mistralai: "mistral",
696
666
  azure: "openai",
697
667
  azureopenai: "openai",
698
668
  bedrock: "anthropic",
@@ -706,20 +676,7 @@ const PROVIDER_ALIASES = {
706
676
  nvidia: "nvidia-nim",
707
677
  lmstudio: "lm-studio",
708
678
  llamacpp: "llamacpp",
709
- xai: "xai",
710
- grok: "xai",
711
- groq: "groq",
712
- cerebras: "cerebras",
713
- sambanova: "sambanova",
714
679
  cohere: "cohere",
715
- togetherai: "together-ai",
716
- together: "together-ai",
717
- fireworks: "fireworks",
718
- perplexity: "perplexity",
719
- pplx: "perplexity",
720
- cloudflare: "cloudflare",
721
- workersai: "cloudflare",
722
- cfai: "cloudflare",
723
680
  replicate: "replicate",
724
681
  voyage: "voyage",
725
682
  voyageai: "voyage",
@@ -730,6 +687,14 @@ const PROVIDER_ALIASES = {
730
687
  sd: "stability",
731
688
  ideogram: "ideogram",
732
689
  recraft: "recraft",
690
+ // 9 JSON-catalog providers (cerebras, cloudflare, fireworks, groq,
691
+ // mistral, perplexity, sambanova, together-ai, xai), derived from each
692
+ // entry's id/aliases above.
693
+ ...buildCatalogProviderAliases(),
694
+ // Not in mistral.json's `aliases` array (only "grok", "together",
695
+ // "pplx", "workers-ai"/"cf-ai" are real catalog aliases) — a pre-existing
696
+ // lenient alias kept explicitly since it can't be derived from the catalog.
697
+ mistralai: "mistral",
733
698
  };
734
699
  /**
735
700
  * Look up per-token rates for a provider/model combination.
@@ -136,7 +136,7 @@ export declare function createNvidiaNimConfig(): ProviderConfigOptions;
136
136
  */
137
137
  export declare function createXaiConfig(): ProviderConfigOptions;
138
138
  /**
139
- * Creates Cerebras provider configuration.
139
+ * Creates SambaNova provider configuration.
140
140
  */
141
141
  export declare function createSambanovaConfig(): ProviderConfigOptions;
142
142
  export declare function createCerebrasConfig(): ProviderConfigOptions;