@shop-os/modelkit 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +3 -3
- package/dist/catalog.cjs +210 -48
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +6 -3
- package/dist/catalog.d.ts +6 -3
- package/dist/catalog.js +210 -48
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +862 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +861 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -88,6 +88,7 @@ __export(index_exports, {
|
|
|
88
88
|
languageModel: () => languageModel,
|
|
89
89
|
liveCatalog: () => liveCatalog,
|
|
90
90
|
liveState: () => liveState,
|
|
91
|
+
lumaAdapter: () => lumaAdapter,
|
|
91
92
|
mergeTextProviderOptions: () => mergeTextProviderOptions,
|
|
92
93
|
missingTierKeys: () => missingTierKeys,
|
|
93
94
|
model3dCall: () => model3dCall,
|
|
@@ -510,8 +511,59 @@ var FAL_IMAGE_MODELS = [
|
|
|
510
511
|
}
|
|
511
512
|
];
|
|
512
513
|
|
|
513
|
-
// src/catalog/image.ts
|
|
514
|
+
// src/catalog/image-luma.ts
|
|
514
515
|
var IMAGE_USAGE2 = { unit: "images" };
|
|
516
|
+
var EXPOSURE2 = ["cowork", "space_builder"];
|
|
517
|
+
var LOBE2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light";
|
|
518
|
+
var LUMA_LOGO = `${LOBE2}/luma-color.png`;
|
|
519
|
+
var UNI_RATIOS = ["adaptive", "16:9", "3:2", "1:1", "2:3", "9:16"];
|
|
520
|
+
function uniImage(id, label, providerModelId, description) {
|
|
521
|
+
return {
|
|
522
|
+
// https://docs.agents.lumalabs.ai: type "image" without references, else
|
|
523
|
+
// "image_edit" with the first reference as source and up to 8 more as
|
|
524
|
+
// image_ref. The output is always 2048 px on the long side.
|
|
525
|
+
id,
|
|
526
|
+
aliases: [],
|
|
527
|
+
label,
|
|
528
|
+
type: "image",
|
|
529
|
+
adapter: "luma",
|
|
530
|
+
providerModelId,
|
|
531
|
+
lifecycle: "active",
|
|
532
|
+
exposure: EXPOSURE2,
|
|
533
|
+
constraints: {
|
|
534
|
+
aspectRatios: [...UNI_RATIOS],
|
|
535
|
+
sizes: ["2K"],
|
|
536
|
+
references: { images: 9 },
|
|
537
|
+
supports: ["outputFormat"],
|
|
538
|
+
prompt: { referenceSyntax: "numbered", maxChars: 6e3 }
|
|
539
|
+
},
|
|
540
|
+
defaults: { size: "2K", aspectRatio: "adaptive" },
|
|
541
|
+
usage: { ...IMAGE_USAGE2 },
|
|
542
|
+
pricingKind: "image_size",
|
|
543
|
+
display: {
|
|
544
|
+
provider: "luma",
|
|
545
|
+
description,
|
|
546
|
+
logo: LUMA_LOGO
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
var LUMA_IMAGE_MODELS = [
|
|
551
|
+
uniImage(
|
|
552
|
+
"uni-1",
|
|
553
|
+
"Uni-1",
|
|
554
|
+
"uni-1",
|
|
555
|
+
"Luma Uni-1 fast image generation and editing; takes a prompt and up to 9 reference images and outputs 2K."
|
|
556
|
+
),
|
|
557
|
+
uniImage(
|
|
558
|
+
"uni-1-max",
|
|
559
|
+
"Uni-1 Max",
|
|
560
|
+
"uni-1-max",
|
|
561
|
+
"Luma Uni-1 Max higher-quality image generation and editing; takes a prompt and up to 9 reference images and outputs 2K."
|
|
562
|
+
)
|
|
563
|
+
];
|
|
564
|
+
|
|
565
|
+
// src/catalog/image.ts
|
|
566
|
+
var IMAGE_USAGE3 = { unit: "images" };
|
|
515
567
|
var GEMINI_RATIOS = [
|
|
516
568
|
"1:1",
|
|
517
569
|
"2:3",
|
|
@@ -556,7 +608,7 @@ function geminiImage(id, label, aliases, sizes, display, exposure, references, p
|
|
|
556
608
|
exposure,
|
|
557
609
|
constraints,
|
|
558
610
|
defaults: { size: "1K", aspectRatio: "1:1" },
|
|
559
|
-
usage: { ...
|
|
611
|
+
usage: { ...IMAGE_USAGE3, slug: "gemini" },
|
|
560
612
|
pricingKind: "image_size",
|
|
561
613
|
display
|
|
562
614
|
};
|
|
@@ -669,7 +721,7 @@ var IMAGE_MODELS = [
|
|
|
669
721
|
prompt: GPT_IMAGE_PROMPT
|
|
670
722
|
},
|
|
671
723
|
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
672
|
-
usage: { ...
|
|
724
|
+
usage: { ...IMAGE_USAGE3, slug: "gpt" },
|
|
673
725
|
pricingKind: "image_size",
|
|
674
726
|
display: {
|
|
675
727
|
provider: "openai",
|
|
@@ -705,7 +757,7 @@ var IMAGE_MODELS = [
|
|
|
705
757
|
prompt: GPT_IMAGE_PROMPT
|
|
706
758
|
},
|
|
707
759
|
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
708
|
-
usage: { ...
|
|
760
|
+
usage: { ...IMAGE_USAGE3 },
|
|
709
761
|
pricingKind: "image_size",
|
|
710
762
|
display: {
|
|
711
763
|
provider: "openai",
|
|
@@ -740,7 +792,7 @@ var IMAGE_MODELS = [
|
|
|
740
792
|
prompt: GPT_IMAGE_PROMPT
|
|
741
793
|
},
|
|
742
794
|
defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
|
|
743
|
-
usage: { ...
|
|
795
|
+
usage: { ...IMAGE_USAGE3 },
|
|
744
796
|
pricingKind: "image_size",
|
|
745
797
|
display: {
|
|
746
798
|
provider: "openai",
|
|
@@ -775,7 +827,7 @@ var IMAGE_MODELS = [
|
|
|
775
827
|
supports: ["count", "outputFormat"]
|
|
776
828
|
},
|
|
777
829
|
defaults: { size: "1K", aspectRatio: "1:1", outputFormat: "png", count: 1 },
|
|
778
|
-
usage: { ...
|
|
830
|
+
usage: { ...IMAGE_USAGE3, slug: "muse" },
|
|
779
831
|
pricingKind: "image_size",
|
|
780
832
|
display: {
|
|
781
833
|
provider: "meta",
|
|
@@ -802,7 +854,7 @@ var IMAGE_MODELS = [
|
|
|
802
854
|
supports: ["quality", "count", "seed"]
|
|
803
855
|
},
|
|
804
856
|
defaults: { size: "2K", aspectRatio: "1:1", quality: "medium", count: 1 },
|
|
805
|
-
usage: { ...
|
|
857
|
+
usage: { ...IMAGE_USAGE3, slug: "ideogram" },
|
|
806
858
|
pricingKind: "image_size",
|
|
807
859
|
display: {
|
|
808
860
|
provider: "ideogram",
|
|
@@ -827,7 +879,7 @@ var IMAGE_MODELS = [
|
|
|
827
879
|
supports: ["seed", "outputFormat"]
|
|
828
880
|
},
|
|
829
881
|
defaults: { size: "1K", aspectRatio: "1:1" },
|
|
830
|
-
usage: { ...
|
|
882
|
+
usage: { ...IMAGE_USAGE3 },
|
|
831
883
|
pricingKind: "image_size",
|
|
832
884
|
display: {
|
|
833
885
|
provider: "bytedance",
|
|
@@ -865,7 +917,7 @@ var IMAGE_MODELS = [
|
|
|
865
917
|
supports: ["seed"]
|
|
866
918
|
},
|
|
867
919
|
defaults: { size: "1K", aspectRatio: "1:1" },
|
|
868
|
-
usage: { ...
|
|
920
|
+
usage: { ...IMAGE_USAGE3 },
|
|
869
921
|
pricingKind: "image_size",
|
|
870
922
|
display: {
|
|
871
923
|
provider: "bytedance",
|
|
@@ -891,7 +943,7 @@ var IMAGE_MODELS = [
|
|
|
891
943
|
prompt: { referenceSyntax: "numbered", maxChars: 32768 }
|
|
892
944
|
},
|
|
893
945
|
defaults: { size: "1K", aspectRatio: "1:1" },
|
|
894
|
-
usage: { ...
|
|
946
|
+
usage: { ...IMAGE_USAGE3 },
|
|
895
947
|
pricingKind: "image_size",
|
|
896
948
|
display: {
|
|
897
949
|
provider: "black-forest-labs",
|
|
@@ -918,7 +970,7 @@ var IMAGE_MODELS = [
|
|
|
918
970
|
supports: []
|
|
919
971
|
},
|
|
920
972
|
defaults: { size: "1K", aspectRatio: "1:1" },
|
|
921
|
-
usage: { ...
|
|
973
|
+
usage: { ...IMAGE_USAGE3 },
|
|
922
974
|
pricingKind: "image_size",
|
|
923
975
|
display: {
|
|
924
976
|
provider: "google",
|
|
@@ -943,7 +995,7 @@ var IMAGE_MODELS = [
|
|
|
943
995
|
supports: []
|
|
944
996
|
},
|
|
945
997
|
defaults: { size: "1K", aspectRatio: "1:1" },
|
|
946
|
-
usage: { ...
|
|
998
|
+
usage: { ...IMAGE_USAGE3 },
|
|
947
999
|
pricingKind: "image_size",
|
|
948
1000
|
display: {
|
|
949
1001
|
provider: "google",
|
|
@@ -1029,7 +1081,8 @@ var IMAGE_MODELS = [
|
|
|
1029
1081
|
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."
|
|
1030
1082
|
}
|
|
1031
1083
|
},
|
|
1032
|
-
...FAL_IMAGE_MODELS
|
|
1084
|
+
...FAL_IMAGE_MODELS,
|
|
1085
|
+
...LUMA_IMAGE_MODELS
|
|
1033
1086
|
];
|
|
1034
1087
|
|
|
1035
1088
|
// src/catalog/audio-formats.ts
|
|
@@ -1225,7 +1278,7 @@ var VEED_SUBTITLE_LANGUAGES = [
|
|
|
1225
1278
|
];
|
|
1226
1279
|
|
|
1227
1280
|
// src/catalog/canvas-tools.ts
|
|
1228
|
-
var
|
|
1281
|
+
var EXPOSURE3 = ["cowork", "space_builder"];
|
|
1229
1282
|
var META_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/characters/1787909065794-k9a7zz.png";
|
|
1230
1283
|
var VEED_SUBTITLE_PRESETS = [
|
|
1231
1284
|
"simple",
|
|
@@ -1267,7 +1320,7 @@ var SAM_3_IMAGE = {
|
|
|
1267
1320
|
adapter: "fal",
|
|
1268
1321
|
providerModelId: "fal-ai/sam-3/image",
|
|
1269
1322
|
lifecycle: "active",
|
|
1270
|
-
exposure:
|
|
1323
|
+
exposure: EXPOSURE3,
|
|
1271
1324
|
constraints: {
|
|
1272
1325
|
references: { images: 1 },
|
|
1273
1326
|
requires: ["references"],
|
|
@@ -1290,7 +1343,7 @@ var VEED_SUBTITLES = {
|
|
|
1290
1343
|
adapter: "fal",
|
|
1291
1344
|
providerModelId: "veed/subtitles",
|
|
1292
1345
|
lifecycle: "active",
|
|
1293
|
-
exposure:
|
|
1346
|
+
exposure: EXPOSURE3,
|
|
1294
1347
|
constraints: {
|
|
1295
1348
|
supports: [],
|
|
1296
1349
|
// fal: up to 2 hours at 1080p or below, 1 hour above.
|
|
@@ -3395,7 +3448,7 @@ var GOOGLE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a
|
|
|
3395
3448
|
var MINIMAX_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
3396
3449
|
var SYNC_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
3397
3450
|
var PER_CALL = { unit: "images" };
|
|
3398
|
-
var
|
|
3451
|
+
var EXPOSURE4 = ["cowork", "space_builder"];
|
|
3399
3452
|
var LIPSYNC_AUDIO = { audioSeconds: { max: 30 } };
|
|
3400
3453
|
function elevenLabsTts(tts) {
|
|
3401
3454
|
return {
|
|
@@ -3406,7 +3459,7 @@ function elevenLabsTts(tts) {
|
|
|
3406
3459
|
adapter: "fal",
|
|
3407
3460
|
providerModelId: tts.providerModelId,
|
|
3408
3461
|
lifecycle: "active",
|
|
3409
|
-
exposure:
|
|
3462
|
+
exposure: EXPOSURE4,
|
|
3410
3463
|
constraints: {
|
|
3411
3464
|
voices: ELEVENLABS_VOICES,
|
|
3412
3465
|
languages: tts.languages,
|
|
@@ -3431,7 +3484,7 @@ function geminiTts(id, label, description) {
|
|
|
3431
3484
|
adapter: "fal",
|
|
3432
3485
|
providerModelId,
|
|
3433
3486
|
lifecycle: "active",
|
|
3434
|
-
exposure:
|
|
3487
|
+
exposure: EXPOSURE4,
|
|
3435
3488
|
constraints: {
|
|
3436
3489
|
voices: GEMINI_TTS_VOICES,
|
|
3437
3490
|
supports: ["style"],
|
|
@@ -3454,7 +3507,7 @@ function syncLipsync(id, label, providerModelId, syncModel, description) {
|
|
|
3454
3507
|
adapter: "fal",
|
|
3455
3508
|
providerModelId,
|
|
3456
3509
|
lifecycle: "active",
|
|
3457
|
-
exposure:
|
|
3510
|
+
exposure: EXPOSURE4,
|
|
3458
3511
|
constraints: {
|
|
3459
3512
|
requires: ["sourceVideo", "sourceAudio"],
|
|
3460
3513
|
references: LIPSYNC_AUDIO,
|
|
@@ -3515,7 +3568,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3515
3568
|
adapter: "fal",
|
|
3516
3569
|
providerModelId: "fal-ai/minimax/speech-2.8-hd",
|
|
3517
3570
|
lifecycle: "active",
|
|
3518
|
-
exposure:
|
|
3571
|
+
exposure: EXPOSURE4,
|
|
3519
3572
|
constraints: {
|
|
3520
3573
|
voices: MINIMAX_VOICES,
|
|
3521
3574
|
languages: MINIMAX_SPEECH_LANGUAGES,
|
|
@@ -3540,7 +3593,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3540
3593
|
adapter: "fal",
|
|
3541
3594
|
providerModelId: "fal-ai/elevenlabs/voice-changer",
|
|
3542
3595
|
lifecycle: "active",
|
|
3543
|
-
exposure:
|
|
3596
|
+
exposure: EXPOSURE4,
|
|
3544
3597
|
constraints: {
|
|
3545
3598
|
requires: ["sourceAudio"],
|
|
3546
3599
|
// The flat price assumes at most a minute of speech.
|
|
@@ -3567,7 +3620,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3567
3620
|
adapter: "fal",
|
|
3568
3621
|
providerModelId: "fal-ai/elevenlabs/dubbing",
|
|
3569
3622
|
lifecycle: "active",
|
|
3570
|
-
exposure:
|
|
3623
|
+
exposure: EXPOSURE4,
|
|
3571
3624
|
constraints: {
|
|
3572
3625
|
requiresOneOf: ["sourceVideo", "sourceAudio"],
|
|
3573
3626
|
// The flat price covers 60 s of source.
|
|
@@ -3615,7 +3668,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3615
3668
|
adapter: "fal",
|
|
3616
3669
|
providerModelId: "veed/lipsync/v2",
|
|
3617
3670
|
lifecycle: "active",
|
|
3618
|
-
exposure:
|
|
3671
|
+
exposure: EXPOSURE4,
|
|
3619
3672
|
constraints: {
|
|
3620
3673
|
requires: ["sourceVideo", "sourceAudio"],
|
|
3621
3674
|
references: LIPSYNC_AUDIO,
|
|
@@ -3641,7 +3694,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3641
3694
|
adapter: "fal",
|
|
3642
3695
|
providerModelId: "minimax/h3-max/lip-sync/image-to-video",
|
|
3643
3696
|
lifecycle: "active",
|
|
3644
|
-
exposure:
|
|
3697
|
+
exposure: EXPOSURE4,
|
|
3645
3698
|
constraints: {
|
|
3646
3699
|
requires: ["firstFrame", "sourceAudio"],
|
|
3647
3700
|
resolutions: ["480p", "768p", "1080p", "2k"],
|
|
@@ -3667,7 +3720,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3667
3720
|
adapter: "fal",
|
|
3668
3721
|
providerModelId: "fal-ai/elevenlabs/speech-to-text/scribe-v2",
|
|
3669
3722
|
lifecycle: "active",
|
|
3670
|
-
exposure:
|
|
3723
|
+
exposure: EXPOSURE4,
|
|
3671
3724
|
constraints: {
|
|
3672
3725
|
requires: ["sourceAudio"],
|
|
3673
3726
|
// The flat price covers 10 minutes of audio.
|
|
@@ -5203,8 +5256,113 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5203
5256
|
}
|
|
5204
5257
|
];
|
|
5205
5258
|
|
|
5206
|
-
// src/catalog/video.ts
|
|
5259
|
+
// src/catalog/video-luma.ts
|
|
5207
5260
|
var VIDEO_USAGE2 = { unit: "seconds" };
|
|
5261
|
+
var EXPOSURE5 = ["cowork", "space_builder"];
|
|
5262
|
+
var LUMA_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/luma-color.png";
|
|
5263
|
+
var RAY_RATIOS = ["9:16", "3:4", "1:1", "4:3", "16:9", "21:9"];
|
|
5264
|
+
var RAY_RESOLUTIONS = ["360p", "720p", "1080p"];
|
|
5265
|
+
var RAY_PROMPT = { referenceSyntax: "numbered", maxChars: 6e3 };
|
|
5266
|
+
var LUMA_VIDEO_MODELS = [
|
|
5267
|
+
{
|
|
5268
|
+
// https://docs.agents.lumalabs.ai: type "video" with a fixed 5 s duration;
|
|
5269
|
+
// firstFrame and lastFrame ride as start_frame and end_frame.
|
|
5270
|
+
id: "ray-3.2",
|
|
5271
|
+
aliases: [],
|
|
5272
|
+
label: "Ray 3.2",
|
|
5273
|
+
type: "video",
|
|
5274
|
+
adapter: "luma",
|
|
5275
|
+
providerModelId: "ray-3.2",
|
|
5276
|
+
lifecycle: "active",
|
|
5277
|
+
exposure: EXPOSURE5,
|
|
5278
|
+
constraints: {
|
|
5279
|
+
aspectRatios: ["adaptive", ...RAY_RATIOS],
|
|
5280
|
+
resolutions: [...RAY_RESOLUTIONS],
|
|
5281
|
+
durations: [5],
|
|
5282
|
+
supports: ["lastFrame"],
|
|
5283
|
+
prompt: { ...RAY_PROMPT },
|
|
5284
|
+
audio: "never"
|
|
5285
|
+
},
|
|
5286
|
+
defaults: { durationSeconds: 5, resolution: "720p", aspectRatio: "adaptive" },
|
|
5287
|
+
usage: { ...VIDEO_USAGE2 },
|
|
5288
|
+
pricingKind: "video_per_second",
|
|
5289
|
+
display: {
|
|
5290
|
+
provider: "luma",
|
|
5291
|
+
description: "Luma Ray 3.2 text- and image-to-video with optional first and last frames, 5-second clips at up to 1080p.",
|
|
5292
|
+
logo: LUMA_LOGO2
|
|
5293
|
+
},
|
|
5294
|
+
capabilities: {}
|
|
5295
|
+
},
|
|
5296
|
+
{
|
|
5297
|
+
// https://docs.agents.lumalabs.ai: type "video_edit" with a source video of
|
|
5298
|
+
// up to 18 s; the output keeps the source length, so there is no durations
|
|
5299
|
+
// knob, no aspect_ratio and no end frame. Luma bills its 5 s price for any
|
|
5300
|
+
// source (live, 2026-10-21) and the row is priced per source second, so a
|
|
5301
|
+
// source under 5 s is refused: it would be billed below Luma's charge.
|
|
5302
|
+
id: "ray-3.2-edit",
|
|
5303
|
+
aliases: [],
|
|
5304
|
+
label: "Ray 3.2 Edit",
|
|
5305
|
+
type: "video",
|
|
5306
|
+
adapter: "luma",
|
|
5307
|
+
providerModelId: "ray-3.2",
|
|
5308
|
+
lifecycle: "active",
|
|
5309
|
+
exposure: EXPOSURE5,
|
|
5310
|
+
constraints: {
|
|
5311
|
+
resolutions: [...RAY_RESOLUTIONS],
|
|
5312
|
+
requires: ["sourceVideo"],
|
|
5313
|
+
sourceVideoSeconds: { min: 5, max: 18 },
|
|
5314
|
+
supports: [],
|
|
5315
|
+
prompt: { ...RAY_PROMPT },
|
|
5316
|
+
audio: "never"
|
|
5317
|
+
},
|
|
5318
|
+
defaults: { resolution: "720p" },
|
|
5319
|
+
usage: { ...VIDEO_USAGE2 },
|
|
5320
|
+
pricingKind: "video_per_second",
|
|
5321
|
+
display: {
|
|
5322
|
+
provider: "luma",
|
|
5323
|
+
description: "Luma Ray 3.2 video edit: changes a 5-18 second clip from a prompt, keeping its length.",
|
|
5324
|
+
logo: LUMA_LOGO2
|
|
5325
|
+
},
|
|
5326
|
+
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
5327
|
+
},
|
|
5328
|
+
{
|
|
5329
|
+
// https://docs.agents.lumalabs.ai: type "video_reframe" with a required
|
|
5330
|
+
// target aspect_ratio; the source is up to 10 s and the output keeps its
|
|
5331
|
+
// length whatever video.duration says, while Luma bills that duration
|
|
5332
|
+
// (live, 2026-10-21). So there is no durations knob, and a source under
|
|
5333
|
+
// 5 s is refused, as on ray-3.2-edit. 1080p is not offered for the
|
|
5334
|
+
// vertical targets 9:16 and 3:4.
|
|
5335
|
+
id: "ray-3.2-reframe",
|
|
5336
|
+
aliases: [],
|
|
5337
|
+
label: "Ray 3.2 Reframe",
|
|
5338
|
+
type: "video",
|
|
5339
|
+
adapter: "luma",
|
|
5340
|
+
providerModelId: "ray-3.2",
|
|
5341
|
+
lifecycle: "active",
|
|
5342
|
+
exposure: EXPOSURE5,
|
|
5343
|
+
constraints: {
|
|
5344
|
+
aspectRatios: [...RAY_RATIOS],
|
|
5345
|
+
resolutions: [...RAY_RESOLUTIONS],
|
|
5346
|
+
requires: ["sourceVideo"],
|
|
5347
|
+
sourceVideoSeconds: { min: 5, max: 10 },
|
|
5348
|
+
supports: [],
|
|
5349
|
+
prompt: { ...RAY_PROMPT },
|
|
5350
|
+
audio: "never"
|
|
5351
|
+
},
|
|
5352
|
+
defaults: { resolution: "720p", aspectRatio: "16:9" },
|
|
5353
|
+
usage: { ...VIDEO_USAGE2 },
|
|
5354
|
+
pricingKind: "video_per_second",
|
|
5355
|
+
display: {
|
|
5356
|
+
provider: "luma",
|
|
5357
|
+
description: "Luma Ray 3.2 Reframe: changes a 5-10 second clip to a new aspect ratio and fills the new area from the prompt.",
|
|
5358
|
+
logo: LUMA_LOGO2
|
|
5359
|
+
},
|
|
5360
|
+
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
5361
|
+
}
|
|
5362
|
+
];
|
|
5363
|
+
|
|
5364
|
+
// src/catalog/video.ts
|
|
5365
|
+
var VIDEO_USAGE3 = { unit: "seconds" };
|
|
5208
5366
|
var SEEDANCE_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16", "adaptive"];
|
|
5209
5367
|
var KLING_RATIOS2 = ["16:9", "9:16", "1:1", "adaptive"];
|
|
5210
5368
|
var KLING_OMNI_RATIOS = ["16:9", "9:16", "1:1"];
|
|
@@ -5257,7 +5415,7 @@ var VIDEO_MODELS = [
|
|
|
5257
5415
|
audio: "always"
|
|
5258
5416
|
},
|
|
5259
5417
|
defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
|
|
5260
|
-
usage: { ...
|
|
5418
|
+
usage: { ...VIDEO_USAGE3, slug: "veo" },
|
|
5261
5419
|
pricingKind: "video_per_second",
|
|
5262
5420
|
display: {
|
|
5263
5421
|
provider: "google",
|
|
@@ -5290,7 +5448,7 @@ var VIDEO_MODELS = [
|
|
|
5290
5448
|
audio: "always"
|
|
5291
5449
|
},
|
|
5292
5450
|
defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
|
|
5293
|
-
usage: { ...
|
|
5451
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5294
5452
|
pricingKind: "video_per_second",
|
|
5295
5453
|
display: {
|
|
5296
5454
|
provider: "google",
|
|
@@ -5320,7 +5478,7 @@ var VIDEO_MODELS = [
|
|
|
5320
5478
|
audio: "always"
|
|
5321
5479
|
},
|
|
5322
5480
|
defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
|
|
5323
|
-
usage: { ...
|
|
5481
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5324
5482
|
pricingKind: "video_per_second",
|
|
5325
5483
|
display: {
|
|
5326
5484
|
provider: "google",
|
|
@@ -5357,7 +5515,7 @@ var VIDEO_MODELS = [
|
|
|
5357
5515
|
audio: "always"
|
|
5358
5516
|
},
|
|
5359
5517
|
defaults: {},
|
|
5360
|
-
usage: { ...
|
|
5518
|
+
usage: { ...VIDEO_USAGE3, slug: "gemini_omni" },
|
|
5361
5519
|
pricingKind: "video_per_second",
|
|
5362
5520
|
display: {
|
|
5363
5521
|
provider: "google",
|
|
@@ -5394,7 +5552,7 @@ var VIDEO_MODELS = [
|
|
|
5394
5552
|
audio: "always"
|
|
5395
5553
|
},
|
|
5396
5554
|
defaults: {},
|
|
5397
|
-
usage: { ...
|
|
5555
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5398
5556
|
pricingKind: "video_per_second",
|
|
5399
5557
|
display: {
|
|
5400
5558
|
provider: "google",
|
|
@@ -5443,7 +5601,7 @@ var VIDEO_MODELS = [
|
|
|
5443
5601
|
aspectRatio: "16:9",
|
|
5444
5602
|
generateAudio: true
|
|
5445
5603
|
},
|
|
5446
|
-
usage: { ...
|
|
5604
|
+
usage: { ...VIDEO_USAGE3, slug: "seedance2", providerLabel: "byteplus" },
|
|
5447
5605
|
pricingKind: "video_per_second",
|
|
5448
5606
|
display: {
|
|
5449
5607
|
provider: "bytedance",
|
|
@@ -5486,7 +5644,7 @@ var VIDEO_MODELS = [
|
|
|
5486
5644
|
aspectRatio: "16:9",
|
|
5487
5645
|
generateAudio: true
|
|
5488
5646
|
},
|
|
5489
|
-
usage: { ...
|
|
5647
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5490
5648
|
pricingKind: "video_per_second",
|
|
5491
5649
|
display: {
|
|
5492
5650
|
provider: "bytedance",
|
|
@@ -5536,7 +5694,7 @@ var VIDEO_MODELS = [
|
|
|
5536
5694
|
aspectRatio: "16:9",
|
|
5537
5695
|
generateAudio: true
|
|
5538
5696
|
},
|
|
5539
|
-
usage: { ...
|
|
5697
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5540
5698
|
pricingKind: "video_per_second",
|
|
5541
5699
|
display: {
|
|
5542
5700
|
provider: "bytedance",
|
|
@@ -5598,7 +5756,7 @@ var VIDEO_MODELS = [
|
|
|
5598
5756
|
cfgScale: 0.5,
|
|
5599
5757
|
negativePrompt: NEGATIVE_PROMPT
|
|
5600
5758
|
},
|
|
5601
|
-
usage: { ...
|
|
5759
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5602
5760
|
pricingKind: "video_per_second",
|
|
5603
5761
|
display: {
|
|
5604
5762
|
provider: "kuaishou",
|
|
@@ -5630,7 +5788,7 @@ var VIDEO_MODELS = [
|
|
|
5630
5788
|
cfgScale: 0.5,
|
|
5631
5789
|
generateAudio: true
|
|
5632
5790
|
},
|
|
5633
|
-
usage: { ...
|
|
5791
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5634
5792
|
pricingKind: "video_per_second",
|
|
5635
5793
|
display: {
|
|
5636
5794
|
provider: "kuaishou",
|
|
@@ -5698,7 +5856,7 @@ var VIDEO_MODELS = [
|
|
|
5698
5856
|
aspectRatio: "16:9",
|
|
5699
5857
|
promptExpansion: "balanced"
|
|
5700
5858
|
},
|
|
5701
|
-
usage: { ...
|
|
5859
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5702
5860
|
pricingKind: "video_per_second",
|
|
5703
5861
|
display: {
|
|
5704
5862
|
provider: "minimax",
|
|
@@ -5732,7 +5890,7 @@ var VIDEO_MODELS = [
|
|
|
5732
5890
|
aspectRatio: "16:9",
|
|
5733
5891
|
promptExpansion: "balanced"
|
|
5734
5892
|
},
|
|
5735
|
-
usage: { ...
|
|
5893
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5736
5894
|
pricingKind: "video_per_second",
|
|
5737
5895
|
display: {
|
|
5738
5896
|
provider: "minimax",
|
|
@@ -5774,7 +5932,7 @@ var VIDEO_MODELS = [
|
|
|
5774
5932
|
aspectRatio: "adaptive",
|
|
5775
5933
|
promptExpansion: "balanced"
|
|
5776
5934
|
},
|
|
5777
|
-
usage: { ...
|
|
5935
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5778
5936
|
pricingKind: "video_per_second",
|
|
5779
5937
|
display: {
|
|
5780
5938
|
provider: "minimax",
|
|
@@ -5818,7 +5976,7 @@ var VIDEO_MODELS = [
|
|
|
5818
5976
|
aspectRatio: "adaptive",
|
|
5819
5977
|
promptExpansion: "balanced"
|
|
5820
5978
|
},
|
|
5821
|
-
usage: { ...
|
|
5979
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5822
5980
|
pricingKind: "video_per_second",
|
|
5823
5981
|
display: {
|
|
5824
5982
|
provider: "minimax",
|
|
@@ -5863,7 +6021,7 @@ var VIDEO_MODELS = [
|
|
|
5863
6021
|
aspectRatio: "adaptive",
|
|
5864
6022
|
generateAudio: true
|
|
5865
6023
|
},
|
|
5866
|
-
usage: { ...
|
|
6024
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5867
6025
|
pricingKind: "video_per_second",
|
|
5868
6026
|
display: {
|
|
5869
6027
|
provider: "alibaba",
|
|
@@ -5890,7 +6048,7 @@ var VIDEO_MODELS = [
|
|
|
5890
6048
|
audio: "never"
|
|
5891
6049
|
},
|
|
5892
6050
|
defaults: { durationSeconds: 5, aspectRatio: "16:9" },
|
|
5893
|
-
usage: { ...
|
|
6051
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5894
6052
|
pricingKind: "video_per_second",
|
|
5895
6053
|
display: {
|
|
5896
6054
|
provider: "kuaishou",
|
|
@@ -5939,7 +6097,7 @@ var VIDEO_MODELS = [
|
|
|
5939
6097
|
audio: "never"
|
|
5940
6098
|
},
|
|
5941
6099
|
defaults: {},
|
|
5942
|
-
usage: { ...
|
|
6100
|
+
usage: { ...VIDEO_USAGE3 },
|
|
5943
6101
|
// Higgsfield bills DoP per generation: a fixed-length clip with no duration knob.
|
|
5944
6102
|
pricingKind: "flat",
|
|
5945
6103
|
display: {
|
|
@@ -5948,7 +6106,8 @@ var VIDEO_MODELS = [
|
|
|
5948
6106
|
},
|
|
5949
6107
|
capabilities: {}
|
|
5950
6108
|
},
|
|
5951
|
-
...VIDEO_FAMILY_MODELS
|
|
6109
|
+
...VIDEO_FAMILY_MODELS,
|
|
6110
|
+
...LUMA_VIDEO_MODELS
|
|
5952
6111
|
];
|
|
5953
6112
|
|
|
5954
6113
|
// src/catalog/video-tools.ts
|
|
@@ -6114,14 +6273,17 @@ var VIDEO_TOOL_MODELS = [
|
|
|
6114
6273
|
{
|
|
6115
6274
|
// https://fal.ai/models/fal-ai/flashvsr/upscale/video/api: upscale_factor 1-4, X264 MP4
|
|
6116
6275
|
// by default; fal bills $0.0005 per output megapixel-frame (width x height x frames).
|
|
6276
|
+
// Retired (ENG-3314): the price rows tier by short edge, which under-prices square, wide
|
|
6277
|
+
// and above-4k outputs.
|
|
6117
6278
|
id: "flashvsr",
|
|
6118
6279
|
aliases: ["flashvsr-upscale"],
|
|
6119
6280
|
label: "FlashVSR",
|
|
6120
6281
|
type: "video-tool",
|
|
6121
6282
|
adapter: "fal",
|
|
6122
6283
|
providerModelId: "fal-ai/flashvsr/upscale/video",
|
|
6123
|
-
lifecycle: "
|
|
6124
|
-
|
|
6284
|
+
lifecycle: "retired",
|
|
6285
|
+
replacedBy: "flux-video-upscale-precise",
|
|
6286
|
+
exposure: [],
|
|
6125
6287
|
constraints: {
|
|
6126
6288
|
supports: [],
|
|
6127
6289
|
tool: { kind: "upscale", upscaleFactor: { min: 1, max: 4 } }
|
|
@@ -6922,7 +7084,8 @@ var ADAPTER_IDS = [
|
|
|
6922
7084
|
"replicate",
|
|
6923
7085
|
"prodia",
|
|
6924
7086
|
"higgsfield",
|
|
6925
|
-
"xai-video"
|
|
7087
|
+
"xai-video",
|
|
7088
|
+
"luma"
|
|
6926
7089
|
];
|
|
6927
7090
|
var ModelTypeSchema = import_zod3.z.enum([
|
|
6928
7091
|
"text",
|
|
@@ -13585,9 +13748,608 @@ var higgsfieldAdapter = {
|
|
|
13585
13748
|
}
|
|
13586
13749
|
};
|
|
13587
13750
|
|
|
13751
|
+
// src/adapters/luma.ts
|
|
13752
|
+
var import_zod25 = require("zod");
|
|
13753
|
+
|
|
13754
|
+
// src/adapters/mp4-duration.ts
|
|
13755
|
+
function mp4DurationSeconds(bytes) {
|
|
13756
|
+
const moov = findBox(bytes, 0, bytes.length, "moov");
|
|
13757
|
+
if (!moov) return void 0;
|
|
13758
|
+
const mvhd = findBox(bytes, moov.start + 8, moov.end, "mvhd");
|
|
13759
|
+
if (!mvhd) return void 0;
|
|
13760
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
13761
|
+
const size = mvhd.end - mvhd.start;
|
|
13762
|
+
if (size < 8 + 4) return void 0;
|
|
13763
|
+
const version = view.getUint8(mvhd.start + 8);
|
|
13764
|
+
if (version === 0) {
|
|
13765
|
+
if (size < 8 + 4 + 4 + 4 + 4 + 4) return void 0;
|
|
13766
|
+
const timescale = view.getUint32(mvhd.start + 8 + 4 + 4 + 4);
|
|
13767
|
+
const duration = view.getUint32(mvhd.start + 8 + 4 + 4 + 4 + 4);
|
|
13768
|
+
if (timescale === 0) return void 0;
|
|
13769
|
+
return duration / timescale;
|
|
13770
|
+
}
|
|
13771
|
+
if (version === 1) {
|
|
13772
|
+
if (size < 8 + 4 + 8 + 8 + 4 + 8) return void 0;
|
|
13773
|
+
const timescale = view.getUint32(mvhd.start + 8 + 4 + 8 + 8);
|
|
13774
|
+
const high = view.getUint32(mvhd.start + 8 + 4 + 8 + 8 + 4);
|
|
13775
|
+
const low = view.getUint32(mvhd.start + 8 + 4 + 8 + 8 + 4 + 4);
|
|
13776
|
+
if (timescale === 0) return void 0;
|
|
13777
|
+
return (high * 2 ** 32 + low) / timescale;
|
|
13778
|
+
}
|
|
13779
|
+
return void 0;
|
|
13780
|
+
}
|
|
13781
|
+
function findBox(bytes, from, to, type) {
|
|
13782
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
13783
|
+
let offset = from;
|
|
13784
|
+
while (offset + 8 <= to) {
|
|
13785
|
+
const size = view.getUint32(offset);
|
|
13786
|
+
const name = String.fromCharCode(
|
|
13787
|
+
view.getUint8(offset + 4),
|
|
13788
|
+
view.getUint8(offset + 5),
|
|
13789
|
+
view.getUint8(offset + 6),
|
|
13790
|
+
view.getUint8(offset + 7)
|
|
13791
|
+
);
|
|
13792
|
+
if (size < 8 || offset + size > to) return void 0;
|
|
13793
|
+
if (name === type) return { start: offset, end: offset + size };
|
|
13794
|
+
offset += size;
|
|
13795
|
+
}
|
|
13796
|
+
return void 0;
|
|
13797
|
+
}
|
|
13798
|
+
|
|
13799
|
+
// src/adapters/luma.ts
|
|
13800
|
+
var DEFAULT_BASE_URL = "https://agents.lumalabs.ai";
|
|
13801
|
+
var IMAGE_POLL_INTERVAL_MS = 3e3;
|
|
13802
|
+
var IMAGE_TIMEOUT_MS = 5 * 6e4;
|
|
13803
|
+
var VIDEO_POLL_INTERVAL_MS = 5e3;
|
|
13804
|
+
var VIDEO_TIMEOUT_MS = 20 * 6e4;
|
|
13805
|
+
var PROMPT_MAX_CHARS = 6e3;
|
|
13806
|
+
var LUMA_IMAGE_MODEL_IDS = /* @__PURE__ */ new Set(["uni-1", "uni-1-max"]);
|
|
13807
|
+
var LUMA_VIDEO_MODEL_ID = "ray-3.2";
|
|
13808
|
+
var LUMA_VIDEO_MODES = /* @__PURE__ */ new Map([
|
|
13809
|
+
["ray-3.2", "generate"],
|
|
13810
|
+
["ray-3.2-edit", "edit"],
|
|
13811
|
+
["ray-3.2-reframe", "reframe"]
|
|
13812
|
+
]);
|
|
13813
|
+
function lumaRowRefusal(row2) {
|
|
13814
|
+
const provider = row2.providerModelId.toLowerCase();
|
|
13815
|
+
if (row2.type === "image") {
|
|
13816
|
+
return LUMA_IMAGE_MODEL_IDS.has(provider) ? void 0 : "luma image rows need providerModelId uni-1 or uni-1-max";
|
|
13817
|
+
}
|
|
13818
|
+
if (row2.type === "video") {
|
|
13819
|
+
if (provider !== LUMA_VIDEO_MODEL_ID) return "luma video rows need providerModelId ray-3.2";
|
|
13820
|
+
return !LUMA_VIDEO_MODES.has(row2.id) ? `luma routes ray-3.2 rows by catalog id; it knows ${[...LUMA_VIDEO_MODES.keys()].join(", ")}` : void 0;
|
|
13821
|
+
}
|
|
13822
|
+
return `luma has no ${row2.type} rows`;
|
|
13823
|
+
}
|
|
13824
|
+
function lumaBase(ctx) {
|
|
13825
|
+
return ctx.endpoints?.luma ?? DEFAULT_BASE_URL;
|
|
13826
|
+
}
|
|
13827
|
+
function lumaKey(ctx) {
|
|
13828
|
+
const key = ctx.keys.luma;
|
|
13829
|
+
if (!key) {
|
|
13830
|
+
throw new ModelKitError({
|
|
13831
|
+
code: "auth",
|
|
13832
|
+
message: "Missing API key for luma",
|
|
13833
|
+
provider: "luma",
|
|
13834
|
+
model: ctx.model.id,
|
|
13835
|
+
retryable: false
|
|
13836
|
+
});
|
|
13837
|
+
}
|
|
13838
|
+
return key;
|
|
13839
|
+
}
|
|
13840
|
+
function checkPrompt(req, ctx) {
|
|
13841
|
+
const prompt = req.prompt.trim();
|
|
13842
|
+
if (prompt.length === 0) {
|
|
13843
|
+
throw new ModelKitError({
|
|
13844
|
+
code: "missing_input",
|
|
13845
|
+
message: `${ctx.model.id} needs a prompt`,
|
|
13846
|
+
provider: "luma",
|
|
13847
|
+
model: ctx.model.id,
|
|
13848
|
+
retryable: false
|
|
13849
|
+
});
|
|
13850
|
+
}
|
|
13851
|
+
if (req.prompt.length > PROMPT_MAX_CHARS) {
|
|
13852
|
+
throw new ModelKitError({
|
|
13853
|
+
code: "unsupported_option",
|
|
13854
|
+
message: `${ctx.model.id} takes a prompt of at most ${PROMPT_MAX_CHARS} characters`,
|
|
13855
|
+
provider: "luma",
|
|
13856
|
+
model: ctx.model.id,
|
|
13857
|
+
retryable: false
|
|
13858
|
+
});
|
|
13859
|
+
}
|
|
13860
|
+
return req.prompt;
|
|
13861
|
+
}
|
|
13862
|
+
function imageRef(ref) {
|
|
13863
|
+
if ("url" in ref) return { url: ref.url };
|
|
13864
|
+
return { data: mediaRefToBase64(ref.bytes), media_type: ref.mime };
|
|
13865
|
+
}
|
|
13866
|
+
function videoRef(ref) {
|
|
13867
|
+
if ("url" in ref) return { url: ref.url, media_type: "video/mp4" };
|
|
13868
|
+
const mediaType = ref.mime.startsWith("video/") ? ref.mime : "video/mp4";
|
|
13869
|
+
return { data: mediaRefToBase64(ref.bytes), media_type: mediaType };
|
|
13870
|
+
}
|
|
13871
|
+
function lumaOutputFormat(req, ctx) {
|
|
13872
|
+
const format = req.outputFormat;
|
|
13873
|
+
if (format === void 0 || format === "png" || format === "jpeg") return format;
|
|
13874
|
+
if ((ctx.call.onUnsupported ?? "error") === "error") {
|
|
13875
|
+
throw new ModelKitError({
|
|
13876
|
+
code: "unsupported_option",
|
|
13877
|
+
message: `${ctx.model.id} has no outputFormat "${format}". Supported: png, jpeg.`,
|
|
13878
|
+
provider: "luma",
|
|
13879
|
+
model: ctx.model.id,
|
|
13880
|
+
retryable: false
|
|
13881
|
+
});
|
|
13882
|
+
}
|
|
13883
|
+
ctx.warnings.push({
|
|
13884
|
+
code: "option_ignored",
|
|
13885
|
+
field: "outputFormat",
|
|
13886
|
+
from: format,
|
|
13887
|
+
to: "png",
|
|
13888
|
+
message: `${ctx.model.id} has no outputFormat "${format}"; using png`
|
|
13889
|
+
});
|
|
13890
|
+
return "png";
|
|
13891
|
+
}
|
|
13892
|
+
function refuseOrDrop(ctx, field, message) {
|
|
13893
|
+
if ((ctx.call.onUnsupported ?? "error") === "error") {
|
|
13894
|
+
throw new ModelKitError({
|
|
13895
|
+
code: "unsupported_option",
|
|
13896
|
+
message,
|
|
13897
|
+
provider: "luma",
|
|
13898
|
+
model: ctx.model.id,
|
|
13899
|
+
retryable: false
|
|
13900
|
+
});
|
|
13901
|
+
}
|
|
13902
|
+
ctx.warnings.push({ code: "option_ignored", field, message });
|
|
13903
|
+
}
|
|
13904
|
+
function lumaVideoMode(ctx) {
|
|
13905
|
+
const mode = LUMA_VIDEO_MODES.get(ctx.model.id);
|
|
13906
|
+
if (mode === void 0) {
|
|
13907
|
+
throw new ModelKitError({
|
|
13908
|
+
code: "unsupported_option",
|
|
13909
|
+
message: `luma routes ray-3.2 rows by catalog id; "${ctx.model.id}" is not a luma video row`,
|
|
13910
|
+
provider: "luma",
|
|
13911
|
+
model: ctx.model.id,
|
|
13912
|
+
retryable: false
|
|
13913
|
+
});
|
|
13914
|
+
}
|
|
13915
|
+
return mode;
|
|
13916
|
+
}
|
|
13917
|
+
function reframeTooTall(req) {
|
|
13918
|
+
const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
|
|
13919
|
+
return vertical && req.resolution === "1080p";
|
|
13920
|
+
}
|
|
13921
|
+
function sentResolution(req, mode) {
|
|
13922
|
+
return mode === "reframe" && reframeTooTall(req) ? "720p" : req.resolution;
|
|
13923
|
+
}
|
|
13924
|
+
function lumaReframeResolution(req, ctx) {
|
|
13925
|
+
const requested = req.resolution;
|
|
13926
|
+
if (requested === void 0 || !reframeTooTall(req)) return requested;
|
|
13927
|
+
const message = `${ctx.model.id} renders 9:16 and 3:4 reframes at up to 720p`;
|
|
13928
|
+
if ((ctx.call.onUnsupported ?? "error") === "error") {
|
|
13929
|
+
throw new ModelKitError({
|
|
13930
|
+
code: "unsupported_option",
|
|
13931
|
+
message,
|
|
13932
|
+
provider: "luma",
|
|
13933
|
+
model: ctx.model.id,
|
|
13934
|
+
retryable: false
|
|
13935
|
+
});
|
|
13936
|
+
}
|
|
13937
|
+
ctx.warnings.push({
|
|
13938
|
+
code: "resolution_coerced",
|
|
13939
|
+
field: "resolution",
|
|
13940
|
+
from: requested,
|
|
13941
|
+
to: "720p",
|
|
13942
|
+
message
|
|
13943
|
+
});
|
|
13944
|
+
return "720p";
|
|
13945
|
+
}
|
|
13946
|
+
var lumaGenerationSchema = import_zod25.z.looseObject({
|
|
13947
|
+
id: import_zod25.z.string(),
|
|
13948
|
+
state: import_zod25.z.string().optional(),
|
|
13949
|
+
output: import_zod25.z.array(
|
|
13950
|
+
import_zod25.z.looseObject({
|
|
13951
|
+
type: import_zod25.z.string().optional(),
|
|
13952
|
+
url: import_zod25.z.string().optional()
|
|
13953
|
+
})
|
|
13954
|
+
).optional(),
|
|
13955
|
+
failure_reason: import_zod25.z.string().optional().nullable(),
|
|
13956
|
+
failure_code: import_zod25.z.string().optional().nullable()
|
|
13957
|
+
});
|
|
13958
|
+
function lumaFailure(ctx, code, reason) {
|
|
13959
|
+
const detail = reason ?? code ?? "unknown_error";
|
|
13960
|
+
const message = `Luma generation failed: ${detail}`;
|
|
13961
|
+
switch (code) {
|
|
13962
|
+
case "content_moderated":
|
|
13963
|
+
return new ModelKitError({
|
|
13964
|
+
code: "content_blocked",
|
|
13965
|
+
message,
|
|
13966
|
+
provider: "luma",
|
|
13967
|
+
model: ctx.model.id,
|
|
13968
|
+
retryable: false
|
|
13969
|
+
});
|
|
13970
|
+
case "rate_limited":
|
|
13971
|
+
return new ModelKitError({
|
|
13972
|
+
code: "rate_limited",
|
|
13973
|
+
message,
|
|
13974
|
+
provider: "luma",
|
|
13975
|
+
model: ctx.model.id
|
|
13976
|
+
});
|
|
13977
|
+
case "generation_failed":
|
|
13978
|
+
case "output_not_found":
|
|
13979
|
+
return new ModelKitError({
|
|
13980
|
+
code: "provider_rejected",
|
|
13981
|
+
message,
|
|
13982
|
+
provider: "luma",
|
|
13983
|
+
model: ctx.model.id,
|
|
13984
|
+
retryable: true
|
|
13985
|
+
});
|
|
13986
|
+
case "budget_exhausted":
|
|
13987
|
+
return new ModelKitError({
|
|
13988
|
+
code: "provider_billing",
|
|
13989
|
+
message,
|
|
13990
|
+
provider: "luma",
|
|
13991
|
+
model: ctx.model.id,
|
|
13992
|
+
retryable: false
|
|
13993
|
+
});
|
|
13994
|
+
case "image_too_large":
|
|
13995
|
+
case "unsupported_format":
|
|
13996
|
+
return new ModelKitError({
|
|
13997
|
+
code: "unsupported_option",
|
|
13998
|
+
message,
|
|
13999
|
+
provider: "luma",
|
|
14000
|
+
model: ctx.model.id,
|
|
14001
|
+
retryable: false
|
|
14002
|
+
});
|
|
14003
|
+
default:
|
|
14004
|
+
return new ModelKitError({
|
|
14005
|
+
code: "provider_rejected",
|
|
14006
|
+
message,
|
|
14007
|
+
provider: "luma",
|
|
14008
|
+
model: ctx.model.id,
|
|
14009
|
+
retryable: false
|
|
14010
|
+
});
|
|
14011
|
+
}
|
|
14012
|
+
}
|
|
14013
|
+
function requestInit2(ctx, key, body) {
|
|
14014
|
+
const init = {
|
|
14015
|
+
method: body !== void 0 ? "POST" : "GET",
|
|
14016
|
+
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" }
|
|
14017
|
+
};
|
|
14018
|
+
if (body !== void 0) init.body = body;
|
|
14019
|
+
if (ctx.signal !== void 0) init.signal = ctx.signal;
|
|
14020
|
+
return init;
|
|
14021
|
+
}
|
|
14022
|
+
async function lumaRequest(ctx, url, body) {
|
|
14023
|
+
const key = lumaKey(ctx);
|
|
14024
|
+
let res;
|
|
14025
|
+
try {
|
|
14026
|
+
res = await ctx.fetch(url, requestInit2(ctx, key, body));
|
|
14027
|
+
} catch (cause) {
|
|
14028
|
+
throw classifyThrown("luma", cause, ctx.model.id);
|
|
14029
|
+
}
|
|
14030
|
+
if (!res.ok) {
|
|
14031
|
+
throw classifyHttpError(res.status, await readBody(res), "luma", ctx.model.id);
|
|
14032
|
+
}
|
|
14033
|
+
return res;
|
|
14034
|
+
}
|
|
14035
|
+
async function submitGeneration(ctx, body) {
|
|
14036
|
+
const retryOptions = mediaRetryOptions(ctx.call, ctx.signal);
|
|
14037
|
+
const res = await withRetry(
|
|
14038
|
+
() => lumaRequest(ctx, `${lumaBase(ctx)}/v1/generations`, JSON.stringify(body)),
|
|
14039
|
+
retryOptions
|
|
14040
|
+
);
|
|
14041
|
+
const parsed = lumaGenerationSchema.safeParse(await res.json());
|
|
14042
|
+
if (!parsed.success) {
|
|
14043
|
+
throw new ModelKitError({
|
|
14044
|
+
code: "provider_rejected",
|
|
14045
|
+
message: "Luma submit returned no generation id",
|
|
14046
|
+
provider: "luma",
|
|
14047
|
+
model: ctx.model.id,
|
|
14048
|
+
retryable: false
|
|
14049
|
+
});
|
|
14050
|
+
}
|
|
14051
|
+
return parsed.data;
|
|
14052
|
+
}
|
|
14053
|
+
async function readGeneration(ctx, id) {
|
|
14054
|
+
const res = await lumaRequest(ctx, `${lumaBase(ctx)}/v1/generations/${id}`);
|
|
14055
|
+
const payload = JsonValueSchema.parse(await res.json());
|
|
14056
|
+
const parsed = lumaGenerationSchema.safeParse(payload);
|
|
14057
|
+
if (!parsed.success) {
|
|
14058
|
+
throw new ModelKitError({
|
|
14059
|
+
code: "provider_rejected",
|
|
14060
|
+
message: "Luma returned an unreadable generation",
|
|
14061
|
+
provider: "luma",
|
|
14062
|
+
model: ctx.model.id,
|
|
14063
|
+
retryable: false
|
|
14064
|
+
});
|
|
14065
|
+
}
|
|
14066
|
+
return parsed.data;
|
|
14067
|
+
}
|
|
14068
|
+
function outputUrl(generation, type) {
|
|
14069
|
+
const outputs = generation.output ?? [];
|
|
14070
|
+
const match = outputs.find((item) => item.type === type && item.url);
|
|
14071
|
+
if (match?.url) return match.url;
|
|
14072
|
+
const fallback = outputs.find((item) => item.url);
|
|
14073
|
+
return fallback?.url;
|
|
14074
|
+
}
|
|
14075
|
+
async function readGenerationOnce(ctx, id) {
|
|
14076
|
+
try {
|
|
14077
|
+
return await readGeneration(ctx, id);
|
|
14078
|
+
} catch (cause) {
|
|
14079
|
+
if (ctx.call.maxRetries === 0) throw cause;
|
|
14080
|
+
if (isModelKitError(cause) && (cause.code === "network" || cause.status === 429 || (cause.status ?? 0) >= 500)) {
|
|
14081
|
+
return void 0;
|
|
14082
|
+
}
|
|
14083
|
+
throw cause;
|
|
14084
|
+
}
|
|
14085
|
+
}
|
|
14086
|
+
async function checkGeneration(ctx, id, type) {
|
|
14087
|
+
const generation = await readGenerationOnce(ctx, id);
|
|
14088
|
+
if (generation === void 0) return void 0;
|
|
14089
|
+
if (generation.state === "completed") {
|
|
14090
|
+
const url = outputUrl(generation, type);
|
|
14091
|
+
if (!url) {
|
|
14092
|
+
throw new ModelKitError({
|
|
14093
|
+
code: "provider_rejected",
|
|
14094
|
+
message: "Luma completed without an output URL",
|
|
14095
|
+
provider: "luma",
|
|
14096
|
+
model: ctx.model.id,
|
|
14097
|
+
retryable: false
|
|
14098
|
+
});
|
|
14099
|
+
}
|
|
14100
|
+
return url;
|
|
14101
|
+
}
|
|
14102
|
+
if (generation.state === "failed") {
|
|
14103
|
+
throw lumaFailure(
|
|
14104
|
+
ctx,
|
|
14105
|
+
generation.failure_code ?? void 0,
|
|
14106
|
+
generation.failure_reason ?? void 0
|
|
14107
|
+
);
|
|
14108
|
+
}
|
|
14109
|
+
return void 0;
|
|
14110
|
+
}
|
|
14111
|
+
async function downloadBytes(ctx, url, fallback) {
|
|
14112
|
+
let bytes;
|
|
14113
|
+
let header;
|
|
14114
|
+
try {
|
|
14115
|
+
const out = await mediaRefToBytes({ url }, ctx.fetch, {
|
|
14116
|
+
...ctx.signal !== void 0 && { signal: ctx.signal },
|
|
14117
|
+
provider: "luma",
|
|
14118
|
+
model: ctx.model.id
|
|
14119
|
+
});
|
|
14120
|
+
bytes = out.bytes;
|
|
14121
|
+
header = out.mime;
|
|
14122
|
+
} catch (cause) {
|
|
14123
|
+
throw classifyThrown("luma", cause, ctx.model.id);
|
|
14124
|
+
}
|
|
14125
|
+
const kind = fallback.split("/")[0];
|
|
14126
|
+
const usable = header !== void 0 && header.startsWith(`${kind}/`);
|
|
14127
|
+
return { bytes, mime: usable ? header : fallback };
|
|
14128
|
+
}
|
|
14129
|
+
function imageUsage2(ctx) {
|
|
14130
|
+
return {
|
|
14131
|
+
model: ctx.model.id,
|
|
14132
|
+
provider: "luma",
|
|
14133
|
+
modality: "IMAGE",
|
|
14134
|
+
unit: "images",
|
|
14135
|
+
quantity: 1,
|
|
14136
|
+
imageSize: "2K"
|
|
14137
|
+
};
|
|
14138
|
+
}
|
|
14139
|
+
var GENERATE_SECONDS = 5;
|
|
14140
|
+
var MAX_PLAUSIBLE_SECONDS = 60;
|
|
14141
|
+
function billedSeconds(req, mode, bytes) {
|
|
14142
|
+
if (mode === "generate") return GENERATE_SECONDS;
|
|
14143
|
+
const measured = mp4DurationSeconds(bytes);
|
|
14144
|
+
const source2 = req.sourceVideo;
|
|
14145
|
+
const length = measured !== void 0 && measured > 0 && measured <= MAX_PLAUSIBLE_SECONDS ? measured : source2 !== void 0 && "url" in source2 ? source2.durationSeconds : void 0;
|
|
14146
|
+
return Math.max(length ?? 0, GENERATE_SECONDS);
|
|
14147
|
+
}
|
|
14148
|
+
function videoUsage4(ctx, req, mode, bytes) {
|
|
14149
|
+
const seconds3 = billedSeconds(req, mode, bytes);
|
|
14150
|
+
const event = {
|
|
14151
|
+
model: ctx.model.id,
|
|
14152
|
+
provider: "luma",
|
|
14153
|
+
modality: "VIDEO",
|
|
14154
|
+
unit: "seconds",
|
|
14155
|
+
quantity: seconds3,
|
|
14156
|
+
durationSeconds: seconds3
|
|
14157
|
+
};
|
|
14158
|
+
const resolution = sentResolution(req, mode);
|
|
14159
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
14160
|
+
return event;
|
|
14161
|
+
}
|
|
14162
|
+
function imageBody(req, ctx, outputFormat) {
|
|
14163
|
+
const prompt = checkPrompt(req, ctx);
|
|
14164
|
+
const model = ctx.model.providerModelId;
|
|
14165
|
+
const ratio = req.aspectRatio !== "adaptive" ? req.aspectRatio : void 0;
|
|
14166
|
+
const [source2, ...rest] = req.references ?? [];
|
|
14167
|
+
if (source2 === void 0) {
|
|
14168
|
+
const body2 = { model, type: "image", prompt };
|
|
14169
|
+
if (ratio !== void 0) body2["aspect_ratio"] = ratio;
|
|
14170
|
+
if (outputFormat !== void 0) body2["output_format"] = outputFormat;
|
|
14171
|
+
return body2;
|
|
14172
|
+
}
|
|
14173
|
+
if (ratio !== void 0) {
|
|
14174
|
+
ctx.warnings.push({
|
|
14175
|
+
code: "option_ignored",
|
|
14176
|
+
field: "aspectRatio",
|
|
14177
|
+
message: `${ctx.model.id} keeps the source image's aspect ratio on an edit`
|
|
14178
|
+
});
|
|
14179
|
+
}
|
|
14180
|
+
const body = {
|
|
14181
|
+
model,
|
|
14182
|
+
type: "image_edit",
|
|
14183
|
+
prompt,
|
|
14184
|
+
source: imageRef(source2)
|
|
14185
|
+
};
|
|
14186
|
+
if (rest.length > 0) body["image_ref"] = rest.map(imageRef);
|
|
14187
|
+
if (outputFormat !== void 0) body["output_format"] = outputFormat;
|
|
14188
|
+
return body;
|
|
14189
|
+
}
|
|
14190
|
+
function videoBody(req, ctx, mode) {
|
|
14191
|
+
const prompt = checkPrompt(req, ctx);
|
|
14192
|
+
const model = ctx.model.providerModelId;
|
|
14193
|
+
const hasReferences = (req.referenceImages ?? []).length + (req.referenceVideos ?? []).length + (req.referenceAudios ?? []).length > 0;
|
|
14194
|
+
if (hasReferences) {
|
|
14195
|
+
refuseOrDrop(
|
|
14196
|
+
ctx,
|
|
14197
|
+
"referenceImages",
|
|
14198
|
+
`${ctx.model.id} takes no reference images, videos or audio`
|
|
14199
|
+
);
|
|
14200
|
+
}
|
|
14201
|
+
if (mode === "generate") {
|
|
14202
|
+
const body = {
|
|
14203
|
+
model,
|
|
14204
|
+
type: "video",
|
|
14205
|
+
prompt,
|
|
14206
|
+
video: {
|
|
14207
|
+
...req.resolution !== void 0 && { resolution: req.resolution },
|
|
14208
|
+
duration: "5s",
|
|
14209
|
+
...req.firstFrame !== void 0 && { start_frame: imageRef(req.firstFrame) },
|
|
14210
|
+
...req.lastFrame !== void 0 && { end_frame: imageRef(req.lastFrame) }
|
|
14211
|
+
}
|
|
14212
|
+
};
|
|
14213
|
+
if (req.aspectRatio !== void 0 && req.aspectRatio !== "adaptive") {
|
|
14214
|
+
body["aspect_ratio"] = req.aspectRatio;
|
|
14215
|
+
}
|
|
14216
|
+
return body;
|
|
14217
|
+
}
|
|
14218
|
+
const sourceVideo = req.sourceVideo;
|
|
14219
|
+
if (!sourceVideo) {
|
|
14220
|
+
throw new ModelKitError({
|
|
14221
|
+
code: "missing_input",
|
|
14222
|
+
message: `${ctx.model.id} requires sourceVideo`,
|
|
14223
|
+
provider: "luma",
|
|
14224
|
+
model: ctx.model.id,
|
|
14225
|
+
retryable: false
|
|
14226
|
+
});
|
|
14227
|
+
}
|
|
14228
|
+
if (mode === "edit") {
|
|
14229
|
+
if (req.lastFrame !== void 0) {
|
|
14230
|
+
refuseOrDrop(ctx, "lastFrame", `${ctx.model.id} takes no end frame`);
|
|
14231
|
+
}
|
|
14232
|
+
const body = {
|
|
14233
|
+
model,
|
|
14234
|
+
type: "video_edit",
|
|
14235
|
+
prompt,
|
|
14236
|
+
source: videoRef(sourceVideo),
|
|
14237
|
+
video: {
|
|
14238
|
+
...req.resolution !== void 0 && { resolution: req.resolution },
|
|
14239
|
+
...req.firstFrame !== void 0 && { start_frame: imageRef(req.firstFrame) },
|
|
14240
|
+
edit: { auto_controls: true }
|
|
14241
|
+
}
|
|
14242
|
+
};
|
|
14243
|
+
return body;
|
|
14244
|
+
}
|
|
14245
|
+
if (req.firstFrame !== void 0) {
|
|
14246
|
+
refuseOrDrop(ctx, "firstFrame", `${ctx.model.id} takes no start frame`);
|
|
14247
|
+
}
|
|
14248
|
+
if (req.lastFrame !== void 0) {
|
|
14249
|
+
refuseOrDrop(ctx, "lastFrame", `${ctx.model.id} takes no end frame`);
|
|
14250
|
+
}
|
|
14251
|
+
const aspectRatio = req.aspectRatio;
|
|
14252
|
+
if (aspectRatio === void 0 || aspectRatio === "adaptive") {
|
|
14253
|
+
throw new ModelKitError({
|
|
14254
|
+
code: "missing_input",
|
|
14255
|
+
message: `${ctx.model.id} needs an aspectRatio target`,
|
|
14256
|
+
provider: "luma",
|
|
14257
|
+
model: ctx.model.id,
|
|
14258
|
+
retryable: false
|
|
14259
|
+
});
|
|
14260
|
+
}
|
|
14261
|
+
const resolution = lumaReframeResolution(req, ctx);
|
|
14262
|
+
return {
|
|
14263
|
+
model,
|
|
14264
|
+
type: "video_reframe",
|
|
14265
|
+
prompt,
|
|
14266
|
+
aspect_ratio: aspectRatio,
|
|
14267
|
+
source: videoRef(sourceVideo),
|
|
14268
|
+
video: { ...resolution !== void 0 && { resolution } }
|
|
14269
|
+
};
|
|
14270
|
+
}
|
|
14271
|
+
async function generateLumaImage(req, ctx) {
|
|
14272
|
+
throwIfAborted(ctx.signal);
|
|
14273
|
+
lumaKey(ctx);
|
|
14274
|
+
if (!LUMA_IMAGE_MODEL_IDS.has(ctx.model.providerModelId.toLowerCase())) {
|
|
14275
|
+
throw new ModelKitError({
|
|
14276
|
+
code: "unsupported_option",
|
|
14277
|
+
message: `luma has no image mapping for "${ctx.model.providerModelId}"`,
|
|
14278
|
+
provider: "luma",
|
|
14279
|
+
model: ctx.model.id,
|
|
14280
|
+
retryable: false
|
|
14281
|
+
});
|
|
14282
|
+
}
|
|
14283
|
+
const format = lumaOutputFormat(req, ctx);
|
|
14284
|
+
const created = await submitGeneration(ctx, imageBody(req, ctx, format));
|
|
14285
|
+
const url = await pollUntil(checkGeneration.bind(null, ctx, created.id, "image"), {
|
|
14286
|
+
intervalMs: IMAGE_POLL_INTERVAL_MS,
|
|
14287
|
+
timeoutMs: IMAGE_TIMEOUT_MS,
|
|
14288
|
+
...ctx.signal !== void 0 && { signal: ctx.signal }
|
|
14289
|
+
});
|
|
14290
|
+
const image = await downloadBytes(ctx, url, format === "jpeg" ? "image/jpeg" : "image/png");
|
|
14291
|
+
return {
|
|
14292
|
+
images: [image],
|
|
14293
|
+
usage: imageUsage2(ctx),
|
|
14294
|
+
raw: created
|
|
14295
|
+
};
|
|
14296
|
+
}
|
|
14297
|
+
function lumaVideoJob(ctx, req, mode, id) {
|
|
14298
|
+
return {
|
|
14299
|
+
jobId: id,
|
|
14300
|
+
async poll() {
|
|
14301
|
+
const generation = await readGenerationOnce(ctx, id);
|
|
14302
|
+
if (generation?.state === "failed") return { status: "failed" };
|
|
14303
|
+
if (generation?.state === "completed") return { status: "succeeded" };
|
|
14304
|
+
return { status: "pending" };
|
|
14305
|
+
},
|
|
14306
|
+
async result(opts) {
|
|
14307
|
+
const signal = opts?.signal ?? ctx.signal;
|
|
14308
|
+
const url = await pollUntil(checkGeneration.bind(null, ctx, id, "video"), {
|
|
14309
|
+
intervalMs: opts?.pollIntervalMs ?? VIDEO_POLL_INTERVAL_MS,
|
|
14310
|
+
timeoutMs: opts?.timeoutMs ?? VIDEO_TIMEOUT_MS,
|
|
14311
|
+
...signal !== void 0 && { signal }
|
|
14312
|
+
});
|
|
14313
|
+
const video = await downloadBytes(ctx, url, "video/mp4");
|
|
14314
|
+
const result = {
|
|
14315
|
+
video,
|
|
14316
|
+
usage: videoUsage4(ctx, req, mode, video.bytes),
|
|
14317
|
+
raw: { id }
|
|
14318
|
+
};
|
|
14319
|
+
return result;
|
|
14320
|
+
}
|
|
14321
|
+
};
|
|
14322
|
+
}
|
|
14323
|
+
async function generateLumaVideo(req, ctx) {
|
|
14324
|
+
throwIfAborted(ctx.signal);
|
|
14325
|
+
lumaKey(ctx);
|
|
14326
|
+
if (ctx.model.providerModelId.toLowerCase() !== LUMA_VIDEO_MODEL_ID) {
|
|
14327
|
+
throw new ModelKitError({
|
|
14328
|
+
code: "unsupported_option",
|
|
14329
|
+
message: `luma has no video mapping for "${ctx.model.providerModelId}"`,
|
|
14330
|
+
provider: "luma",
|
|
14331
|
+
model: ctx.model.id,
|
|
14332
|
+
retryable: false
|
|
14333
|
+
});
|
|
14334
|
+
}
|
|
14335
|
+
const mode = lumaVideoMode(ctx);
|
|
14336
|
+
const created = await submitGeneration(ctx, videoBody(req, ctx, mode));
|
|
14337
|
+
return lumaVideoJob(ctx, req, mode, created.id);
|
|
14338
|
+
}
|
|
14339
|
+
var lumaAdapter = {
|
|
14340
|
+
id: "luma",
|
|
14341
|
+
generateImage: generateLumaImage,
|
|
14342
|
+
generateVideo: generateLumaVideo,
|
|
14343
|
+
resumeVideo: (req, jobId, ctx) => {
|
|
14344
|
+
throwIfAborted(ctx.signal);
|
|
14345
|
+
lumaKey(ctx);
|
|
14346
|
+
return lumaVideoJob(ctx, req, lumaVideoMode(ctx), jobId);
|
|
14347
|
+
}
|
|
14348
|
+
};
|
|
14349
|
+
|
|
13588
14350
|
// src/adapters/openai-image.ts
|
|
13589
14351
|
var import_openai2 = __toESM(require("openai"), 1);
|
|
13590
|
-
var
|
|
14352
|
+
var import_zod26 = require("zod");
|
|
13591
14353
|
var MAX_EDIT_REFERENCES = 16;
|
|
13592
14354
|
function aspectRatioToSize(ratio, tier) {
|
|
13593
14355
|
const TIER_LONG_EDGE = {
|
|
@@ -13670,9 +14432,9 @@ function toProviderError2(cause, ctx) {
|
|
|
13670
14432
|
ctx.model.id
|
|
13671
14433
|
);
|
|
13672
14434
|
}
|
|
13673
|
-
var openaiUsageSchema =
|
|
13674
|
-
input_tokens:
|
|
13675
|
-
output_tokens:
|
|
14435
|
+
var openaiUsageSchema = import_zod26.z.object({
|
|
14436
|
+
input_tokens: import_zod26.z.number().optional(),
|
|
14437
|
+
output_tokens: import_zod26.z.number().optional()
|
|
13676
14438
|
});
|
|
13677
14439
|
var openaiImageAdapter = {
|
|
13678
14440
|
id: "openai-image",
|
|
@@ -14084,13 +14846,13 @@ var prodiaAdapter = {
|
|
|
14084
14846
|
var import_replicate = __toESM(require("replicate"), 1);
|
|
14085
14847
|
|
|
14086
14848
|
// src/adapters/replicate-http.ts
|
|
14087
|
-
var
|
|
14088
|
-
var predictionSchema =
|
|
14089
|
-
id:
|
|
14090
|
-
status:
|
|
14849
|
+
var import_zod27 = require("zod");
|
|
14850
|
+
var predictionSchema = import_zod27.z.object({
|
|
14851
|
+
id: import_zod27.z.string(),
|
|
14852
|
+
status: import_zod27.z.string(),
|
|
14091
14853
|
output: JsonValueSchema.optional(),
|
|
14092
14854
|
error: JsonValueSchema.optional(),
|
|
14093
|
-
metrics:
|
|
14855
|
+
metrics: import_zod27.z.object({ predict_time: import_zod27.z.number().optional() }).optional()
|
|
14094
14856
|
});
|
|
14095
14857
|
function createReplicateHttpClient(opts) {
|
|
14096
14858
|
async function request(path, body, signal) {
|
|
@@ -14141,7 +14903,7 @@ function createReplicateHttpClient(opts) {
|
|
|
14141
14903
|
}
|
|
14142
14904
|
|
|
14143
14905
|
// src/adapters/replicate.ts
|
|
14144
|
-
var
|
|
14906
|
+
var import_zod28 = require("zod");
|
|
14145
14907
|
var POLL_INTERVAL_MS = 1e3;
|
|
14146
14908
|
var POLL_TIMEOUT_MS = 15 * 6e4;
|
|
14147
14909
|
var defaultReplicateDeps = {
|
|
@@ -14181,8 +14943,8 @@ function route(providerModelId) {
|
|
|
14181
14943
|
if (!providerModelId.includes("/")) return { version: providerModelId };
|
|
14182
14944
|
return { model: providerModelId };
|
|
14183
14945
|
}
|
|
14184
|
-
var replicateResponseStatusSchema =
|
|
14185
|
-
response:
|
|
14946
|
+
var replicateResponseStatusSchema = import_zod28.z.object({
|
|
14947
|
+
response: import_zod28.z.object({ status: import_zod28.z.number() }).partial()
|
|
14186
14948
|
});
|
|
14187
14949
|
function replicateError(cause, ctx) {
|
|
14188
14950
|
if (isModelKitError(cause)) return cause;
|
|
@@ -14205,7 +14967,7 @@ function isUrlFn(value) {
|
|
|
14205
14967
|
function extractOutputUrl(output) {
|
|
14206
14968
|
const root = Array.isArray(output) ? output[0] : output;
|
|
14207
14969
|
if (root === void 0) throw noOutput();
|
|
14208
|
-
const asString =
|
|
14970
|
+
const asString = import_zod28.z.string().safeParse(root);
|
|
14209
14971
|
if (asString.success && asString.data) return asString.data;
|
|
14210
14972
|
if (root instanceof URL) return root.href;
|
|
14211
14973
|
if (isObjectOutput(root)) {
|
|
@@ -14214,15 +14976,15 @@ function extractOutputUrl(output) {
|
|
|
14214
14976
|
if (urlValue !== void 0 && isUrlFn(urlValue)) {
|
|
14215
14977
|
const called = urlValue();
|
|
14216
14978
|
if (called instanceof URL) return called.href;
|
|
14217
|
-
const calledString =
|
|
14979
|
+
const calledString = import_zod28.z.string().safeParse(called);
|
|
14218
14980
|
if (calledString.success && calledString.data) return calledString.data;
|
|
14219
14981
|
} else {
|
|
14220
|
-
const direct =
|
|
14982
|
+
const direct = import_zod28.z.string().safeParse(urlValue);
|
|
14221
14983
|
if (direct.success && direct.data) return direct.data;
|
|
14222
14984
|
}
|
|
14223
14985
|
}
|
|
14224
14986
|
if ("default" in root) {
|
|
14225
|
-
const fallback =
|
|
14987
|
+
const fallback = import_zod28.z.string().safeParse(root.default);
|
|
14226
14988
|
if (fallback.success && fallback.data) return fallback.data;
|
|
14227
14989
|
}
|
|
14228
14990
|
}
|
|
@@ -14283,7 +15045,7 @@ async function runPrediction(ctx, input, deps) {
|
|
|
14283
15045
|
}
|
|
14284
15046
|
return void 0;
|
|
14285
15047
|
}, pollOpts);
|
|
14286
|
-
const predictTime =
|
|
15048
|
+
const predictTime = import_zod28.z.number().safeParse(done.metrics?.predict_time);
|
|
14287
15049
|
if (done.output === void 0) throw noOutput();
|
|
14288
15050
|
return {
|
|
14289
15051
|
url: extractOutputUrl(done.output),
|
|
@@ -14291,7 +15053,7 @@ async function runPrediction(ctx, input, deps) {
|
|
|
14291
15053
|
raw: done
|
|
14292
15054
|
};
|
|
14293
15055
|
}
|
|
14294
|
-
function
|
|
15056
|
+
function imageUsage3(ctx, req) {
|
|
14295
15057
|
const event = {
|
|
14296
15058
|
model: ctx.model.id,
|
|
14297
15059
|
provider: "replicate",
|
|
@@ -14303,7 +15065,7 @@ function imageUsage2(ctx, req) {
|
|
|
14303
15065
|
if (req.quality !== void 0) event.imageQuality = req.quality;
|
|
14304
15066
|
return event;
|
|
14305
15067
|
}
|
|
14306
|
-
function
|
|
15068
|
+
function videoUsage5(ctx, req) {
|
|
14307
15069
|
const event = {
|
|
14308
15070
|
model: ctx.model.id,
|
|
14309
15071
|
provider: "replicate",
|
|
@@ -14529,7 +15291,7 @@ async function generateReplicateImage(req, ctx, deps) {
|
|
|
14529
15291
|
}
|
|
14530
15292
|
const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
|
|
14531
15293
|
const file = await download(ctx, url);
|
|
14532
|
-
const usage3 =
|
|
15294
|
+
const usage3 = imageUsage3(ctx, req);
|
|
14533
15295
|
usage3.quantity = predictTime;
|
|
14534
15296
|
return { images: [{ bytes: file.bytes, mime: file.mime }], usage: usage3, raw, outputUrl: url };
|
|
14535
15297
|
}
|
|
@@ -14636,7 +15398,7 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
14636
15398
|
throw replicateError(cause, ctx);
|
|
14637
15399
|
}
|
|
14638
15400
|
if (current.status === "succeeded") {
|
|
14639
|
-
const predictTime =
|
|
15401
|
+
const predictTime = import_zod28.z.number().safeParse(current.metrics?.predict_time);
|
|
14640
15402
|
if (current.output === void 0) throw noOutput();
|
|
14641
15403
|
return {
|
|
14642
15404
|
url: extractOutputUrl(current.output),
|
|
@@ -14655,7 +15417,7 @@ async function generateReplicateVideo(req, ctx, deps) {
|
|
|
14655
15417
|
return void 0;
|
|
14656
15418
|
};
|
|
14657
15419
|
const toResult = (done) => {
|
|
14658
|
-
const usage3 =
|
|
15420
|
+
const usage3 = videoUsage5(ctx, req);
|
|
14659
15421
|
usage3.quantity = done.predictTime;
|
|
14660
15422
|
return { video: { url: done.url }, usage: usage3, raw: done.raw };
|
|
14661
15423
|
};
|
|
@@ -14778,7 +15540,7 @@ async function generateReplicateAudio(req, ctx, deps) {
|
|
|
14778
15540
|
// src/adapters/xai-video.ts
|
|
14779
15541
|
var import_ai3 = require("ai");
|
|
14780
15542
|
var import_xai2 = require("@ai-sdk/xai");
|
|
14781
|
-
var
|
|
15543
|
+
var import_zod29 = require("zod");
|
|
14782
15544
|
var POLL_INTERVAL_MS2 = 1e4;
|
|
14783
15545
|
var POLL_TIMEOUT_MS2 = 15 * 6e4;
|
|
14784
15546
|
var defaultXaiDeps = {
|
|
@@ -14791,8 +15553,8 @@ function createXaiVideoAdapter(deps = defaultXaiDeps) {
|
|
|
14791
15553
|
};
|
|
14792
15554
|
}
|
|
14793
15555
|
var xaiVideoAdapter = createXaiVideoAdapter();
|
|
14794
|
-
var xaiResponseStatusSchema =
|
|
14795
|
-
response:
|
|
15556
|
+
var xaiResponseStatusSchema = import_zod29.z.object({
|
|
15557
|
+
response: import_zod29.z.object({ status: import_zod29.z.number() }).partial()
|
|
14796
15558
|
});
|
|
14797
15559
|
function xaiError(cause, ctx) {
|
|
14798
15560
|
const info = describeThrown(cause);
|
|
@@ -14800,12 +15562,12 @@ function xaiError(cause, ctx) {
|
|
|
14800
15562
|
const status = info.status ?? (nested.success ? nested.data.response?.status : void 0);
|
|
14801
15563
|
return classifyThrown("xai-video", cause, ctx.model.id, { status, body: info.body });
|
|
14802
15564
|
}
|
|
14803
|
-
var xaiMetaSchema =
|
|
15565
|
+
var xaiMetaSchema = import_zod29.z.object({
|
|
14804
15566
|
videoUrl: JsonValueSchema.optional(),
|
|
14805
15567
|
costInUsdTicks: JsonValueSchema.optional(),
|
|
14806
15568
|
duration: JsonValueSchema.optional()
|
|
14807
15569
|
});
|
|
14808
|
-
var xaiProviderMetadataSchema =
|
|
15570
|
+
var xaiProviderMetadataSchema = import_zod29.z.object({ xai: xaiMetaSchema });
|
|
14809
15571
|
function metaOf(result) {
|
|
14810
15572
|
const parsed = xaiProviderMetadataSchema.partial().safeParse(result.providerMetadata);
|
|
14811
15573
|
if (!parsed.success) return {};
|
|
@@ -14921,7 +15683,7 @@ async function mapResult(ctx, req, result) {
|
|
|
14921
15683
|
};
|
|
14922
15684
|
}
|
|
14923
15685
|
const meta = metaOf(result);
|
|
14924
|
-
const videoUrl =
|
|
15686
|
+
const videoUrl = import_zod29.z.string().safeParse(meta.videoUrl);
|
|
14925
15687
|
if (videoUrl.success && videoUrl.data) {
|
|
14926
15688
|
const res = await ctx.fetch(videoUrl.data);
|
|
14927
15689
|
if (!res.ok) {
|
|
@@ -14944,7 +15706,7 @@ async function mapResult(ctx, req, result) {
|
|
|
14944
15706
|
});
|
|
14945
15707
|
}
|
|
14946
15708
|
function usage2(ctx, req, meta) {
|
|
14947
|
-
const costTicks =
|
|
15709
|
+
const costTicks = import_zod29.z.number().safeParse(meta.costInUsdTicks);
|
|
14948
15710
|
const cost = costTicks.success ? costTicks.data / 1e10 : void 0;
|
|
14949
15711
|
const event = {
|
|
14950
15712
|
model: ctx.model.id,
|
|
@@ -14992,7 +15754,8 @@ var DEFAULT_ADAPTERS = {
|
|
|
14992
15754
|
replicate: replicateAdapter,
|
|
14993
15755
|
prodia: prodiaAdapter,
|
|
14994
15756
|
higgsfield: higgsfieldAdapter,
|
|
14995
|
-
"xai-video": xaiVideoAdapter
|
|
15757
|
+
"xai-video": xaiVideoAdapter,
|
|
15758
|
+
luma: lumaAdapter
|
|
14996
15759
|
};
|
|
14997
15760
|
|
|
14998
15761
|
// src/catalog/data-only.ts
|
|
@@ -15108,6 +15871,10 @@ function dataOnlyCapable(row2) {
|
|
|
15108
15871
|
reason: "higgsfield providerModelId must be a platform path, not a URL"
|
|
15109
15872
|
};
|
|
15110
15873
|
}
|
|
15874
|
+
case "luma": {
|
|
15875
|
+
const reason = lumaRowRefusal(row2);
|
|
15876
|
+
return reason === void 0 ? { ok: true } : { ok: false, reason };
|
|
15877
|
+
}
|
|
15111
15878
|
default: {
|
|
15112
15879
|
return assertNever(row2.adapter);
|
|
15113
15880
|
}
|
|
@@ -15127,22 +15894,22 @@ var liveState = store[KEY] ??= {
|
|
|
15127
15894
|
var liveCatalog = liveState.catalog;
|
|
15128
15895
|
|
|
15129
15896
|
// src/catalog/load.ts
|
|
15130
|
-
var
|
|
15897
|
+
var import_zod30 = require("zod");
|
|
15131
15898
|
function rowCount() {
|
|
15132
15899
|
return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
|
|
15133
15900
|
}
|
|
15134
15901
|
function authHeaders(auth) {
|
|
15135
15902
|
return "bearer" in auth ? { Authorization: `Bearer ${auth.bearer}` } : { "x-api-key": auth.apiKey };
|
|
15136
15903
|
}
|
|
15137
|
-
var EnvelopeSchema =
|
|
15138
|
-
rows:
|
|
15139
|
-
revision:
|
|
15904
|
+
var EnvelopeSchema = import_zod30.z.object({
|
|
15905
|
+
rows: import_zod30.z.array(JsonValueSchema),
|
|
15906
|
+
revision: import_zod30.z.string().optional()
|
|
15140
15907
|
});
|
|
15141
15908
|
function dropReason(path, message) {
|
|
15142
15909
|
return path.length === 0 ? message : `${path.map((part) => String(part)).join(".")} ${message}`;
|
|
15143
15910
|
}
|
|
15144
15911
|
function rowId(raw) {
|
|
15145
|
-
const parsed =
|
|
15912
|
+
const parsed = import_zod30.z.object({ id: import_zod30.z.string().min(1) }).loose().safeParse(raw);
|
|
15146
15913
|
if (!parsed.success) return "?";
|
|
15147
15914
|
return parsed.data.id;
|
|
15148
15915
|
}
|
|
@@ -16191,7 +16958,8 @@ var ADAPTER_KEYS = {
|
|
|
16191
16958
|
replicate: ["replicate"],
|
|
16192
16959
|
prodia: ["prodia"],
|
|
16193
16960
|
higgsfield: ["higgsfield"],
|
|
16194
|
-
"xai-video": ["xai"]
|
|
16961
|
+
"xai-video": ["xai"],
|
|
16962
|
+
luma: ["luma"]
|
|
16195
16963
|
};
|
|
16196
16964
|
function hasAll(keys, names) {
|
|
16197
16965
|
if (!keys) return false;
|
|
@@ -16249,6 +17017,7 @@ function keysFromEnv(env, prefix = "") {
|
|
|
16249
17017
|
set("prodia", pick2("PRODIA_API_KEY", "PRODIA_TOKEN"));
|
|
16250
17018
|
set("higgsfield", pick2("HIGGSFIELD_API_KEY"));
|
|
16251
17019
|
set("higgsfieldSecret", pick2("HIGGSFIELD_API_SECRET"));
|
|
17020
|
+
set("luma", pick2("LUMA_API_KEY", "LUMA_AGENTS_API_KEY"));
|
|
16252
17021
|
set("cloudflare", pick2("CLOUDFLARE_AI_GATEWAY_TOKEN", "CF_AIG_TOKEN"));
|
|
16253
17022
|
const bearer = pick2("AWS_BEARER_TOKEN_BEDROCK");
|
|
16254
17023
|
const accessKeyId = pick2("AWS_ACCESS_KEY_ID");
|
|
@@ -16271,7 +17040,7 @@ function keysFromEnv(env, prefix = "") {
|
|
|
16271
17040
|
|
|
16272
17041
|
// src/text.ts
|
|
16273
17042
|
var import_ai4 = require("ai");
|
|
16274
|
-
var
|
|
17043
|
+
var import_zod31 = require("zod");
|
|
16275
17044
|
function mergeTextProviderOptions(catalog, caller) {
|
|
16276
17045
|
const merged = {};
|
|
16277
17046
|
const catalogOptions = catalog.providerOptions ?? {};
|
|
@@ -16310,8 +17079,8 @@ function passthroughTextModel(model) {
|
|
|
16310
17079
|
pricingKind: "token"
|
|
16311
17080
|
};
|
|
16312
17081
|
}
|
|
16313
|
-
var perplexityCostSchema =
|
|
16314
|
-
perplexity:
|
|
17082
|
+
var perplexityCostSchema = import_zod31.z.object({
|
|
17083
|
+
perplexity: import_zod31.z.object({ cost: import_zod31.z.object({ totalCost: import_zod31.z.number().finite().nonnegative() }) })
|
|
16315
17084
|
});
|
|
16316
17085
|
function reportedCostUsd(metadata) {
|
|
16317
17086
|
const parsed = perplexityCostSchema.safeParse(metadata);
|
|
@@ -16384,7 +17153,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
|
|
|
16384
17153
|
|
|
16385
17154
|
// src/client.ts
|
|
16386
17155
|
var import_ai5 = require("ai");
|
|
16387
|
-
var
|
|
17156
|
+
var import_zod32 = require("zod");
|
|
16388
17157
|
|
|
16389
17158
|
// src/generated-image.ts
|
|
16390
17159
|
function toGeneratedImage(image) {
|
|
@@ -16733,10 +17502,10 @@ function textAbortOptions(sdk, context) {
|
|
|
16733
17502
|
if (abortSignal) return { abortSignal };
|
|
16734
17503
|
return {};
|
|
16735
17504
|
}
|
|
16736
|
-
var catalogId =
|
|
16737
|
-
var exactSize =
|
|
16738
|
-
var sdkRatio =
|
|
16739
|
-
var sizeTier =
|
|
17505
|
+
var catalogId = import_zod32.z.string();
|
|
17506
|
+
var exactSize = import_zod32.z.templateLiteral([import_zod32.z.number(), "x", import_zod32.z.number()]);
|
|
17507
|
+
var sdkRatio = import_zod32.z.templateLiteral([import_zod32.z.number(), ":", import_zod32.z.number()]);
|
|
17508
|
+
var sizeTier = import_zod32.z.enum(["512", "1K", "2K", "4K"]);
|
|
16740
17509
|
function isCatalogId(model) {
|
|
16741
17510
|
return catalogId.safeParse(model).success;
|
|
16742
17511
|
}
|
|
@@ -17481,6 +18250,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
|
|
|
17481
18250
|
languageModel,
|
|
17482
18251
|
liveCatalog,
|
|
17483
18252
|
liveState,
|
|
18253
|
+
lumaAdapter,
|
|
17484
18254
|
mergeTextProviderOptions,
|
|
17485
18255
|
missingTierKeys,
|
|
17486
18256
|
model3dCall,
|