@shop-os/modelkit 0.1.10 → 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.
package/dist/index.cjs CHANGED
@@ -31,8 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.ts
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
+ ADAPTER_IDS: () => ADAPTER_IDS,
34
35
  ADAPTER_KEYS: () => ADAPTER_KEYS,
35
36
  Catalog: () => Catalog,
37
+ CatalogModelSchema: () => CatalogModelSchema,
38
+ CatalogSchema: () => CatalogSchema,
36
39
  DEFAULT_ADAPTERS: () => DEFAULT_ADAPTERS,
37
40
  JsonObjectSchema: () => JsonObjectSchema,
38
41
  JsonValueSchema: () => JsonValueSchema,
@@ -48,6 +51,7 @@ __export(index_exports, {
48
51
  describeThrown: () => describeThrown,
49
52
  experimental_generateImage: () => generateImage,
50
53
  falAdapter: () => falAdapter,
54
+ fileCatalogCache: () => fileCatalogCache,
51
55
  generateAudio: () => generateAudio,
52
56
  generateImage: () => generateImage,
53
57
  generateObject: () => generateObject,
@@ -59,15 +63,18 @@ __export(index_exports, {
59
63
  isModelKitError: () => isModelKitError,
60
64
  keysFromEnv: () => keysFromEnv,
61
65
  languageModel: () => languageModel,
66
+ liveCatalog: () => liveCatalog,
62
67
  mergeTextProviderOptions: () => mergeTextProviderOptions,
63
68
  nearestAspectRatio: () => nearestAspectRatio,
64
69
  openaiImageAdapter: () => openaiImageAdapter,
65
70
  passthroughTextModel: () => passthroughTextModel,
66
71
  pollUntil: () => pollUntil,
67
72
  prepareMediaPart: () => prepareMediaPart,
73
+ primeCatalog: () => primeCatalog,
68
74
  prodiaAdapter: () => prodiaAdapter,
69
75
  readErrorBody: () => readErrorBody,
70
76
  replicateAdapter: () => replicateAdapter,
77
+ resetLiveCatalog: () => resetLiveCatalog,
71
78
  resolveAudioOptions: () => resolveAudioOptions,
72
79
  resolveImageOptions: () => resolveImageOptions,
73
80
  resolveKeys: () => resolveKeys,
@@ -179,11 +186,18 @@ var Catalog = class _Catalog {
179
186
  ...rows
180
187
  ]);
181
188
  }
189
+ /** Atomically swap every row. Builds the maps first so a bad batch throws before anything changes. */
190
+ replace(rows) {
191
+ const next = new _Catalog(rows);
192
+ this.byId.clear();
193
+ this.byAlias.clear();
194
+ for (const [id, model] of next.byId) this.byId.set(id, model);
195
+ for (const [alias, id] of next.byAlias) this.byAlias.set(alias, id);
196
+ }
182
197
  };
183
198
 
184
199
  // src/catalog/image.ts
185
- var IMAGE_USAGE = { unit: "images", modality: "IMAGE" };
186
- var IMAGE_GENERATE_EDIT = { imageGenerate: true, imageEdit: true };
200
+ var IMAGE_USAGE = { unit: "images" };
187
201
  var GEMINI_RATIOS = [
188
202
  "1:1",
189
203
  "2:3",
@@ -215,8 +229,7 @@ function geminiImage(id, label, aliases, sizes, display, exposure) {
215
229
  defaults: { size: "1K", aspectRatio: "1:1" },
216
230
  usage: { ...IMAGE_USAGE, slug: "gemini" },
217
231
  pricingKind: "image_size",
218
- display,
219
- capabilities: { ...IMAGE_GENERATE_EDIT }
232
+ display
220
233
  };
221
234
  return model;
222
235
  }
@@ -303,8 +316,7 @@ var IMAGE_MODELS = [
303
316
  provider: "openai",
304
317
  description: "The most capable model for image editing and complex creative instructions. Excels at text rendering, visual consistency, design generation, and iterative refinement.",
305
318
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/1204b494-8962-4f7f-af5e-699a8bdc98e3_compressed.png"
306
- },
307
- capabilities: { ...IMAGE_GENERATE_EDIT }
319
+ }
308
320
  },
309
321
  {
310
322
  // Same Images API surface as gpt-image-2 plus the "xhigh" and "max" quality tiers.
@@ -338,8 +350,7 @@ var IMAGE_MODELS = [
338
350
  display: {
339
351
  provider: "openai",
340
352
  description: "OpenAI's most capable GPT Image 2.5 tier, built for editing precision; takes text and image input and outputs images in low, medium, high, xhigh, or max quality."
341
- },
342
- capabilities: { ...IMAGE_GENERATE_EDIT }
353
+ }
343
354
  },
344
355
  {
345
356
  // Same Images API surface as gpt-image-2 plus the "xhigh" and "max" quality tiers.
@@ -373,8 +384,7 @@ var IMAGE_MODELS = [
373
384
  display: {
374
385
  provider: "openai",
375
386
  description: "OpenAI's fastest GPT Image 2.5 tier for high-quality everyday image generation and editing; takes text and image input and outputs images."
376
- },
377
- capabilities: { ...IMAGE_GENERATE_EDIT }
387
+ }
378
388
  },
379
389
  {
380
390
  // Cowork allows 7 ratios; trigger-workflows allows 9 (adds 3:2, 9:21, drops 4:5/5:4).
@@ -412,8 +422,7 @@ var IMAGE_MODELS = [
412
422
  provider: "meta",
413
423
  description: "Meta's image model with built-in world knowledge and strong prompt adherence. Great for concept-rich scenes, realistic compositions, and reference-guided edits.",
414
424
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/characters/1787909065794-k9a7zz.png"
415
- },
416
- capabilities: { ...IMAGE_GENERATE_EDIT }
425
+ }
417
426
  },
418
427
  {
419
428
  id: "seedream-5-0-pro",
@@ -439,8 +448,7 @@ var IMAGE_MODELS = [
439
448
  provider: "bytedance",
440
449
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png",
441
450
  description: "ByteDance Seedream 5.0 Pro text-to-image and multi-reference image-to-image (up to 10 inputs) with region editing; outputs 1K, 1.5K, or 2K."
442
- },
443
- capabilities: { ...IMAGE_GENERATE_EDIT }
451
+ }
444
452
  },
445
453
  {
446
454
  id: "seedream-4.5",
@@ -477,8 +485,7 @@ var IMAGE_MODELS = [
477
485
  display: {
478
486
  provider: "bytedance",
479
487
  description: "ByteDance Seedream 4.5 text-to-image and image-to-image with up to 14 reference images and batch image-set generation; outputs 2K or 4K."
480
- },
481
- capabilities: { ...IMAGE_GENERATE_EDIT }
488
+ }
482
489
  },
483
490
  {
484
491
  id: "flux-2-pro",
@@ -500,9 +507,9 @@ var IMAGE_MODELS = [
500
507
  pricingKind: "image_size",
501
508
  display: {
502
509
  provider: "black-forest-labs",
510
+ logo: "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/flux.png",
503
511
  description: "Black Forest Labs FLUX.2 [pro] text-to-image and multi-reference editing model served via Prodia; takes a prompt and up to 8 input images and outputs up to 4096x4096."
504
- },
505
- capabilities: { ...IMAGE_GENERATE_EDIT }
512
+ }
506
513
  },
507
514
  {
508
515
  // Prodia's gemini-3-pro jobs take aspect_ratio + resolution (1K/2K/4K), not
@@ -528,8 +535,7 @@ var IMAGE_MODELS = [
528
535
  display: {
529
536
  provider: "google",
530
537
  description: "Google Gemini 3 Pro image generation and editing served via Prodia; takes a prompt plus up to 3 reference images and outputs 1K, 2K, or 4K."
531
- },
532
- capabilities: { ...IMAGE_GENERATE_EDIT }
538
+ }
533
539
  },
534
540
  {
535
541
  // Nano Banana (img2img.v2) is flat-rate with aspect_ratio only; 3:2, 4:5,
@@ -554,8 +560,7 @@ var IMAGE_MODELS = [
554
560
  display: {
555
561
  provider: "google",
556
562
  description: "Google Nano Banana image generation and editing served via Prodia; takes a prompt plus 1-3 input images and matches the first input's aspect ratio in roughly 8 seconds."
557
- },
558
- capabilities: { ...IMAGE_GENERATE_EDIT }
563
+ }
559
564
  },
560
565
  {
561
566
  // WAN 2.7 takes `images` (up to 9) and a `size` enum whose exact values
@@ -576,13 +581,12 @@ var IMAGE_MODELS = [
576
581
  supports: []
577
582
  },
578
583
  defaults: { size: "1K", aspectRatio: "1:1" },
579
- usage: { unit: "compute_seconds", modality: "IMAGE" },
584
+ usage: { unit: "compute_seconds" },
580
585
  pricingKind: "image_size",
581
586
  display: {
582
587
  provider: "alibaba",
583
588
  description: "Alibaba Wan 2.7 Image Pro text-to-image and image-editing model; takes a prompt plus up to 9 reference images and generates up to 4K (4096x4096)."
584
- },
585
- capabilities: { ...IMAGE_GENERATE_EDIT }
589
+ }
586
590
  },
587
591
  {
588
592
  // Qwen Image 2 Pro has aspect_ratio but no size input; resolution follows
@@ -604,13 +608,12 @@ var IMAGE_MODELS = [
604
608
  supports: []
605
609
  },
606
610
  defaults: { aspectRatio: "1:1" },
607
- usage: { unit: "compute_seconds", modality: "IMAGE" },
611
+ usage: { unit: "compute_seconds" },
608
612
  pricingKind: "image_size",
609
613
  display: {
610
614
  provider: "alibaba",
611
615
  description: "Alibaba Qwen Image 2 Pro unified text-to-image and editing model; takes a prompt plus an optional single reference image and generates native 2K output."
612
- },
613
- capabilities: { ...IMAGE_GENERATE_EDIT }
616
+ }
614
617
  },
615
618
  {
616
619
  // Qwen Image Edit Plus takes aspect_ratio (or match_input_image) and
@@ -632,13 +635,12 @@ var IMAGE_MODELS = [
632
635
  supports: ["outputFormat"]
633
636
  },
634
637
  defaults: { outputFormat: "png" },
635
- usage: { unit: "compute_seconds", modality: "IMAGE" },
638
+ usage: { unit: "compute_seconds" },
636
639
  pricingKind: "image_size",
637
640
  display: {
638
641
  provider: "alibaba",
639
642
  description: "Alibaba Qwen Image Edit Plus with Lightning and a skin-retouching LoRA; takes one or more reference images plus an edit prompt and outputs webp, jpg, or png."
640
- },
641
- capabilities: { ...IMAGE_GENERATE_EDIT }
643
+ }
642
644
  }
643
645
  ];
644
646
 
@@ -660,7 +662,7 @@ var OTHER_MODELS = [
660
662
  supports: []
661
663
  },
662
664
  defaults: {},
663
- usage: { unit: "images", modality: "AUDIO" },
665
+ usage: { unit: "images" },
664
666
  pricingKind: "flat",
665
667
  display: {
666
668
  provider: "google",
@@ -683,7 +685,7 @@ var OTHER_MODELS = [
683
685
  supports: []
684
686
  },
685
687
  defaults: {},
686
- usage: { unit: "images", modality: "AUDIO" },
688
+ usage: { unit: "images" },
687
689
  pricingKind: "flat",
688
690
  display: {
689
691
  provider: "google",
@@ -706,7 +708,7 @@ var OTHER_MODELS = [
706
708
  supports: ["seed", "negativePrompt"]
707
709
  },
708
710
  defaults: {},
709
- usage: { unit: "compute_seconds", modality: "AUDIO" },
711
+ usage: { unit: "compute_seconds" },
710
712
  pricingKind: "flat",
711
713
  display: {
712
714
  provider: "google",
@@ -729,7 +731,7 @@ var OTHER_MODELS = [
729
731
  supports: ["seed", "negativePrompt"]
730
732
  },
731
733
  defaults: { durationSeconds: 8 },
732
- usage: { unit: "compute_seconds", modality: "AUDIO" },
734
+ usage: { unit: "compute_seconds" },
733
735
  pricingKind: "flat",
734
736
  display: {
735
737
  provider: "mmaudio",
@@ -752,7 +754,7 @@ var OTHER_MODELS = [
752
754
  },
753
755
  defaults: { durationSeconds: 15, instrumental: true },
754
756
  // Replicate's run() does not report predict_time; billed by generated length.
755
- usage: { unit: "seconds", modality: "AUDIO" },
757
+ usage: { unit: "seconds" },
756
758
  pricingKind: "flat",
757
759
  display: {
758
760
  provider: "elevenlabs",
@@ -775,13 +777,13 @@ var OTHER_MODELS = [
775
777
  supports: ["scaleFactor", "outputFormat", "upscale"]
776
778
  },
777
779
  defaults: { scaleFactor: 2, outputFormat: "png" },
778
- usage: { unit: "compute_seconds", modality: "IMAGE" },
780
+ usage: { unit: "compute_seconds" },
779
781
  pricingKind: "flat",
780
782
  display: {
781
783
  provider: "topaz",
784
+ logo: "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/topazlabs.png",
782
785
  description: "Topaz Labs AI image upscaling on Replicate; takes one input image and upscales up to 6x with selectable enhancement models and optional face enhancement."
783
- },
784
- capabilities: { imageEdit: true }
786
+ }
785
787
  },
786
788
  {
787
789
  id: "bg-remove",
@@ -798,19 +800,30 @@ var OTHER_MODELS = [
798
800
  supports: []
799
801
  },
800
802
  defaults: {},
801
- usage: { unit: "images", modality: "IMAGE" },
803
+ usage: { unit: "images" },
802
804
  pricingKind: "flat",
803
805
  display: {
804
806
  provider: "prodia",
805
807
  description: "Prodia background removal; takes one input image and returns a PNG cut-out of the subject plus an optional black-and-white mask."
806
- },
807
- capabilities: { imageEdit: true }
808
+ }
808
809
  }
809
810
  ];
810
811
 
811
812
  // src/catalog/text.ts
812
- var TEXT_USAGE = { unit: "tokens", modality: "TEXT" };
813
+ var TEXT_USAGE = { unit: "tokens" };
814
+ var CDN = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image";
815
+ var PROVIDER_LOGOS = {
816
+ anthropic: `${CDN}/25fad392-188c-4829-a3d0-c4fa02d1c8cd.png`,
817
+ openai: `${CDN}/1204b494-8962-4f7f-af5e-699a8bdc98e3.png`,
818
+ google: `${CDN}/192485d2-a76a-4657-9c06-930b2c70badd.png`,
819
+ deepseek: `${CDN}/9b7406d2-a696-4558-ab79-90a37e3f4574.png`,
820
+ xai: `${CDN}/858b7fcc-9bd5-411d-aea1-a7b35ecfffab.png`,
821
+ moonshot: `${CDN}/5a1e2eae-3474-4fac-9c74-a93f41ee6f67.png`,
822
+ minimax: `${CDN}/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png`
823
+ };
813
824
  function text(id, label, providerModelId, extra) {
825
+ const display = extra?.display;
826
+ const logo = display && !display.logo ? PROVIDER_LOGOS[display.provider] : void 0;
814
827
  return {
815
828
  id,
816
829
  aliases: [],
@@ -824,7 +837,8 @@ function text(id, label, providerModelId, extra) {
824
837
  defaults: {},
825
838
  usage: { ...TEXT_USAGE },
826
839
  pricingKind: "token",
827
- ...extra
840
+ ...extra,
841
+ ...display && logo ? { display: { ...display, logo } } : {}
828
842
  };
829
843
  }
830
844
  var ANTHROPIC_THINKING = {
@@ -843,7 +857,7 @@ var TEXT_MODELS = [
843
857
  costTier: 2,
844
858
  description: "OpenAI GPT-4o flagship multimodal model; text and image input, 128K-token context."
845
859
  },
846
- capabilities: { vision: true, tools: true, structuredOutput: true, contextWindow: 128e3 }
860
+ capabilities: { vision: true, contextWindow: 128e3 }
847
861
  }),
848
862
  text("gpt-4o-mini", "GPT-4o mini", "gpt-4o-mini", {
849
863
  exposure: "internal",
@@ -852,7 +866,7 @@ var TEXT_MODELS = [
852
866
  costTier: 1,
853
867
  description: "OpenAI GPT-4o mini fast, low-cost multimodal model; text and image input, 128K-token context."
854
868
  },
855
- capabilities: { vision: true, tools: true, structuredOutput: true, contextWindow: 128e3 }
869
+ capabilities: { vision: true, contextWindow: 128e3 }
856
870
  }),
857
871
  text("gpt-5.1", "GPT-5.1", "gpt-5.1", {
858
872
  exposure: "catalog",
@@ -861,7 +875,7 @@ var TEXT_MODELS = [
861
875
  costTier: 3,
862
876
  description: "OpenAI GPT-5.1 reasoning model for coding and agentic tasks; text and image input, 400K-token context."
863
877
  },
864
- capabilities: { vision: true, tools: true, structuredOutput: true, contextWindow: 4e5 }
878
+ capabilities: { vision: true, contextWindow: 4e5 }
865
879
  }),
866
880
  text("gpt-5.2", "GPT-5.2", "gpt-5.2", {
867
881
  exposure: "catalog",
@@ -870,7 +884,7 @@ var TEXT_MODELS = [
870
884
  costTier: 3,
871
885
  description: "OpenAI GPT-5.2 reasoning model for complex professional work; text and image input, 400K-token context."
872
886
  },
873
- capabilities: { vision: true, tools: true, structuredOutput: true, contextWindow: 4e5 }
887
+ capabilities: { vision: true, contextWindow: 4e5 }
874
888
  }),
875
889
  // 1.05M-token context: https://platform.openai.com/docs/models/gpt-5.4
876
890
  text("gpt-5.4", "GPT-5.4", "gpt-5.4", {
@@ -882,8 +896,6 @@ var TEXT_MODELS = [
882
896
  },
883
897
  capabilities: {
884
898
  vision: true,
885
- tools: true,
886
- structuredOutput: true,
887
899
  contextWindow: 105e4
888
900
  }
889
901
  }),
@@ -896,7 +908,7 @@ var TEXT_MODELS = [
896
908
  costTier: 1,
897
909
  description: "OpenAI GPT-5.4 mini efficient reasoning model for high-volume workloads; text and image input, 400K-token context."
898
910
  },
899
- capabilities: { vision: true, tools: true, structuredOutput: true, contextWindow: 4e5 }
911
+ capabilities: { vision: true, contextWindow: 4e5 }
900
912
  }),
901
913
  text("gpt-5.5", "GPT-5.5", "gpt-5.5", {
902
914
  exposure: "catalog",
@@ -907,8 +919,6 @@ var TEXT_MODELS = [
907
919
  },
908
920
  capabilities: {
909
921
  vision: true,
910
- tools: true,
911
- structuredOutput: true,
912
922
  contextWindow: 105e4
913
923
  }
914
924
  }),
@@ -923,8 +933,6 @@ var TEXT_MODELS = [
923
933
  capabilities: {
924
934
  reasoning: true,
925
935
  vision: true,
926
- tools: true,
927
- structuredOutput: true,
928
936
  contextWindow: 105e4
929
937
  }
930
938
  }),
@@ -939,8 +947,6 @@ var TEXT_MODELS = [
939
947
  capabilities: {
940
948
  reasoning: true,
941
949
  vision: true,
942
- tools: true,
943
- structuredOutput: true,
944
950
  contextWindow: 105e4
945
951
  }
946
952
  }),
@@ -955,8 +961,6 @@ var TEXT_MODELS = [
955
961
  capabilities: {
956
962
  reasoning: true,
957
963
  vision: true,
958
- tools: true,
959
- structuredOutput: true,
960
964
  contextWindow: 105e4
961
965
  }
962
966
  }),
@@ -969,7 +973,7 @@ var TEXT_MODELS = [
969
973
  costTier: 2,
970
974
  description: "Anthropic Claude Sonnet 4.5 (legacy) balanced model; text and image input, 200K-token context."
971
975
  },
972
- capabilities: { vision: true, tools: true, structuredOutput: true, contextWindow: 2e5 }
976
+ capabilities: { vision: true, contextWindow: 2e5 }
973
977
  }),
974
978
  // Anthropic retired the dated 4.0 ids; callers that still send them get 4.6.
975
979
  text("claude-sonnet-4-6", "Claude Sonnet 4.6", "claude-sonnet-4-6", {
@@ -989,8 +993,6 @@ var TEXT_MODELS = [
989
993
  capabilities: {
990
994
  reasoning: true,
991
995
  vision: true,
992
- tools: true,
993
- structuredOutput: true,
994
996
  contextWindow: 1e6
995
997
  }
996
998
  }),
@@ -1005,8 +1007,6 @@ var TEXT_MODELS = [
1005
1007
  capabilities: {
1006
1008
  reasoning: true,
1007
1009
  vision: true,
1008
- tools: true,
1009
- structuredOutput: true,
1010
1010
  contextWindow: 1e6
1011
1011
  }
1012
1012
  }),
@@ -1022,8 +1022,6 @@ var TEXT_MODELS = [
1022
1022
  capabilities: {
1023
1023
  reasoning: true,
1024
1024
  vision: true,
1025
- tools: true,
1026
- structuredOutput: true,
1027
1025
  contextWindow: 1e6
1028
1026
  }
1029
1027
  }),
@@ -1039,8 +1037,6 @@ var TEXT_MODELS = [
1039
1037
  capabilities: {
1040
1038
  reasoning: true,
1041
1039
  vision: true,
1042
- tools: true,
1043
- structuredOutput: true,
1044
1040
  contextWindow: 2e5
1045
1041
  }
1046
1042
  }),
@@ -1054,8 +1050,6 @@ var TEXT_MODELS = [
1054
1050
  },
1055
1051
  capabilities: {
1056
1052
  vision: true,
1057
- tools: true,
1058
- structuredOutput: true,
1059
1053
  contextWindow: 1e6
1060
1054
  }
1061
1055
  }),
@@ -1068,8 +1062,6 @@ var TEXT_MODELS = [
1068
1062
  },
1069
1063
  capabilities: {
1070
1064
  vision: true,
1071
- tools: true,
1072
- structuredOutput: true,
1073
1065
  contextWindow: 1e6
1074
1066
  }
1075
1067
  }),
@@ -1082,8 +1074,6 @@ var TEXT_MODELS = [
1082
1074
  },
1083
1075
  capabilities: {
1084
1076
  vision: true,
1085
- tools: true,
1086
- structuredOutput: true,
1087
1077
  contextWindow: 1048576
1088
1078
  }
1089
1079
  }),
@@ -1096,8 +1086,6 @@ var TEXT_MODELS = [
1096
1086
  },
1097
1087
  capabilities: {
1098
1088
  vision: true,
1099
- tools: true,
1100
- structuredOutput: true,
1101
1089
  contextWindow: 1048576
1102
1090
  }
1103
1091
  }),
@@ -1110,8 +1098,6 @@ var TEXT_MODELS = [
1110
1098
  },
1111
1099
  capabilities: {
1112
1100
  vision: true,
1113
- tools: true,
1114
- structuredOutput: true,
1115
1101
  contextWindow: 1048576
1116
1102
  }
1117
1103
  }),
@@ -1124,8 +1110,6 @@ var TEXT_MODELS = [
1124
1110
  },
1125
1111
  capabilities: {
1126
1112
  vision: true,
1127
- tools: true,
1128
- structuredOutput: true,
1129
1113
  contextWindow: 1048576
1130
1114
  }
1131
1115
  }),
@@ -1138,8 +1122,6 @@ var TEXT_MODELS = [
1138
1122
  },
1139
1123
  capabilities: {
1140
1124
  vision: true,
1141
- tools: true,
1142
- structuredOutput: true,
1143
1125
  contextWindow: 1048576
1144
1126
  }
1145
1127
  }),
@@ -1153,8 +1135,6 @@ var TEXT_MODELS = [
1153
1135
  },
1154
1136
  capabilities: {
1155
1137
  vision: true,
1156
- tools: true,
1157
- structuredOutput: true,
1158
1138
  contextWindow: 1048576
1159
1139
  }
1160
1140
  }),
@@ -1167,8 +1147,6 @@ var TEXT_MODELS = [
1167
1147
  },
1168
1148
  capabilities: {
1169
1149
  vision: true,
1170
- tools: true,
1171
- structuredOutput: true,
1172
1150
  contextWindow: 1048576
1173
1151
  }
1174
1152
  }),
@@ -1187,8 +1165,6 @@ var TEXT_MODELS = [
1187
1165
  },
1188
1166
  capabilities: {
1189
1167
  vision: true,
1190
- tools: true,
1191
- structuredOutput: true,
1192
1168
  contextWindow: 1048576
1193
1169
  }
1194
1170
  }),
@@ -1201,8 +1177,6 @@ var TEXT_MODELS = [
1201
1177
  },
1202
1178
  capabilities: {
1203
1179
  vision: true,
1204
- tools: false,
1205
- structuredOutput: true,
1206
1180
  contextWindow: 128e3
1207
1181
  }
1208
1182
  }),
@@ -1215,8 +1189,6 @@ var TEXT_MODELS = [
1215
1189
  },
1216
1190
  capabilities: {
1217
1191
  vision: true,
1218
- tools: false,
1219
- structuredOutput: true,
1220
1192
  contextWindow: 2e5
1221
1193
  }
1222
1194
  }),
@@ -1229,8 +1201,6 @@ var TEXT_MODELS = [
1229
1201
  },
1230
1202
  capabilities: {
1231
1203
  vision: true,
1232
- tools: false,
1233
- structuredOutput: true,
1234
1204
  contextWindow: 128e3
1235
1205
  }
1236
1206
  }),
@@ -1250,8 +1220,6 @@ var TEXT_MODELS = [
1250
1220
  capabilities: {
1251
1221
  reasoning: true,
1252
1222
  vision: true,
1253
- tools: true,
1254
- structuredOutput: true,
1255
1223
  contextWindow: 1e6
1256
1224
  }
1257
1225
  }),
@@ -1266,8 +1234,6 @@ var TEXT_MODELS = [
1266
1234
  capabilities: {
1267
1235
  reasoning: true,
1268
1236
  vision: false,
1269
- tools: true,
1270
- structuredOutput: true,
1271
1237
  contextWindow: 1e6
1272
1238
  }
1273
1239
  }),
@@ -1281,14 +1247,14 @@ var TEXT_MODELS = [
1281
1247
  },
1282
1248
  capabilities: {
1283
1249
  vision: true,
1284
- tools: true,
1285
- structuredOutput: true,
1286
1250
  contextWindow: 1e6
1287
1251
  }
1288
1252
  }),
1289
1253
  // Moonshot retired kimi-k2.5 on 2026-08-31 and no longer publishes its specs.
1290
1254
  text("kimi-k2.5", "Kimi K2.5", "kimi-k2.5", {
1291
- exposure: "catalog",
1255
+ lifecycle: "deprecated",
1256
+ replacedBy: "kimi-k3",
1257
+ exposure: "internal",
1292
1258
  display: {
1293
1259
  chat: { temperature: 1 },
1294
1260
  provider: "moonshot",
@@ -1308,8 +1274,6 @@ var TEXT_MODELS = [
1308
1274
  capabilities: {
1309
1275
  reasoning: true,
1310
1276
  vision: true,
1311
- tools: true,
1312
- structuredOutput: true,
1313
1277
  contextWindow: 1e6
1314
1278
  }
1315
1279
  }),
@@ -1323,12 +1287,12 @@ var TEXT_MODELS = [
1323
1287
  costTier: 2,
1324
1288
  description: "MiniMax M3 frontier multimodal model for agentic reasoning, tool use, and coding; text, image, and video input, 1M-token context."
1325
1289
  },
1326
- capabilities: { vision: true, tools: true, contextWindow: 1e6 }
1290
+ capabilities: { vision: true, contextWindow: 1e6 }
1327
1291
  })
1328
1292
  ];
1329
1293
 
1330
1294
  // src/catalog/video.ts
1331
- var VIDEO_USAGE = { unit: "seconds", modality: "VIDEO" };
1295
+ var VIDEO_USAGE = { unit: "seconds" };
1332
1296
  var SEEDANCE_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16", "adaptive"];
1333
1297
  var KLING_RATIOS = ["16:9", "9:16", "1:1", "adaptive"];
1334
1298
  var OMNI_RATIOS = ["16:9", "9:16"];
@@ -1502,7 +1466,7 @@ var VIDEO_MODELS = [
1502
1466
  constraints: {
1503
1467
  aspectRatios: [...SEEDANCE_RATIOS],
1504
1468
  resolutions: ["480p", "720p", "1080p", "4k"],
1505
- durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1469
+ durations: { min: 4, max: 15 },
1506
1470
  durationPresets: [4, 6, 8, 10, 12, 15],
1507
1471
  references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1508
1472
  ratioIgnoredWith: ["firstFrame"],
@@ -1535,7 +1499,7 @@ var VIDEO_MODELS = [
1535
1499
  constraints: {
1536
1500
  aspectRatios: [...SEEDANCE_RATIOS],
1537
1501
  resolutions: ["480p", "720p"],
1538
- durations: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1502
+ durations: { min: 4, max: 15 },
1539
1503
  references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1540
1504
  ratioIgnoredWith: ["firstFrame"],
1541
1505
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
@@ -1608,7 +1572,7 @@ var VIDEO_MODELS = [
1608
1572
  },
1609
1573
  // No resolution default: xAI picks its own unless the caller asks.
1610
1574
  defaults: { durationSeconds: 8, aspectRatio: "16:9" },
1611
- usage: { unit: "reported_cost_usd", modality: "VIDEO", slug: "grok" },
1575
+ usage: { unit: "reported_cost_usd", slug: "grok" },
1612
1576
  pricingKind: "video_per_second",
1613
1577
  display: {
1614
1578
  provider: "xai",
@@ -1642,6 +1606,7 @@ var VIDEO_MODELS = [
1642
1606
  pricingKind: "video_per_second",
1643
1607
  display: {
1644
1608
  provider: "kuaishou",
1609
+ logo: "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png",
1645
1610
  description: "Kuaishou Kling 2.5 Turbo Pro image-to-video; animates a single input image from a text prompt with an optional end image, 5- or 10-second clips."
1646
1611
  },
1647
1612
  capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
@@ -1672,6 +1637,7 @@ var VIDEO_MODELS = [
1672
1637
  pricingKind: "video_per_second",
1673
1638
  display: {
1674
1639
  provider: "kuaishou",
1640
+ logo: "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png",
1675
1641
  description: "Kuaishou Kling 3.0 Pro image-to-video; a required start image plus a text prompt (or multi-shot prompts) with optional end image and native audio, 3-15 second clips."
1676
1642
  },
1677
1643
  capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
@@ -1705,10 +1671,11 @@ var VIDEO_MODELS = [
1705
1671
  supports: ["generateAudio", "lastFrame"]
1706
1672
  },
1707
1673
  defaults: { durationSeconds: 5, aspectRatio: "16:9", generateAudio: false, mode: "pro" },
1708
- usage: { unit: "compute_seconds", modality: "VIDEO" },
1674
+ usage: { unit: "compute_seconds" },
1709
1675
  pricingKind: "video_per_second",
1710
1676
  display: {
1711
1677
  provider: "kuaishou",
1678
+ logo: "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png",
1712
1679
  description: "Kuaishou Kling Video 3.0 Omni unified generation and editing from text, start/end images, up to 7 reference images, and reference video; up to 15 seconds at up to 1080p."
1713
1680
  },
1714
1681
  capabilities: {}
@@ -1738,6 +1705,7 @@ var VIDEO_MODELS = [
1738
1705
  pricingKind: "video_per_second",
1739
1706
  display: {
1740
1707
  provider: "minimax",
1708
+ logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
1741
1709
  description: "MiniMax H3 multimodal video model for text-to-video, image-to-video (first/last frame), and reference-to-video with native audio, up to 2K."
1742
1710
  },
1743
1711
  capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
@@ -1767,6 +1735,7 @@ var VIDEO_MODELS = [
1767
1735
  pricingKind: "video_per_second",
1768
1736
  display: {
1769
1737
  provider: "minimax",
1738
+ logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
1770
1739
  description: "High-speed MiniMax H3 Max variant for text-to-video and image-to-video (first/last frame) only, up to 768p."
1771
1740
  },
1772
1741
  capabilities: { ...FRAMES_EXCLUDE_REFERENCES }
@@ -1797,6 +1766,7 @@ var VIDEO_MODELS = [
1797
1766
  pricingKind: "video_per_second",
1798
1767
  display: {
1799
1768
  provider: "minimax",
1769
+ logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
1800
1770
  description: "MiniMax H3 reference-to-video mode guided by up to 9 reference images, 3 reference videos, and 3 audio clips; reference and image-to-video inputs cannot be mixed."
1801
1771
  },
1802
1772
  capabilities: {}
@@ -1827,6 +1797,7 @@ var VIDEO_MODELS = [
1827
1797
  pricingKind: "video_per_second",
1828
1798
  display: {
1829
1799
  provider: "minimax",
1800
+ logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
1830
1801
  description: "MiniMax H3 Max reference-to-video on fal; conditions on reference images, videos, and audio. MiniMax's own docs do not list a reference mode for H3 Max."
1831
1802
  },
1832
1803
  capabilities: {}
@@ -1852,6 +1823,7 @@ var VIDEO_MODELS = [
1852
1823
  pricingKind: "video_per_second",
1853
1824
  display: {
1854
1825
  provider: "kuaishou",
1826
+ logo: "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png",
1855
1827
  description: "Kuaishou Kling O1 Reference Video-to-Video; a prompt plus a 3-10 second reference video (optional reference images) generates 3-10 second clips preserving motion and camera language."
1856
1828
  },
1857
1829
  capabilities: { acceptsSourceVideo: true }
@@ -1871,10 +1843,11 @@ var VIDEO_MODELS = [
1871
1843
  supports: ["lastFrame"]
1872
1844
  },
1873
1845
  defaults: { durationSeconds: 6, resolution: "768p" },
1874
- usage: { unit: "compute_seconds", modality: "VIDEO" },
1846
+ usage: { unit: "compute_seconds" },
1875
1847
  pricingKind: "video_per_second",
1876
1848
  display: {
1877
1849
  provider: "minimax",
1850
+ logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png",
1878
1851
  description: "MiniMax Hailuo 02 text-to-video and image-to-video model with realistic physics and strong prompt following; outputs 768p at 6 or 10 seconds."
1879
1852
  },
1880
1853
  capabilities: {}
@@ -1911,6 +1884,407 @@ var MODELS = [
1911
1884
  ...OTHER_MODELS
1912
1885
  ];
1913
1886
 
1887
+ // src/catalog/schema.ts
1888
+ var import_zod = require("zod");
1889
+ var ADAPTER_IDS = [
1890
+ "ai-sdk-text",
1891
+ "google-image",
1892
+ "openai-image",
1893
+ "google-genai",
1894
+ "ark",
1895
+ "fal",
1896
+ "replicate",
1897
+ "prodia",
1898
+ "higgsfield",
1899
+ "xai-video"
1900
+ ];
1901
+ var ModelTypeSchema = import_zod.z.enum(["text", "image", "video", "audio", "upscale", "bg-remove"]);
1902
+ var LifecycleSchema = import_zod.z.enum(["active", "deprecated", "retired"]);
1903
+ var AdapterSchema = import_zod.z.enum(ADAPTER_IDS);
1904
+ var AspectRatioSchema = import_zod.z.enum([
1905
+ "1:1",
1906
+ "16:9",
1907
+ "9:16",
1908
+ "4:3",
1909
+ "3:4",
1910
+ "3:2",
1911
+ "2:3",
1912
+ "4:5",
1913
+ "5:4",
1914
+ "21:9",
1915
+ "9:21",
1916
+ "97:30",
1917
+ "adaptive"
1918
+ ]);
1919
+ var ImageSizeSchema = import_zod.z.enum(["512", "1K", "2K", "4K"]);
1920
+ var VideoResolutionSchema = import_zod.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
1921
+ var ImageQualitySchema = import_zod.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
1922
+ var OutputFormatSchema = import_zod.z.enum(["png", "jpeg", "webp"]);
1923
+ var RequiredInputSchema = import_zod.z.enum(["firstFrame", "sourceVideo", "references"]);
1924
+ var SupportedOptionSchema = import_zod.z.enum([
1925
+ "seed",
1926
+ "quality",
1927
+ "negativePrompt",
1928
+ "cfgScale",
1929
+ "generateAudio",
1930
+ "promptExpansion",
1931
+ "lastFrame",
1932
+ "count",
1933
+ "outputFormat",
1934
+ "scaleFactor",
1935
+ "safetySettings",
1936
+ "temperature",
1937
+ "upscale",
1938
+ "watermark",
1939
+ "safetyChecker",
1940
+ "instrumental"
1941
+ ]);
1942
+ var UsageUnitSchema = import_zod.z.enum([
1943
+ "tokens",
1944
+ "images",
1945
+ "seconds",
1946
+ "reported_cost_usd",
1947
+ "compute_seconds"
1948
+ ]);
1949
+ var PricingKindSchema = import_zod.z.enum(["token", "image_size", "video_per_second", "flat"]);
1950
+ var ProviderOptionValueSchema = import_zod.z.lazy(
1951
+ () => import_zod.z.union([
1952
+ import_zod.z.string(),
1953
+ import_zod.z.number(),
1954
+ import_zod.z.boolean(),
1955
+ import_zod.z.array(ProviderOptionValueSchema),
1956
+ import_zod.z.record(import_zod.z.string(), ProviderOptionValueSchema)
1957
+ ])
1958
+ );
1959
+ var ProviderOptionsSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.record(import_zod.z.string(), ProviderOptionValueSchema));
1960
+ var ReferenceLimitsSchema = import_zod.z.looseObject({
1961
+ images: import_zod.z.number().optional(),
1962
+ videos: import_zod.z.number().optional(),
1963
+ audios: import_zod.z.number().optional(),
1964
+ total: import_zod.z.number().optional(),
1965
+ audioOnly: import_zod.z.boolean().optional()
1966
+ });
1967
+ var ModelConstraintsSchema = import_zod.z.looseObject({
1968
+ aspectRatios: import_zod.z.array(AspectRatioSchema).optional(),
1969
+ sizes: import_zod.z.array(ImageSizeSchema).optional(),
1970
+ resolutions: import_zod.z.array(VideoResolutionSchema).optional(),
1971
+ durations: import_zod.z.union([import_zod.z.looseObject({ min: import_zod.z.number(), max: import_zod.z.number() }), import_zod.z.array(import_zod.z.number())]).optional(),
1972
+ durationPresets: import_zod.z.array(import_zod.z.number()).optional(),
1973
+ qualityOptions: import_zod.z.array(import_zod.z.string()).optional(),
1974
+ exactSizes: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional(),
1975
+ references: ReferenceLimitsSchema.optional(),
1976
+ requires: import_zod.z.array(RequiredInputSchema).optional(),
1977
+ supports: import_zod.z.array(SupportedOptionSchema).optional(),
1978
+ ratioIgnoredWith: import_zod.z.array(import_zod.z.enum(["firstFrame", "sourceVideo"])).optional()
1979
+ });
1980
+ var MediaRefSchema = import_zod.z.union([
1981
+ import_zod.z.looseObject({ url: import_zod.z.string(), label: import_zod.z.string().optional() }),
1982
+ import_zod.z.looseObject({
1983
+ bytes: import_zod.z.instanceof(Uint8Array),
1984
+ mime: import_zod.z.string(),
1985
+ label: import_zod.z.string().optional()
1986
+ })
1987
+ ]);
1988
+ var ImageSafetySettingSchema = import_zod.z.looseObject({ category: import_zod.z.string(), threshold: import_zod.z.string() });
1989
+ var UpscaleOptionsSchema = import_zod.z.looseObject({
1990
+ enhanceModel: import_zod.z.string().optional(),
1991
+ subjectDetection: import_zod.z.string().optional(),
1992
+ faceEnhancement: import_zod.z.boolean().optional(),
1993
+ faceEnhancementCreativity: import_zod.z.number().optional(),
1994
+ faceEnhancementStrength: import_zod.z.number().optional()
1995
+ });
1996
+ var DefaultsSchema = import_zod.z.looseObject({
1997
+ references: import_zod.z.array(MediaRefSchema).optional(),
1998
+ aspectRatio: AspectRatioSchema.optional(),
1999
+ size: ImageSizeSchema.optional(),
2000
+ exactSize: import_zod.z.string().optional(),
2001
+ quality: ImageQualitySchema.optional(),
2002
+ seed: import_zod.z.number().optional(),
2003
+ count: import_zod.z.number().optional(),
2004
+ outputFormat: OutputFormatSchema.optional(),
2005
+ scaleFactor: import_zod.z.number().optional(),
2006
+ safetySettings: import_zod.z.array(ImageSafetySettingSchema).optional(),
2007
+ temperature: import_zod.z.number().optional(),
2008
+ upscale: UpscaleOptionsSchema.optional(),
2009
+ firstFrame: MediaRefSchema.optional(),
2010
+ lastFrame: MediaRefSchema.optional(),
2011
+ sourceVideo: MediaRefSchema.optional(),
2012
+ referenceImages: import_zod.z.array(MediaRefSchema).optional(),
2013
+ referenceVideos: import_zod.z.array(MediaRefSchema).optional(),
2014
+ referenceAudios: import_zod.z.array(MediaRefSchema).optional(),
2015
+ resolution: VideoResolutionSchema.optional(),
2016
+ durationSeconds: import_zod.z.number().optional(),
2017
+ generateAudio: import_zod.z.boolean().optional(),
2018
+ negativePrompt: import_zod.z.string().optional(),
2019
+ cfgScale: import_zod.z.number().optional(),
2020
+ promptExpansion: import_zod.z.enum(["fast", "balanced", "quality"]).optional(),
2021
+ watermark: import_zod.z.boolean().optional(),
2022
+ safetyChecker: import_zod.z.boolean().optional(),
2023
+ mode: import_zod.z.enum(["standard", "pro"]).optional(),
2024
+ instrumental: import_zod.z.boolean().optional()
2025
+ });
2026
+ var CatalogDisplaySchema = import_zod.z.looseObject({
2027
+ provider: import_zod.z.string(),
2028
+ description: import_zod.z.string(),
2029
+ logo: import_zod.z.string().optional(),
2030
+ costTier: import_zod.z.union([import_zod.z.literal(1), import_zod.z.literal(2), import_zod.z.literal(3)]).optional(),
2031
+ recommended: import_zod.z.boolean().optional(),
2032
+ sortOrder: import_zod.z.number().optional(),
2033
+ chat: import_zod.z.looseObject({
2034
+ providerOptions: ProviderOptionsSchema.optional(),
2035
+ temperature: import_zod.z.number().optional()
2036
+ }).optional()
2037
+ });
2038
+ var CatalogCapabilitiesSchema = import_zod.z.looseObject({
2039
+ acceptsSourceVideo: import_zod.z.boolean().optional(),
2040
+ framesExcludeReferences: import_zod.z.boolean().optional(),
2041
+ reasoning: import_zod.z.boolean().optional(),
2042
+ vision: import_zod.z.boolean().optional(),
2043
+ contextWindow: import_zod.z.number().optional()
2044
+ });
2045
+ var CatalogModelSchemaBase = import_zod.z.looseObject({
2046
+ id: import_zod.z.string().min(1),
2047
+ aliases: import_zod.z.array(import_zod.z.string()).default([]),
2048
+ label: import_zod.z.string().min(1),
2049
+ type: ModelTypeSchema,
2050
+ adapter: AdapterSchema,
2051
+ providerModelId: import_zod.z.string().min(1),
2052
+ lifecycle: LifecycleSchema,
2053
+ replacedBy: import_zod.z.string().optional(),
2054
+ exposure: import_zod.z.enum(["catalog", "internal"]),
2055
+ constraints: ModelConstraintsSchema,
2056
+ defaults: DefaultsSchema,
2057
+ providerOptions: ProviderOptionsSchema.optional(),
2058
+ usage: import_zod.z.looseObject({
2059
+ unit: UsageUnitSchema,
2060
+ slug: import_zod.z.string().optional(),
2061
+ providerLabel: import_zod.z.string().optional()
2062
+ }),
2063
+ pricingKind: PricingKindSchema,
2064
+ display: CatalogDisplaySchema.optional(),
2065
+ capabilities: CatalogCapabilitiesSchema.optional()
2066
+ }).superRefine((row, ctx) => {
2067
+ if (row.lifecycle === "active" && !row.display) {
2068
+ ctx.addIssue({
2069
+ code: "custom",
2070
+ path: ["display"],
2071
+ message: "active rows need display"
2072
+ });
2073
+ }
2074
+ if (row.lifecycle === "active" && row.type === "text" && !row.capabilities?.contextWindow) {
2075
+ ctx.addIssue({
2076
+ code: "custom",
2077
+ path: ["capabilities", "contextWindow"],
2078
+ message: "active text rows need contextWindow"
2079
+ });
2080
+ }
2081
+ if (row.replacedBy !== void 0 && row.replacedBy === row.id) {
2082
+ ctx.addIssue({
2083
+ code: "custom",
2084
+ path: ["replacedBy"],
2085
+ message: "replacedBy must not equal id"
2086
+ });
2087
+ }
2088
+ });
2089
+ var CatalogModelSchema = CatalogModelSchemaBase;
2090
+ var CatalogSchema = import_zod.z.array(CatalogModelSchemaBase).superRefine((rows, ctx) => {
2091
+ const seenIds = /* @__PURE__ */ new Map();
2092
+ rows.forEach((row, index) => {
2093
+ if (seenIds.has(row.id)) {
2094
+ ctx.addIssue({
2095
+ code: "custom",
2096
+ path: [index, "id"],
2097
+ message: `Duplicate model id "${row.id}"`
2098
+ });
2099
+ } else {
2100
+ seenIds.set(row.id, index);
2101
+ }
2102
+ });
2103
+ const seenAliases = /* @__PURE__ */ new Map();
2104
+ rows.forEach((row, index) => {
2105
+ row.aliases.forEach((alias, aliasIndex) => {
2106
+ const path = [index, "aliases", aliasIndex];
2107
+ if (alias === row.id || seenIds.has(alias)) {
2108
+ ctx.addIssue({
2109
+ code: "custom",
2110
+ path,
2111
+ message: `Alias "${alias}" collides with a model id`
2112
+ });
2113
+ return;
2114
+ }
2115
+ if (seenAliases.has(alias)) {
2116
+ ctx.addIssue({
2117
+ code: "custom",
2118
+ path,
2119
+ message: `Duplicate alias "${alias}"`
2120
+ });
2121
+ } else {
2122
+ seenAliases.set(alias, index);
2123
+ }
2124
+ });
2125
+ });
2126
+ });
2127
+
2128
+ // src/catalog/live.ts
2129
+ var liveCatalog = new Catalog(MODELS);
2130
+
2131
+ // src/catalog/load.ts
2132
+ var memo;
2133
+ var timer;
2134
+ var revision;
2135
+ var origin = "snapshot";
2136
+ function rowCount() {
2137
+ return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
2138
+ }
2139
+ function authHeaders(auth) {
2140
+ return "bearer" in auth ? { Authorization: `Bearer ${auth.bearer}` } : { "x-api-key": auth.apiKey };
2141
+ }
2142
+ function describeError(err) {
2143
+ return err instanceof Error ? err.message : String(err);
2144
+ }
2145
+ function parseEnvelope(json) {
2146
+ if (typeof json !== "object" || json === null || !("rows" in json)) {
2147
+ throw new Error("invalid catalog response: missing rows");
2148
+ }
2149
+ const rows = CatalogSchema.parse(json.rows);
2150
+ const rev = json.revision;
2151
+ if (typeof rev === "string") return { rows, revision: rev };
2152
+ return { rows };
2153
+ }
2154
+ function logPrimed(logger, result) {
2155
+ const { origin: loggedOrigin, rowCount: loggedCount, revision: loggedRevision } = result;
2156
+ logger.info("[modelkit] catalog primed", {
2157
+ origin: loggedOrigin,
2158
+ rowCount: loggedCount,
2159
+ revision: loggedRevision
2160
+ });
2161
+ }
2162
+ async function fetchRemote(source, logger) {
2163
+ const fetchImpl = source.fetch ?? globalThis.fetch;
2164
+ const headers2 = authHeaders(source.auth);
2165
+ if (revision !== void 0) headers2["If-None-Match"] = `"${revision}"`;
2166
+ const res = await fetchImpl(`${source.baseUrl}/models/catalog`, {
2167
+ headers: headers2,
2168
+ signal: AbortSignal.timeout(source.timeoutMs ?? 1e4)
2169
+ });
2170
+ if (res.status === 304) return { kept: true };
2171
+ if (!res.ok) throw new Error(`catalog fetch failed with status ${res.status}`);
2172
+ const json = await res.json();
2173
+ const { rows, revision: rev } = parseEnvelope(json);
2174
+ if (rev === void 0) return { rows, fromCache: false };
2175
+ return { rows, revision: rev, fromCache: false };
2176
+ }
2177
+ async function writeCache(source, logger, rows, rev) {
2178
+ if (!source.cache) return;
2179
+ try {
2180
+ await source.cache.set(JSON.stringify({ rows, revision: rev }));
2181
+ } catch (err) {
2182
+ logger.warn("[modelkit] catalog cache write failed", err);
2183
+ }
2184
+ }
2185
+ async function prime(source, logger) {
2186
+ try {
2187
+ const fetched = await fetchRemote(source, logger);
2188
+ if ("kept" in fetched) {
2189
+ const result2 = { origin, rowCount: rowCount() };
2190
+ if (revision !== void 0) result2.revision = revision;
2191
+ logPrimed(logger, result2);
2192
+ return result2;
2193
+ }
2194
+ liveCatalog.replace(fetched.rows);
2195
+ origin = "remote";
2196
+ revision = fetched.revision;
2197
+ await writeCache(source, logger, fetched.rows, fetched.revision);
2198
+ const result = { origin, rowCount: rowCount() };
2199
+ if (fetched.revision !== void 0) result.revision = fetched.revision;
2200
+ logPrimed(logger, result);
2201
+ return result;
2202
+ } catch (err) {
2203
+ logger.warn("[modelkit] catalog remote failed, trying cache", err);
2204
+ const error = describeError(err);
2205
+ try {
2206
+ const cached = await source.cache?.get();
2207
+ if (!cached) throw new Error("no cached catalog");
2208
+ const { rows, revision: rev } = parseEnvelope(JSON.parse(cached));
2209
+ liveCatalog.replace(rows);
2210
+ origin = "last-good";
2211
+ revision = rev;
2212
+ const result = { origin, rowCount: rowCount(), error };
2213
+ if (rev !== void 0) result.revision = rev;
2214
+ logPrimed(logger, result);
2215
+ return result;
2216
+ } catch (cacheErr) {
2217
+ logger.warn("[modelkit] catalog cache failed, using snapshot", cacheErr);
2218
+ liveCatalog.replace([...MODELS]);
2219
+ origin = "snapshot";
2220
+ revision = void 0;
2221
+ const result = {
2222
+ origin,
2223
+ rowCount: rowCount(),
2224
+ error
2225
+ };
2226
+ logPrimed(logger, result);
2227
+ return result;
2228
+ }
2229
+ }
2230
+ }
2231
+ async function refresh(source, logger) {
2232
+ try {
2233
+ const fetched = await fetchRemote(source, logger);
2234
+ if ("kept" in fetched) return;
2235
+ liveCatalog.replace(fetched.rows);
2236
+ origin = "remote";
2237
+ revision = fetched.revision;
2238
+ await writeCache(source, logger, fetched.rows, fetched.revision);
2239
+ } catch (err) {
2240
+ logger.warn("[modelkit] catalog refresh failed, keeping current rows", err);
2241
+ }
2242
+ }
2243
+ function primeCatalog(source) {
2244
+ if (memo) return memo;
2245
+ const logger = source.logger ?? console;
2246
+ memo = prime(source, logger).then((result) => {
2247
+ const ttlMs = source.ttlMs ?? 3e5;
2248
+ if (ttlMs > 0 && timer === void 0) {
2249
+ timer = setInterval(() => void refresh(source, logger), ttlMs);
2250
+ const maybeUnref = timer;
2251
+ maybeUnref.unref?.();
2252
+ }
2253
+ return result;
2254
+ });
2255
+ return memo;
2256
+ }
2257
+ function resetLiveCatalog() {
2258
+ if (timer !== void 0) {
2259
+ clearInterval(timer);
2260
+ timer = void 0;
2261
+ }
2262
+ memo = void 0;
2263
+ revision = void 0;
2264
+ origin = "snapshot";
2265
+ liveCatalog.replace([...MODELS]);
2266
+ }
2267
+
2268
+ // src/catalog/file-cache.ts
2269
+ var import_promises = require("fs/promises");
2270
+ function fileCatalogCache(path) {
2271
+ return {
2272
+ async get() {
2273
+ try {
2274
+ return await (0, import_promises.readFile)(path, "utf8");
2275
+ } catch (err) {
2276
+ if (err?.code === "ENOENT") return null;
2277
+ throw err;
2278
+ }
2279
+ },
2280
+ async set(json) {
2281
+ const tmp = `${path}.tmp`;
2282
+ await (0, import_promises.writeFile)(tmp, json, "utf8");
2283
+ await (0, import_promises.rename)(tmp, path);
2284
+ }
2285
+ };
2286
+ }
2287
+
1914
2288
  // src/resolve-options.ts
1915
2289
  var SIZE_ORDER = ["512", "1K", "2K", "4K"];
1916
2290
  var RESOLUTION_ORDER = ["360p", "480p", "720p", "768p", "1080p", "2k", "4k"];
@@ -2336,21 +2710,21 @@ function keysFromEnv(env, prefix = "") {
2336
2710
  }
2337
2711
 
2338
2712
  // src/retry.ts
2339
- var import_zod2 = require("zod");
2713
+ var import_zod3 = require("zod");
2340
2714
 
2341
2715
  // src/json.ts
2342
- var import_zod = require("zod");
2343
- var JsonValueSchema = import_zod.z.lazy(
2344
- () => import_zod.z.union([
2345
- import_zod.z.string(),
2346
- import_zod.z.number(),
2347
- import_zod.z.boolean(),
2348
- import_zod.z.null(),
2349
- import_zod.z.array(JsonValueSchema),
2350
- import_zod.z.record(import_zod.z.string(), JsonValueSchema)
2716
+ var import_zod2 = require("zod");
2717
+ var JsonValueSchema = import_zod2.z.lazy(
2718
+ () => import_zod2.z.union([
2719
+ import_zod2.z.string(),
2720
+ import_zod2.z.number(),
2721
+ import_zod2.z.boolean(),
2722
+ import_zod2.z.null(),
2723
+ import_zod2.z.array(JsonValueSchema),
2724
+ import_zod2.z.record(import_zod2.z.string(), JsonValueSchema)
2351
2725
  ])
2352
2726
  );
2353
- var JsonObjectSchema = import_zod.z.record(import_zod.z.string(), JsonValueSchema);
2727
+ var JsonObjectSchema = import_zod2.z.record(import_zod2.z.string(), JsonValueSchema);
2354
2728
  async function readErrorBody(res) {
2355
2729
  const text2 = await res.text().catch(() => "");
2356
2730
  try {
@@ -2359,11 +2733,11 @@ async function readErrorBody(res) {
2359
2733
  return text2;
2360
2734
  }
2361
2735
  }
2362
- var thrownErrorSchema = import_zod.z.object({
2363
- message: import_zod.z.string().optional(),
2364
- status: import_zod.z.number().optional(),
2365
- statusCode: import_zod.z.number().optional(),
2366
- responseBody: import_zod.z.string().optional()
2736
+ var thrownErrorSchema = import_zod2.z.object({
2737
+ message: import_zod2.z.string().optional(),
2738
+ status: import_zod2.z.number().optional(),
2739
+ statusCode: import_zod2.z.number().optional(),
2740
+ responseBody: import_zod2.z.string().optional()
2367
2741
  });
2368
2742
  function describeThrown(cause) {
2369
2743
  const parsed = thrownErrorSchema.safeParse(cause);
@@ -2374,7 +2748,7 @@ function describeThrown(cause) {
2374
2748
  }
2375
2749
 
2376
2750
  // src/retry.ts
2377
- var textBody = import_zod2.z.string();
2751
+ var textBody = import_zod3.z.string();
2378
2752
  function classifyHttpError(status, body, provider, model) {
2379
2753
  const asText = textBody.safeParse(body);
2380
2754
  const text2 = asText.success ? asText.data : JSON.stringify(body);
@@ -2431,12 +2805,12 @@ function sleep(ms, signal) {
2431
2805
  rejectAborted();
2432
2806
  return;
2433
2807
  }
2434
- let timer;
2808
+ let timer2;
2435
2809
  const onAbort = () => {
2436
- if (timer !== void 0) clearTimeout(timer);
2810
+ if (timer2 !== void 0) clearTimeout(timer2);
2437
2811
  rejectAborted();
2438
2812
  };
2439
- timer = setTimeout(() => {
2813
+ timer2 = setTimeout(() => {
2440
2814
  signal?.removeEventListener("abort", onAbort);
2441
2815
  resolve();
2442
2816
  }, ms);
@@ -2522,7 +2896,7 @@ function passthroughTextModel(model) {
2522
2896
  exposure: "internal",
2523
2897
  constraints: {},
2524
2898
  defaults: {},
2525
- usage: { unit: "tokens", modality: "TEXT" },
2899
+ usage: { unit: "tokens" },
2526
2900
  pricingKind: "token"
2527
2901
  };
2528
2902
  }
@@ -2582,7 +2956,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
2582
2956
 
2583
2957
  // src/client.ts
2584
2958
  var import_ai2 = require("ai");
2585
- var import_zod4 = require("zod");
2959
+ var import_zod5 = require("zod");
2586
2960
 
2587
2961
  // src/adapters/media-ref.ts
2588
2962
  function isUrlRef(ref) {
@@ -2667,7 +3041,7 @@ var import_perplexity = require("@ai-sdk/perplexity");
2667
3041
  var import_xai = require("@ai-sdk/xai");
2668
3042
  var import_deepseek = require("@ai-sdk/deepseek");
2669
3043
  var import_moonshotai = require("@ai-sdk/moonshotai");
2670
- var import_zod3 = require("zod");
3044
+ var import_zod4 = require("zod");
2671
3045
  var TEXT_PROVIDERS = [
2672
3046
  "openai",
2673
3047
  "anthropic",
@@ -2678,7 +3052,7 @@ var TEXT_PROVIDERS = [
2678
3052
  "moonshot",
2679
3053
  "minimax"
2680
3054
  ];
2681
- var textProviderSchema = import_zod3.z.enum(TEXT_PROVIDERS);
3055
+ var textProviderSchema = import_zod4.z.enum(TEXT_PROVIDERS);
2682
3056
  function isTextProvider(value) {
2683
3057
  return textProviderSchema.safeParse(value).success;
2684
3058
  }
@@ -2848,10 +3222,10 @@ function textAbortOptions(sdk, context) {
2848
3222
  if (abortSignal) return { abortSignal };
2849
3223
  return {};
2850
3224
  }
2851
- var catalogId = import_zod4.z.string();
2852
- var exactSize = import_zod4.z.templateLiteral([import_zod4.z.number(), "x", import_zod4.z.number()]);
2853
- var sdkRatio = import_zod4.z.templateLiteral([import_zod4.z.number(), ":", import_zod4.z.number()]);
2854
- var sizeTier = import_zod4.z.enum(["512", "1K", "2K", "4K"]);
3225
+ var catalogId = import_zod5.z.string();
3226
+ var exactSize = import_zod5.z.templateLiteral([import_zod5.z.number(), "x", import_zod5.z.number()]);
3227
+ var sdkRatio = import_zod5.z.templateLiteral([import_zod5.z.number(), ":", import_zod5.z.number()]);
3228
+ var sizeTier = import_zod5.z.enum(["512", "1K", "2K", "4K"]);
2855
3229
  function isCatalogId(model) {
2856
3230
  return catalogId.safeParse(model).success;
2857
3231
  }
@@ -2918,7 +3292,7 @@ function logCoercions(logger, modelId, warnings) {
2918
3292
  logger.warn(`[modelkit] ${modelId} request coerced`, { model: modelId, warnings });
2919
3293
  }
2920
3294
  function createModelKit(config, adapters) {
2921
- const catalog = new Catalog(MODELS).withOverrides(config.catalogOverride ?? []);
3295
+ const catalog = config.catalogOverride ? liveCatalog.withOverrides(config.catalogOverride) : liveCatalog;
2922
3296
  const logger = config.logger ?? console;
2923
3297
  const fetchImpl = config.fetch ?? globalThis.fetch;
2924
3298
  function context(model, call, warnings) {
@@ -3372,7 +3746,7 @@ function createModelKit(config, adapters) {
3372
3746
  }
3373
3747
 
3374
3748
  // src/adapters/ark.ts
3375
- var import_zod5 = require("zod");
3749
+ var import_zod6 = require("zod");
3376
3750
  var ARK_BASE_URL = "https://ark.ap-southeast.bytepluses.com/api/v3";
3377
3751
  var SUBMIT_PATH = "/contents/generations/tasks";
3378
3752
  var SEEDANCE_POLL_INTERVAL_MS = 15e3;
@@ -3449,7 +3823,7 @@ function arkKey(ctx) {
3449
3823
  return key;
3450
3824
  }
3451
3825
  function throwArkError(status, body, model) {
3452
- const parsed = import_zod5.z.string().safeParse(body);
3826
+ const parsed = import_zod6.z.string().safeParse(body);
3453
3827
  const text2 = parsed.success ? parsed.data : JSON.stringify(body ?? "");
3454
3828
  if (/sensitive.?content|human.?face/i.test(text2)) {
3455
3829
  const init = {
@@ -3487,13 +3861,13 @@ function sniffedImageMime(bytes) {
3487
3861
  return "image/webp";
3488
3862
  return "image/jpeg";
3489
3863
  }
3490
- var SeedreamImageSchema = import_zod5.z.object({
3491
- url: import_zod5.z.string().optional(),
3492
- b64_json: import_zod5.z.string().optional()
3864
+ var SeedreamImageSchema = import_zod6.z.object({
3865
+ url: import_zod6.z.string().optional(),
3866
+ b64_json: import_zod6.z.string().optional()
3493
3867
  });
3494
- var SeedreamResponseSchema = import_zod5.z.object({
3495
- data: import_zod5.z.array(SeedreamImageSchema).optional(),
3496
- error: import_zod5.z.object({ message: import_zod5.z.string().optional(), code: import_zod5.z.string().optional() }).optional()
3868
+ var SeedreamResponseSchema = import_zod6.z.object({
3869
+ data: import_zod6.z.array(SeedreamImageSchema).optional(),
3870
+ error: import_zod6.z.object({ message: import_zod6.z.string().optional(), code: import_zod6.z.string().optional() }).optional()
3497
3871
  });
3498
3872
  function retryOptsFor(ctx, attempts = 3) {
3499
3873
  const opts = { attempts };
@@ -3565,21 +3939,21 @@ async function generateSeedreamImage(req, ctx) {
3565
3939
  if (req.quality !== void 0) usage2.imageQuality = req.quality;
3566
3940
  return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage: usage2, raw: data };
3567
3941
  }
3568
- var SeedanceUsageSchema = import_zod5.z.object({
3569
- total_tokens: import_zod5.z.number().optional(),
3570
- completion_tokens: import_zod5.z.number().optional()
3942
+ var SeedanceUsageSchema = import_zod6.z.object({
3943
+ total_tokens: import_zod6.z.number().optional(),
3944
+ completion_tokens: import_zod6.z.number().optional()
3571
3945
  });
3572
- var SeedanceResponseSchema = import_zod5.z.object({
3573
- id: import_zod5.z.string().optional(),
3574
- status: import_zod5.z.string().optional(),
3575
- content: import_zod5.z.object({ video_url: import_zod5.z.string().optional() }).optional(),
3946
+ var SeedanceResponseSchema = import_zod6.z.object({
3947
+ id: import_zod6.z.string().optional(),
3948
+ status: import_zod6.z.string().optional(),
3949
+ content: import_zod6.z.object({ video_url: import_zod6.z.string().optional() }).optional(),
3576
3950
  usage: SeedanceUsageSchema.optional(),
3577
- duration: import_zod5.z.number().optional(),
3578
- framespersecond: import_zod5.z.number().optional(),
3579
- resolution: import_zod5.z.string().optional(),
3580
- error: import_zod5.z.union([import_zod5.z.string(), import_zod5.z.object({ message: import_zod5.z.string().optional() })]).optional()
3951
+ duration: import_zod6.z.number().optional(),
3952
+ framespersecond: import_zod6.z.number().optional(),
3953
+ resolution: import_zod6.z.string().optional(),
3954
+ error: import_zod6.z.union([import_zod6.z.string(), import_zod6.z.object({ message: import_zod6.z.string().optional() })]).optional()
3581
3955
  });
3582
- var SeedanceErrorMessageSchema = import_zod5.z.object({ message: import_zod5.z.string().optional() });
3956
+ var SeedanceErrorMessageSchema = import_zod6.z.object({ message: import_zod6.z.string().optional() });
3583
3957
  function seedanceUsage(ctx, req, duration) {
3584
3958
  const usage2 = {
3585
3959
  model: ctx.model.id,
@@ -3593,7 +3967,7 @@ function seedanceUsage(ctx, req, duration) {
3593
3967
  return usage2;
3594
3968
  }
3595
3969
  function seedanceErrorMessage(error, status) {
3596
- const asString = import_zod5.z.string().safeParse(error);
3970
+ const asString = import_zod6.z.string().safeParse(error);
3597
3971
  if (asString.success) return asString.data;
3598
3972
  const asObject = SeedanceErrorMessageSchema.safeParse(error);
3599
3973
  if (asObject.success && asObject.data.message !== void 0) return asObject.data.message;
@@ -3742,7 +4116,7 @@ async function generateSeedanceVideo(req, ctx) {
3742
4116
  }
3743
4117
 
3744
4118
  // src/adapters/fal.ts
3745
- var import_zod6 = require("zod");
4119
+ var import_zod7 = require("zod");
3746
4120
  var import_client = require("@fal-ai/client");
3747
4121
  var MUSE_T2I_ENDPOINT = "meta/muse-image/text-to-image";
3748
4122
  var MUSE_EDIT_ENDPOINT = "meta/muse-image/edit";
@@ -3750,7 +4124,7 @@ var KLING_O1_ENDPOINT = "fal-ai/kling-video/o1/video-to-video/reference";
3750
4124
  var FAL_QUEUE_HOST = "https://queue.fal.run";
3751
4125
  var PASSTHROUGH_POLL_MS = 2e3;
3752
4126
  var PASSTHROUGH_MAX_WAIT_MS = 18e4;
3753
- var falSubscribePayloadSchema = import_zod6.z.object({ data: JsonValueSchema });
4127
+ var falSubscribePayloadSchema = import_zod7.z.object({ data: JsonValueSchema });
3754
4128
  function defaultCreateFalClient(opts) {
3755
4129
  const client2 = (0, import_client.createFalClient)(opts);
3756
4130
  return {
@@ -3800,7 +4174,7 @@ function createFalAdapter(deps = defaultDeps) {
3800
4174
  };
3801
4175
  }
3802
4176
  var falAdapter = createFalAdapter();
3803
- var falDetailSchema = import_zod6.z.object({ detail: JsonValueSchema });
4177
+ var falDetailSchema = import_zod7.z.object({ detail: JsonValueSchema });
3804
4178
  function liftDetail(body) {
3805
4179
  const parsed = falDetailSchema.safeParse(body);
3806
4180
  const detail = parsed.success ? parsed.data.detail : void 0;
@@ -3809,11 +4183,11 @@ function liftDetail(body) {
3809
4183
  function falError(status, body, model) {
3810
4184
  return classifyHttpError(status, liftDetail(body), "fal", model);
3811
4185
  }
3812
- var falSdkThrownSchema = import_zod6.z.object({
3813
- status: import_zod6.z.number().optional(),
3814
- statusCode: import_zod6.z.number().optional(),
4186
+ var falSdkThrownSchema = import_zod7.z.object({
4187
+ status: import_zod7.z.number().optional(),
4188
+ statusCode: import_zod7.z.number().optional(),
3815
4189
  body: JsonValueSchema.optional(),
3816
- message: import_zod6.z.string().optional()
4190
+ message: import_zod7.z.string().optional()
3817
4191
  });
3818
4192
  function falSdkError(cause, model) {
3819
4193
  const parsed = falSdkThrownSchema.safeParse(cause);
@@ -3857,12 +4231,12 @@ async function gatewayFetch(cfg, fetchImpl, targetUrl, init) {
3857
4231
  if (init.body !== void 0) request.body = init.body;
3858
4232
  return fetchImpl(cfg.baseUrl, request);
3859
4233
  }
3860
- var falQueueSubmitSchema = import_zod6.z.object({
3861
- request_id: import_zod6.z.string(),
3862
- status_url: import_zod6.z.string(),
3863
- response_url: import_zod6.z.string()
4234
+ var falQueueSubmitSchema = import_zod7.z.object({
4235
+ request_id: import_zod7.z.string(),
4236
+ status_url: import_zod7.z.string(),
4237
+ response_url: import_zod7.z.string()
3864
4238
  });
3865
- var falQueueStatusSchema = import_zod6.z.object({ status: import_zod6.z.string() });
4239
+ var falQueueStatusSchema = import_zod7.z.object({ status: import_zod7.z.string() });
3866
4240
  async function passthroughRequest(ctx, endpoint, input) {
3867
4241
  const cfg = gatewayConfig(ctx);
3868
4242
  const submitRes = await gatewayFetch(cfg, ctx.fetch, `${FAL_QUEUE_HOST}/${endpoint}`, {
@@ -3988,11 +4362,11 @@ async function decodeImage(ctx, url, contentType) {
3988
4362
  const mime = res.headers.get("content-type") ?? contentType ?? "image/png";
3989
4363
  return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
3990
4364
  }
3991
- var museImageResultSchema = import_zod6.z.object({
3992
- images: import_zod6.z.array(
3993
- import_zod6.z.object({
3994
- url: import_zod6.z.string().optional(),
3995
- content_type: import_zod6.z.string().nullable().optional()
4365
+ var museImageResultSchema = import_zod7.z.object({
4366
+ images: import_zod7.z.array(
4367
+ import_zod7.z.object({
4368
+ url: import_zod7.z.string().optional(),
4369
+ content_type: import_zod7.z.string().nullable().optional()
3996
4370
  })
3997
4371
  ).optional()
3998
4372
  });
@@ -4084,8 +4458,8 @@ function klingO1Input(req) {
4084
4458
  if (refs.length > 0) input.image_urls = refs;
4085
4459
  return input;
4086
4460
  }
4087
- var falVideoResultSchema = import_zod6.z.object({
4088
- video: import_zod6.z.object({ url: import_zod6.z.string().optional() }).optional()
4461
+ var falVideoResultSchema = import_zod7.z.object({
4462
+ video: import_zod7.z.object({ url: import_zod7.z.string().optional() }).optional()
4089
4463
  });
4090
4464
  function extractVideoUrl(result, endpoint, model) {
4091
4465
  const parsed = falVideoResultSchema.safeParse(result);
@@ -4275,11 +4649,11 @@ async function passthroughVideoJob(ctx, req, endpoint, input) {
4275
4649
  }
4276
4650
 
4277
4651
  // src/adapters/google-genai.ts
4278
- var import_zod8 = require("zod");
4652
+ var import_zod9 = require("zod");
4279
4653
  var import_genai = require("@google/genai");
4280
4654
 
4281
4655
  // src/adapters/google-files.ts
4282
- var import_zod7 = require("zod");
4656
+ var import_zod8 = require("zod");
4283
4657
  var GOOGLE_FILES_BASE = "https://generativelanguage.googleapis.com";
4284
4658
  var GOOGLE_FILES_POLL_INTERVAL_MS = 2e3;
4285
4659
  var GOOGLE_FILES_POLL_TIMEOUT_MS = 5 * 60 * 1e3;
@@ -4289,17 +4663,17 @@ var GENERIC_MEDIA_TYPES = /* @__PURE__ */ new Set([
4289
4663
  "binary/octet-stream",
4290
4664
  "application/binary"
4291
4665
  ]);
4292
- var uploadedFileSchema = import_zod7.z.object({
4293
- file: import_zod7.z.object({
4294
- uri: import_zod7.z.string().optional(),
4295
- name: import_zod7.z.string().optional(),
4296
- state: import_zod7.z.string().optional(),
4297
- mimeType: import_zod7.z.string().optional()
4666
+ var uploadedFileSchema = import_zod8.z.object({
4667
+ file: import_zod8.z.object({
4668
+ uri: import_zod8.z.string().optional(),
4669
+ name: import_zod8.z.string().optional(),
4670
+ state: import_zod8.z.string().optional(),
4671
+ mimeType: import_zod8.z.string().optional()
4298
4672
  }).optional()
4299
4673
  });
4300
- var fileStateSchema = import_zod7.z.object({
4301
- state: import_zod7.z.string().optional(),
4302
- error: import_zod7.z.object({ message: import_zod7.z.string().optional() }).optional()
4674
+ var fileStateSchema = import_zod8.z.object({
4675
+ state: import_zod8.z.string().optional(),
4676
+ error: import_zod8.z.object({ message: import_zod8.z.string().optional() }).optional()
4303
4677
  });
4304
4678
  function resolveMime(declared, fallback) {
4305
4679
  const clean = declared?.split(";")[0]?.trim().toLowerCase();
@@ -4512,7 +4886,7 @@ var OMNI_POLL_INTERVAL_MS = 1e4;
4512
4886
  var RESULT_TIMEOUT_MS2 = 15 * 60 * 1e3;
4513
4887
  var OMNI_INLINE_LIMIT_BYTES = 4 * 1024 * 1024;
4514
4888
  var MEDIA_PART_INLINE_LIMIT_BYTES = 20 * 1024 * 1024;
4515
- var errorTextSchema = import_zod8.z.string();
4889
+ var errorTextSchema = import_zod9.z.string();
4516
4890
  function createGoogleGenaiAdapter(deps = defaultDeps2) {
4517
4891
  const { createGenAIClient } = deps;
4518
4892
  return {
@@ -5070,15 +5444,15 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
5070
5444
  // src/adapters/google-image.ts
5071
5445
  var import_google2 = require("@ai-sdk/google");
5072
5446
  var import_ai3 = require("ai");
5073
- var import_zod9 = require("zod");
5447
+ var import_zod10 = require("zod");
5074
5448
  var GEMINI_IMAGE_TIMEOUT_MS = 6e5;
5075
5449
  var defaultGoogleImageDeps = {
5076
5450
  createGoogleClient: (opts) => (0, import_google2.createGoogleGenerativeAI)(opts),
5077
5451
  runTextGeneration: (opts) => (0, import_ai3.generateText)(opts)
5078
5452
  };
5079
- var causeChainNodeSchema = import_zod9.z.object({
5080
- message: import_zod9.z.string().optional(),
5081
- cause: import_zod9.z.unknown().optional()
5453
+ var causeChainNodeSchema = import_zod10.z.object({
5454
+ message: import_zod10.z.string().optional(),
5455
+ cause: import_zod10.z.unknown().optional()
5082
5456
  });
5083
5457
  function extractBlockReason(cause) {
5084
5458
  let current = cause;
@@ -5199,7 +5573,7 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
5199
5573
  var googleImageAdapter = createGoogleImageAdapter();
5200
5574
 
5201
5575
  // src/adapters/higgsfield.ts
5202
- var import_zod10 = require("zod");
5576
+ var import_zod11 = require("zod");
5203
5577
 
5204
5578
  // src/adapters/higgsfield-motions.ts
5205
5579
  var MOTION_MAP = {
@@ -5387,14 +5761,14 @@ function videoUsage3(ctx, req, duration) {
5387
5761
  if (req.durationSeconds !== void 0) event.durationSeconds = req.durationSeconds;
5388
5762
  return event;
5389
5763
  }
5390
- var klingCreateSchema = import_zod10.z.object({ status_url: import_zod10.z.string() });
5391
- var klingStatusSchema = import_zod10.z.object({
5392
- status: import_zod10.z.string().optional(),
5393
- video: import_zod10.z.object({ url: import_zod10.z.string().optional() }).optional(),
5764
+ var klingCreateSchema = import_zod11.z.object({ status_url: import_zod11.z.string() });
5765
+ var klingStatusSchema = import_zod11.z.object({
5766
+ status: import_zod11.z.string().optional(),
5767
+ video: import_zod11.z.object({ url: import_zod11.z.string().optional() }).optional(),
5394
5768
  error: JsonValueSchema.optional()
5395
5769
  });
5396
- var errorMessageSchema = import_zod10.z.object({ message: import_zod10.z.string().optional() });
5397
- var textValueSchema = import_zod10.z.string();
5770
+ var errorMessageSchema = import_zod11.z.object({ message: import_zod11.z.string().optional() });
5771
+ var textValueSchema = import_zod11.z.string();
5398
5772
  function klingErrorDetail(error) {
5399
5773
  if (error === void 0) return "unknown_error";
5400
5774
  const asText = textValueSchema.safeParse(error);
@@ -5528,8 +5902,8 @@ async function generateKlingVideo(req, ctx) {
5528
5902
  }
5529
5903
  };
5530
5904
  }
5531
- var dopMotionOptionsSchema = import_zod10.z.object({
5532
- modelkit: import_zod10.z.object({ motion: import_zod10.z.string().optional() }).optional()
5905
+ var dopMotionOptionsSchema = import_zod11.z.object({
5906
+ modelkit: import_zod11.z.object({ motion: import_zod11.z.string().optional() }).optional()
5533
5907
  });
5534
5908
  function dopMotionId(ctx) {
5535
5909
  const parsed = dopMotionOptionsSchema.safeParse(ctx.model.providerOptions);
@@ -5545,7 +5919,7 @@ function dopMotionId(ctx) {
5545
5919
  });
5546
5920
  return id;
5547
5921
  }
5548
- var jsonRecordSchema = import_zod10.z.record(import_zod10.z.string(), JsonValueSchema);
5922
+ var jsonRecordSchema = import_zod11.z.record(import_zod11.z.string(), JsonValueSchema);
5549
5923
  var DOP_URL_KEYS = ["url", "video_url", "output_url", "result_url", "download_url"];
5550
5924
  var DOP_NESTED_KEYS = ["video", "result", "results"];
5551
5925
  function dopUrl(body) {
@@ -5573,8 +5947,8 @@ function dopUrl(body) {
5573
5947
  }
5574
5948
  return void 0;
5575
5949
  }
5576
- var dopCreateSchema = import_zod10.z.object({ id: import_zod10.z.string() });
5577
- var dopStatusSchema = import_zod10.z.object({ status: import_zod10.z.string().optional() });
5950
+ var dopCreateSchema = import_zod11.z.object({ id: import_zod11.z.string() });
5951
+ var dopStatusSchema = import_zod11.z.object({ status: import_zod11.z.string().optional() });
5578
5952
  async function generateDopVideo(req, ctx) {
5579
5953
  const firstFrame = req.firstFrame ? refToUrl(req.firstFrame) : void 0;
5580
5954
  if (!firstFrame) {
@@ -5694,7 +6068,7 @@ var higgsfieldAdapter = {
5694
6068
 
5695
6069
  // src/adapters/openai-image.ts
5696
6070
  var import_openai2 = __toESM(require("openai"), 1);
5697
- var import_zod11 = require("zod");
6071
+ var import_zod12 = require("zod");
5698
6072
  var MAX_EDIT_REFERENCES = 16;
5699
6073
  function aspectRatioToSize(ratio, tier) {
5700
6074
  const TIER_LONG_EDGE = {
@@ -5777,9 +6151,9 @@ function toProviderError2(cause, ctx) {
5777
6151
  ctx.model.id
5778
6152
  );
5779
6153
  }
5780
- var openaiUsageSchema = import_zod11.z.object({
5781
- input_tokens: import_zod11.z.number().optional(),
5782
- output_tokens: import_zod11.z.number().optional()
6154
+ var openaiUsageSchema = import_zod12.z.object({
6155
+ input_tokens: import_zod12.z.number().optional(),
6156
+ output_tokens: import_zod12.z.number().optional()
5783
6157
  });
5784
6158
  var openaiImageAdapter = {
5785
6159
  id: "openai-image",
@@ -6169,7 +6543,7 @@ var prodiaAdapter = {
6169
6543
 
6170
6544
  // src/adapters/replicate.ts
6171
6545
  var import_replicate = __toESM(require("replicate"), 1);
6172
- var import_zod12 = require("zod");
6546
+ var import_zod13 = require("zod");
6173
6547
  var POLL_INTERVAL_MS = 1e3;
6174
6548
  var POLL_TIMEOUT_MS = 15 * 6e4;
6175
6549
  var defaultReplicateDeps = {
@@ -6205,8 +6579,8 @@ function route(providerModelId) {
6205
6579
  if (!providerModelId.includes("/")) return { version: providerModelId };
6206
6580
  return { model: providerModelId };
6207
6581
  }
6208
- var replicateResponseStatusSchema = import_zod12.z.object({
6209
- response: import_zod12.z.object({ status: import_zod12.z.number() }).partial()
6582
+ var replicateResponseStatusSchema = import_zod13.z.object({
6583
+ response: import_zod13.z.object({ status: import_zod13.z.number() }).partial()
6210
6584
  });
6211
6585
  function replicateError(cause, ctx) {
6212
6586
  if (isModelKitError(cause)) return cause;
@@ -6233,7 +6607,7 @@ function isUrlFn(value) {
6233
6607
  function extractOutputUrl(output) {
6234
6608
  const root = Array.isArray(output) ? output[0] : output;
6235
6609
  if (root === void 0) throw noOutput();
6236
- const asString = import_zod12.z.string().safeParse(root);
6610
+ const asString = import_zod13.z.string().safeParse(root);
6237
6611
  if (asString.success && asString.data) return asString.data;
6238
6612
  if (root instanceof URL) return root.href;
6239
6613
  if (isObjectOutput(root)) {
@@ -6242,15 +6616,15 @@ function extractOutputUrl(output) {
6242
6616
  if (urlValue !== void 0 && isUrlFn(urlValue)) {
6243
6617
  const called = urlValue();
6244
6618
  if (called instanceof URL) return called.href;
6245
- const calledString = import_zod12.z.string().safeParse(called);
6619
+ const calledString = import_zod13.z.string().safeParse(called);
6246
6620
  if (calledString.success && calledString.data) return calledString.data;
6247
6621
  } else {
6248
- const direct = import_zod12.z.string().safeParse(urlValue);
6622
+ const direct = import_zod13.z.string().safeParse(urlValue);
6249
6623
  if (direct.success && direct.data) return direct.data;
6250
6624
  }
6251
6625
  }
6252
6626
  if ("default" in root) {
6253
- const fallback = import_zod12.z.string().safeParse(root.default);
6627
+ const fallback = import_zod13.z.string().safeParse(root.default);
6254
6628
  if (fallback.success && fallback.data) return fallback.data;
6255
6629
  }
6256
6630
  }
@@ -6311,7 +6685,7 @@ async function runPrediction(ctx, input, deps) {
6311
6685
  }
6312
6686
  return void 0;
6313
6687
  }, pollOpts);
6314
- const predictTime = import_zod12.z.number().safeParse(done.metrics?.predict_time);
6688
+ const predictTime = import_zod13.z.number().safeParse(done.metrics?.predict_time);
6315
6689
  if (done.output === void 0) throw noOutput();
6316
6690
  return {
6317
6691
  url: extractOutputUrl(done.output),
@@ -6654,7 +7028,7 @@ async function generateReplicateVideo(req, ctx, deps) {
6654
7028
  throw replicateError(cause, ctx);
6655
7029
  }
6656
7030
  if (current.status === "succeeded") {
6657
- const predictTime = import_zod12.z.number().safeParse(current.metrics?.predict_time);
7031
+ const predictTime = import_zod13.z.number().safeParse(current.metrics?.predict_time);
6658
7032
  if (current.output === void 0) throw noOutput();
6659
7033
  return {
6660
7034
  url: extractOutputUrl(current.output),
@@ -6786,7 +7160,7 @@ async function generateReplicateAudio(req, ctx, deps) {
6786
7160
  // src/adapters/xai-video.ts
6787
7161
  var import_ai4 = require("ai");
6788
7162
  var import_xai2 = require("@ai-sdk/xai");
6789
- var import_zod13 = require("zod");
7163
+ var import_zod14 = require("zod");
6790
7164
  var POLL_INTERVAL_MS2 = 1e4;
6791
7165
  var POLL_TIMEOUT_MS2 = 15 * 6e4;
6792
7166
  var defaultXaiDeps = {
@@ -6799,8 +7173,8 @@ function createXaiVideoAdapter(deps = defaultXaiDeps) {
6799
7173
  };
6800
7174
  }
6801
7175
  var xaiVideoAdapter = createXaiVideoAdapter();
6802
- var xaiResponseStatusSchema = import_zod13.z.object({
6803
- response: import_zod13.z.object({ status: import_zod13.z.number() }).partial()
7176
+ var xaiResponseStatusSchema = import_zod14.z.object({
7177
+ response: import_zod14.z.object({ status: import_zod14.z.number() }).partial()
6804
7178
  });
6805
7179
  function xaiError(cause, ctx) {
6806
7180
  const info = describeThrown(cause);
@@ -6808,12 +7182,12 @@ function xaiError(cause, ctx) {
6808
7182
  const status = info.status ?? (nested.success ? nested.data.response?.status : void 0);
6809
7183
  return classifyThrown("xai-video", cause, ctx.model.id, { status, body: info.body });
6810
7184
  }
6811
- var xaiMetaSchema = import_zod13.z.object({
7185
+ var xaiMetaSchema = import_zod14.z.object({
6812
7186
  videoUrl: JsonValueSchema.optional(),
6813
7187
  costInUsdTicks: JsonValueSchema.optional(),
6814
7188
  duration: JsonValueSchema.optional()
6815
7189
  });
6816
- var xaiProviderMetadataSchema = import_zod13.z.object({ xai: xaiMetaSchema });
7190
+ var xaiProviderMetadataSchema = import_zod14.z.object({ xai: xaiMetaSchema });
6817
7191
  function metaOf(result) {
6818
7192
  const parsed = xaiProviderMetadataSchema.partial().safeParse(result.providerMetadata);
6819
7193
  if (!parsed.success) return {};
@@ -6920,7 +7294,7 @@ async function mapResult(ctx, req, result) {
6920
7294
  };
6921
7295
  }
6922
7296
  const meta = metaOf(result);
6923
- const videoUrl = import_zod13.z.string().safeParse(meta.videoUrl);
7297
+ const videoUrl = import_zod14.z.string().safeParse(meta.videoUrl);
6924
7298
  if (videoUrl.success && videoUrl.data) {
6925
7299
  const res = await ctx.fetch(videoUrl.data);
6926
7300
  if (!res.ok) {
@@ -6943,7 +7317,7 @@ async function mapResult(ctx, req, result) {
6943
7317
  });
6944
7318
  }
6945
7319
  function usage(ctx, req, meta) {
6946
- const costTicks = import_zod13.z.number().safeParse(meta.costInUsdTicks);
7320
+ const costTicks = import_zod14.z.number().safeParse(meta.costInUsdTicks);
6947
7321
  const cost = costTicks.success ? costTicks.data / 1e10 : void 0;
6948
7322
  const event = {
6949
7323
  model: ctx.model.id,
@@ -6992,8 +7366,11 @@ var languageModel = (modelId, call) => createDefaultModelKit().languageModel(mod
6992
7366
  var describe = (modelId) => createDefaultModelKit().describe(modelId);
6993
7367
  // Annotate the CommonJS export names for ESM import in node:
6994
7368
  0 && (module.exports = {
7369
+ ADAPTER_IDS,
6995
7370
  ADAPTER_KEYS,
6996
7371
  Catalog,
7372
+ CatalogModelSchema,
7373
+ CatalogSchema,
6997
7374
  DEFAULT_ADAPTERS,
6998
7375
  JsonObjectSchema,
6999
7376
  JsonValueSchema,
@@ -7009,6 +7386,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
7009
7386
  describeThrown,
7010
7387
  experimental_generateImage,
7011
7388
  falAdapter,
7389
+ fileCatalogCache,
7012
7390
  generateAudio,
7013
7391
  generateImage,
7014
7392
  generateObject,
@@ -7020,15 +7398,18 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
7020
7398
  isModelKitError,
7021
7399
  keysFromEnv,
7022
7400
  languageModel,
7401
+ liveCatalog,
7023
7402
  mergeTextProviderOptions,
7024
7403
  nearestAspectRatio,
7025
7404
  openaiImageAdapter,
7026
7405
  passthroughTextModel,
7027
7406
  pollUntil,
7028
7407
  prepareMediaPart,
7408
+ primeCatalog,
7029
7409
  prodiaAdapter,
7030
7410
  readErrorBody,
7031
7411
  replicateAdapter,
7412
+ resetLiveCatalog,
7032
7413
  resolveAudioOptions,
7033
7414
  resolveImageOptions,
7034
7415
  resolveKeys,