@shop-os/modelkit 0.2.14 → 0.2.15

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.d.cts CHANGED
@@ -25,10 +25,14 @@ type OutputFormat = "png" | "jpeg" | "webp";
25
25
  type MediaRef = {
26
26
  url: string;
27
27
  label?: string;
28
+ /** Measured length of a video/audio; the kit never measures it. */
29
+ durationSeconds?: number;
28
30
  } | {
29
31
  bytes: Uint8Array;
30
32
  mime: string;
31
33
  label?: string;
34
+ /** Measured length of a video/audio; the kit never measures it. */
35
+ durationSeconds?: number;
32
36
  };
33
37
  /** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
34
38
  interface UpscaleOptions {
@@ -160,6 +164,16 @@ interface MediaPart {
160
164
  }
161
165
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
162
166
  type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
167
+ interface VideoSecondsLimits {
168
+ /** Minimum length of each reference video, in seconds. */
169
+ min?: number;
170
+ /** Maximum length of each reference video, in seconds. */
171
+ max?: number;
172
+ /** Maximum combined length of the reference videos, in seconds. */
173
+ total?: number;
174
+ /** Higher per-video minimum when `taskType` is `edit` (Seedance 2.5: 4 s). */
175
+ editMin?: number;
176
+ }
163
177
  interface ReferenceLimits {
164
178
  images?: number;
165
179
  /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
@@ -169,6 +183,8 @@ interface ReferenceLimits {
169
183
  total?: number;
170
184
  /** Provider rejects a request whose only references are audio. */
171
185
  audioOnly?: boolean;
186
+ /** Per-video length caps (min/max each) and combined total for reference videos. */
187
+ videoSeconds?: VideoSecondsLimits;
172
188
  }
173
189
  interface ModelConstraints {
174
190
  aspectRatios?: AspectRatio[];
@@ -192,6 +208,11 @@ interface ModelConstraints {
192
208
  supports?: SupportedOption[];
193
209
  /** Ratio is dropped, with a warning, when one of these inputs is present. */
194
210
  ratioIgnoredWith?: ("firstFrame" | "sourceVideo")[];
211
+ /** Length limits for the source video the row edits or extends. */
212
+ sourceVideoSeconds?: Omit<VideoSecondsLimits, "total"> & {
213
+ /** The provider sends the source as a reference video, so it counts toward `references.videoSeconds.total` (Seedance). */
214
+ inReferenceTotal?: boolean;
215
+ };
195
216
  }
196
217
  /** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
197
218
  type JsonPrimitive = string | number | boolean | null;
@@ -589,6 +610,12 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
589
610
  audios: z.ZodOptional<z.ZodNumber>;
590
611
  total: z.ZodOptional<z.ZodNumber>;
591
612
  audioOnly: z.ZodOptional<z.ZodBoolean>;
613
+ videoSeconds: z.ZodOptional<z.ZodObject<{
614
+ min: z.ZodOptional<z.ZodNumber>;
615
+ max: z.ZodOptional<z.ZodNumber>;
616
+ total: z.ZodOptional<z.ZodNumber>;
617
+ editMin: z.ZodOptional<z.ZodNumber>;
618
+ }, z.core.$loose>>;
592
619
  }, z.core.$loose>>;
593
620
  requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
594
621
  references: "references";
@@ -618,15 +645,23 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
618
645
  firstFrame: "firstFrame";
619
646
  sourceVideo: "sourceVideo";
620
647
  }>>>;
648
+ sourceVideoSeconds: z.ZodOptional<z.ZodObject<{
649
+ max: z.ZodOptional<z.ZodNumber>;
650
+ min: z.ZodOptional<z.ZodNumber>;
651
+ editMin: z.ZodOptional<z.ZodNumber>;
652
+ inReferenceTotal: z.ZodOptional<z.ZodBoolean>;
653
+ }, z.core.$loose>>;
621
654
  }, z.core.$loose>;
622
655
  defaults: z.ZodObject<{
623
656
  references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
624
657
  url: z.ZodString;
625
658
  label: z.ZodOptional<z.ZodString>;
659
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
626
660
  }, z.core.$loose>, z.ZodObject<{
627
661
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
628
662
  mime: z.ZodString;
629
663
  label: z.ZodOptional<z.ZodString>;
664
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
630
665
  }, z.core.$loose>]>>>;
631
666
  aspectRatio: z.ZodOptional<z.ZodEnum<{
632
667
  "1:1": "1:1";
@@ -681,50 +716,62 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
681
716
  firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
682
717
  url: z.ZodString;
683
718
  label: z.ZodOptional<z.ZodString>;
719
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
684
720
  }, z.core.$loose>, z.ZodObject<{
685
721
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
686
722
  mime: z.ZodString;
687
723
  label: z.ZodOptional<z.ZodString>;
724
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
688
725
  }, z.core.$loose>]>>;
689
726
  lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
690
727
  url: z.ZodString;
691
728
  label: z.ZodOptional<z.ZodString>;
729
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
692
730
  }, z.core.$loose>, z.ZodObject<{
693
731
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
694
732
  mime: z.ZodString;
695
733
  label: z.ZodOptional<z.ZodString>;
734
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
696
735
  }, z.core.$loose>]>>;
697
736
  sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
698
737
  url: z.ZodString;
699
738
  label: z.ZodOptional<z.ZodString>;
739
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
700
740
  }, z.core.$loose>, z.ZodObject<{
701
741
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
702
742
  mime: z.ZodString;
703
743
  label: z.ZodOptional<z.ZodString>;
744
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
704
745
  }, z.core.$loose>]>>;
705
746
  referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
706
747
  url: z.ZodString;
707
748
  label: z.ZodOptional<z.ZodString>;
749
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
708
750
  }, z.core.$loose>, z.ZodObject<{
709
751
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
710
752
  mime: z.ZodString;
711
753
  label: z.ZodOptional<z.ZodString>;
754
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
712
755
  }, z.core.$loose>]>>>;
713
756
  referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
714
757
  url: z.ZodString;
715
758
  label: z.ZodOptional<z.ZodString>;
759
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
716
760
  }, z.core.$loose>, z.ZodObject<{
717
761
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
718
762
  mime: z.ZodString;
719
763
  label: z.ZodOptional<z.ZodString>;
764
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
720
765
  }, z.core.$loose>]>>>;
721
766
  referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
722
767
  url: z.ZodString;
723
768
  label: z.ZodOptional<z.ZodString>;
769
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
724
770
  }, z.core.$loose>, z.ZodObject<{
725
771
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
726
772
  mime: z.ZodString;
727
773
  label: z.ZodOptional<z.ZodString>;
774
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
728
775
  }, z.core.$loose>]>>>;
729
776
  resolution: z.ZodOptional<z.ZodEnum<{
730
777
  "360p": "360p";
@@ -936,6 +983,12 @@ interface ResolveResult<T> {
936
983
  }
937
984
  /** Nearest supported ratio in the same orientation bucket, else nearest overall, by log distance. */
938
985
  declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
986
+ /** First length violation for the videos a request sends, as a user-facing message. */
987
+ declare function videoLengthViolation(model: CatalogModel, input: {
988
+ referenceVideos?: (number | undefined)[];
989
+ sourceVideo?: number;
990
+ taskType?: VideoRequest["taskType"];
991
+ }): string | undefined;
939
992
  declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
940
993
  declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
941
994
  declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
@@ -1143,4 +1196,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1143
1196
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1144
1197
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1145
1198
 
1146
- export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, withRetry, xaiVideoAdapter };
1199
+ export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -25,10 +25,14 @@ type OutputFormat = "png" | "jpeg" | "webp";
25
25
  type MediaRef = {
26
26
  url: string;
27
27
  label?: string;
28
+ /** Measured length of a video/audio; the kit never measures it. */
29
+ durationSeconds?: number;
28
30
  } | {
29
31
  bytes: Uint8Array;
30
32
  mime: string;
31
33
  label?: string;
34
+ /** Measured length of a video/audio; the kit never measures it. */
35
+ durationSeconds?: number;
32
36
  };
33
37
  /** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
34
38
  interface UpscaleOptions {
@@ -160,6 +164,16 @@ interface MediaPart {
160
164
  }
161
165
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
162
166
  type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
167
+ interface VideoSecondsLimits {
168
+ /** Minimum length of each reference video, in seconds. */
169
+ min?: number;
170
+ /** Maximum length of each reference video, in seconds. */
171
+ max?: number;
172
+ /** Maximum combined length of the reference videos, in seconds. */
173
+ total?: number;
174
+ /** Higher per-video minimum when `taskType` is `edit` (Seedance 2.5: 4 s). */
175
+ editMin?: number;
176
+ }
163
177
  interface ReferenceLimits {
164
178
  images?: number;
165
179
  /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
@@ -169,6 +183,8 @@ interface ReferenceLimits {
169
183
  total?: number;
170
184
  /** Provider rejects a request whose only references are audio. */
171
185
  audioOnly?: boolean;
186
+ /** Per-video length caps (min/max each) and combined total for reference videos. */
187
+ videoSeconds?: VideoSecondsLimits;
172
188
  }
173
189
  interface ModelConstraints {
174
190
  aspectRatios?: AspectRatio[];
@@ -192,6 +208,11 @@ interface ModelConstraints {
192
208
  supports?: SupportedOption[];
193
209
  /** Ratio is dropped, with a warning, when one of these inputs is present. */
194
210
  ratioIgnoredWith?: ("firstFrame" | "sourceVideo")[];
211
+ /** Length limits for the source video the row edits or extends. */
212
+ sourceVideoSeconds?: Omit<VideoSecondsLimits, "total"> & {
213
+ /** The provider sends the source as a reference video, so it counts toward `references.videoSeconds.total` (Seedance). */
214
+ inReferenceTotal?: boolean;
215
+ };
195
216
  }
196
217
  /** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
197
218
  type JsonPrimitive = string | number | boolean | null;
@@ -589,6 +610,12 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
589
610
  audios: z.ZodOptional<z.ZodNumber>;
590
611
  total: z.ZodOptional<z.ZodNumber>;
591
612
  audioOnly: z.ZodOptional<z.ZodBoolean>;
613
+ videoSeconds: z.ZodOptional<z.ZodObject<{
614
+ min: z.ZodOptional<z.ZodNumber>;
615
+ max: z.ZodOptional<z.ZodNumber>;
616
+ total: z.ZodOptional<z.ZodNumber>;
617
+ editMin: z.ZodOptional<z.ZodNumber>;
618
+ }, z.core.$loose>>;
592
619
  }, z.core.$loose>>;
593
620
  requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
594
621
  references: "references";
@@ -618,15 +645,23 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
618
645
  firstFrame: "firstFrame";
619
646
  sourceVideo: "sourceVideo";
620
647
  }>>>;
648
+ sourceVideoSeconds: z.ZodOptional<z.ZodObject<{
649
+ max: z.ZodOptional<z.ZodNumber>;
650
+ min: z.ZodOptional<z.ZodNumber>;
651
+ editMin: z.ZodOptional<z.ZodNumber>;
652
+ inReferenceTotal: z.ZodOptional<z.ZodBoolean>;
653
+ }, z.core.$loose>>;
621
654
  }, z.core.$loose>;
622
655
  defaults: z.ZodObject<{
623
656
  references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
624
657
  url: z.ZodString;
625
658
  label: z.ZodOptional<z.ZodString>;
659
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
626
660
  }, z.core.$loose>, z.ZodObject<{
627
661
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
628
662
  mime: z.ZodString;
629
663
  label: z.ZodOptional<z.ZodString>;
664
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
630
665
  }, z.core.$loose>]>>>;
631
666
  aspectRatio: z.ZodOptional<z.ZodEnum<{
632
667
  "1:1": "1:1";
@@ -681,50 +716,62 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
681
716
  firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
682
717
  url: z.ZodString;
683
718
  label: z.ZodOptional<z.ZodString>;
719
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
684
720
  }, z.core.$loose>, z.ZodObject<{
685
721
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
686
722
  mime: z.ZodString;
687
723
  label: z.ZodOptional<z.ZodString>;
724
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
688
725
  }, z.core.$loose>]>>;
689
726
  lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
690
727
  url: z.ZodString;
691
728
  label: z.ZodOptional<z.ZodString>;
729
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
692
730
  }, z.core.$loose>, z.ZodObject<{
693
731
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
694
732
  mime: z.ZodString;
695
733
  label: z.ZodOptional<z.ZodString>;
734
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
696
735
  }, z.core.$loose>]>>;
697
736
  sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
698
737
  url: z.ZodString;
699
738
  label: z.ZodOptional<z.ZodString>;
739
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
700
740
  }, z.core.$loose>, z.ZodObject<{
701
741
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
702
742
  mime: z.ZodString;
703
743
  label: z.ZodOptional<z.ZodString>;
744
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
704
745
  }, z.core.$loose>]>>;
705
746
  referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
706
747
  url: z.ZodString;
707
748
  label: z.ZodOptional<z.ZodString>;
749
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
708
750
  }, z.core.$loose>, z.ZodObject<{
709
751
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
710
752
  mime: z.ZodString;
711
753
  label: z.ZodOptional<z.ZodString>;
754
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
712
755
  }, z.core.$loose>]>>>;
713
756
  referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
714
757
  url: z.ZodString;
715
758
  label: z.ZodOptional<z.ZodString>;
759
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
716
760
  }, z.core.$loose>, z.ZodObject<{
717
761
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
718
762
  mime: z.ZodString;
719
763
  label: z.ZodOptional<z.ZodString>;
764
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
720
765
  }, z.core.$loose>]>>>;
721
766
  referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
722
767
  url: z.ZodString;
723
768
  label: z.ZodOptional<z.ZodString>;
769
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
724
770
  }, z.core.$loose>, z.ZodObject<{
725
771
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
726
772
  mime: z.ZodString;
727
773
  label: z.ZodOptional<z.ZodString>;
774
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
728
775
  }, z.core.$loose>]>>>;
729
776
  resolution: z.ZodOptional<z.ZodEnum<{
730
777
  "360p": "360p";
@@ -936,6 +983,12 @@ interface ResolveResult<T> {
936
983
  }
937
984
  /** Nearest supported ratio in the same orientation bucket, else nearest overall, by log distance. */
938
985
  declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
986
+ /** First length violation for the videos a request sends, as a user-facing message. */
987
+ declare function videoLengthViolation(model: CatalogModel, input: {
988
+ referenceVideos?: (number | undefined)[];
989
+ sourceVideo?: number;
990
+ taskType?: VideoRequest["taskType"];
991
+ }): string | undefined;
939
992
  declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
940
993
  declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
941
994
  declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
@@ -1143,4 +1196,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1143
1196
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1144
1197
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1145
1198
 
1146
- export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, withRetry, xaiVideoAdapter };
1199
+ export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type GeneratedImage, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, withRetry, xaiVideoAdapter };
package/dist/index.js CHANGED
@@ -1373,7 +1373,8 @@ var VIDEO_MODELS = [
1373
1373
  // reference clip keeps its own framing.
1374
1374
  aspectRatios: [...OMNI_RATIOS],
1375
1375
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1376
- references: { images: 6, videos: 1 },
1376
+ references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
1377
+ sourceVideoSeconds: { max: 10 },
1377
1378
  supports: []
1378
1379
  },
1379
1380
  defaults: {},
@@ -1399,7 +1400,8 @@ var VIDEO_MODELS = [
1399
1400
  aspectRatios: [...OMNI_RATIOS],
1400
1401
  resolutions: ["360p", "720p", "1080p", "4k"],
1401
1402
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1402
- references: { images: 6, videos: 1 },
1403
+ references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
1404
+ sourceVideoSeconds: { max: 10 },
1403
1405
  supports: []
1404
1406
  },
1405
1407
  defaults: {},
@@ -1427,7 +1429,14 @@ var VIDEO_MODELS = [
1427
1429
  resolutions: ["480p", "720p", "1080p", "4k"],
1428
1430
  durations: { min: 4, max: 15 },
1429
1431
  durationPresets: [4, 6, 8, 10, 12, 15],
1430
- references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1432
+ references: {
1433
+ images: 9,
1434
+ videos: 3,
1435
+ audios: 3,
1436
+ audioOnly: false,
1437
+ videoSeconds: { min: 2, max: 15, total: 15 }
1438
+ },
1439
+ sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
1431
1440
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1432
1441
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1433
1442
  },
@@ -1459,7 +1468,14 @@ var VIDEO_MODELS = [
1459
1468
  aspectRatios: [...SEEDANCE_RATIOS],
1460
1469
  resolutions: ["480p", "720p"],
1461
1470
  durations: { min: 4, max: 15 },
1462
- references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1471
+ references: {
1472
+ images: 9,
1473
+ videos: 3,
1474
+ audios: 3,
1475
+ audioOnly: false,
1476
+ videoSeconds: { min: 2, max: 15, total: 15 }
1477
+ },
1478
+ sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
1463
1479
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1464
1480
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1465
1481
  },
@@ -1493,7 +1509,13 @@ var VIDEO_MODELS = [
1493
1509
  aspectRatios: [...SEEDANCE_RATIOS],
1494
1510
  resolutions: ["480p", "720p", "1080p"],
1495
1511
  durations: { min: 4, max: 30 },
1496
- references: { images: 30, videos: 10, audios: 10 },
1512
+ references: {
1513
+ images: 30,
1514
+ videos: 10,
1515
+ audios: 10,
1516
+ videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 }
1517
+ },
1518
+ sourceVideoSeconds: { min: 2, max: 30, editMin: 4, inReferenceTotal: true },
1497
1519
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1498
1520
  supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"]
1499
1521
  },
@@ -1705,7 +1727,14 @@ var VIDEO_MODELS = [
1705
1727
  aspectRatios: [...H3_REFERENCE_RATIOS],
1706
1728
  resolutions: ["480p", "768p", "2k", "4k"],
1707
1729
  durations: { min: 5, max: 15 },
1708
- references: { images: 9, videos: 3, audios: 3, total: 12, audioOnly: false },
1730
+ references: {
1731
+ images: 9,
1732
+ videos: 3,
1733
+ audios: 3,
1734
+ total: 12,
1735
+ audioOnly: false,
1736
+ videoSeconds: { min: 2, max: 15, total: 15 }
1737
+ },
1709
1738
  supports: ["seed", "promptExpansion", "safetyChecker"]
1710
1739
  },
1711
1740
  defaults: {
@@ -1736,7 +1765,14 @@ var VIDEO_MODELS = [
1736
1765
  aspectRatios: [...H3_REFERENCE_RATIOS],
1737
1766
  resolutions: ["480p", "768p"],
1738
1767
  durations: { min: 5, max: 15 },
1739
- references: { images: 9, videos: 3, audios: 3, total: 12, audioOnly: false },
1768
+ references: {
1769
+ images: 9,
1770
+ videos: 3,
1771
+ audios: 3,
1772
+ total: 12,
1773
+ audioOnly: false,
1774
+ videoSeconds: { min: 2, max: 15, total: 15 }
1775
+ },
1740
1776
  supports: ["seed", "promptExpansion", "safetyChecker"]
1741
1777
  },
1742
1778
  defaults: {
@@ -1768,6 +1804,7 @@ var VIDEO_MODELS = [
1768
1804
  aspectRatios: [...KLING_RATIOS],
1769
1805
  durations: { min: 3, max: 10 },
1770
1806
  requires: ["sourceVideo"],
1807
+ sourceVideoSeconds: { min: 3, max: 10.05 },
1771
1808
  supports: []
1772
1809
  },
1773
1810
  defaults: { durationSeconds: 5, aspectRatio: "16:9" },
@@ -2127,13 +2164,20 @@ var ProviderOptionValueSchema = z2.lazy(
2127
2164
  ])
2128
2165
  );
2129
2166
  var ProviderOptionsSchema = z2.record(z2.string(), z2.record(z2.string(), ProviderOptionValueSchema));
2167
+ var VideoSecondsLimitsSchema = z2.looseObject({
2168
+ min: z2.number().optional(),
2169
+ max: z2.number().optional(),
2170
+ total: z2.number().optional(),
2171
+ editMin: z2.number().optional()
2172
+ });
2130
2173
  var ReferenceLimitsSchema = z2.looseObject({
2131
2174
  images: z2.number().optional(),
2132
2175
  imagesWithVideo: z2.number().optional(),
2133
2176
  videos: z2.number().optional(),
2134
2177
  audios: z2.number().optional(),
2135
2178
  total: z2.number().optional(),
2136
- audioOnly: z2.boolean().optional()
2179
+ audioOnly: z2.boolean().optional(),
2180
+ videoSeconds: VideoSecondsLimitsSchema.optional()
2137
2181
  });
2138
2182
  var ModelConstraintsSchema = z2.looseObject({
2139
2183
  aspectRatios: z2.array(AspectRatioSchema).optional(),
@@ -2146,14 +2190,20 @@ var ModelConstraintsSchema = z2.looseObject({
2146
2190
  references: ReferenceLimitsSchema.optional(),
2147
2191
  requires: z2.array(RequiredInputSchema).optional(),
2148
2192
  supports: z2.array(SupportedOptionSchema).optional(),
2149
- ratioIgnoredWith: z2.array(z2.enum(["firstFrame", "sourceVideo"])).optional()
2193
+ ratioIgnoredWith: z2.array(z2.enum(["firstFrame", "sourceVideo"])).optional(),
2194
+ sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: z2.boolean().optional() }).optional()
2150
2195
  });
2151
2196
  var MediaRefSchema = z2.union([
2152
- z2.looseObject({ url: z2.string(), label: z2.string().optional() }),
2197
+ z2.looseObject({
2198
+ url: z2.string(),
2199
+ label: z2.string().optional(),
2200
+ durationSeconds: z2.number().optional()
2201
+ }),
2153
2202
  z2.looseObject({
2154
2203
  bytes: z2.instanceof(Uint8Array),
2155
2204
  mime: z2.string(),
2156
- label: z2.string().optional()
2205
+ label: z2.string().optional(),
2206
+ durationSeconds: z2.number().optional()
2157
2207
  })
2158
2208
  ]);
2159
2209
  var ImageSafetySettingSchema = z2.looseObject({ category: z2.string(), threshold: z2.string() });
@@ -6540,8 +6590,8 @@ function lyriaAudioInput(req, ctx) {
6540
6590
  if (negative) input.negative_prompt = negative;
6541
6591
  return input;
6542
6592
  }
6543
- function elevenLabsMusicDuration(seconds) {
6544
- return Math.min(300, Math.max(5, seconds ?? 15));
6593
+ function elevenLabsMusicDuration(seconds2) {
6594
+ return Math.min(300, Math.max(5, seconds2 ?? 15));
6545
6595
  }
6546
6596
  function elevenLabsMusicInput(req, ctx) {
6547
6597
  const prompt = req.prompt.trim();
@@ -6606,9 +6656,9 @@ async function generateReplicateAudio(req, ctx, deps) {
6606
6656
  const { url, predictTime, raw } = await runPrediction(ctx, input, deps);
6607
6657
  const usage2 = audioUsage(ctx, req);
6608
6658
  if (ctx.model.usage.unit === "seconds") {
6609
- const seconds = elevenLabsMusicDuration(req.durationSeconds);
6610
- usage2.quantity = seconds;
6611
- usage2.durationSeconds = seconds;
6659
+ const seconds2 = elevenLabsMusicDuration(req.durationSeconds);
6660
+ usage2.quantity = seconds2;
6661
+ usage2.durationSeconds = seconds2;
6612
6662
  } else {
6613
6663
  usage2.quantity = predictTime;
6614
6664
  }
@@ -7248,6 +7298,49 @@ function trim(field, refs, limit, model, warnings) {
7248
7298
  });
7249
7299
  return refs.slice(0, limit);
7250
7300
  }
7301
+ function knownLength(value) {
7302
+ return value !== void 0 && Number.isFinite(value) ? value : void 0;
7303
+ }
7304
+ function seconds(len, limit) {
7305
+ let digits = 1;
7306
+ while (digits < 3 && Number(len.toFixed(digits)) === limit) digits++;
7307
+ return len.toFixed(digits);
7308
+ }
7309
+ function effectiveMin(limits, taskType) {
7310
+ if (taskType !== "edit" || limits?.editMin === void 0) return limits?.min;
7311
+ return Math.max(limits.min ?? 0, limits.editMin);
7312
+ }
7313
+ function videoLengthViolation(model, input) {
7314
+ const limits = model.constraints.references?.videoSeconds;
7315
+ const refMin = effectiveMin(limits, input.taskType);
7316
+ const lengths = (input.referenceVideos ?? []).map(knownLength);
7317
+ if (limits?.max !== void 0) {
7318
+ const max = limits.max;
7319
+ const i = lengths.findIndex((len) => len !== void 0 && len > max);
7320
+ if (i >= 0)
7321
+ return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
7322
+ }
7323
+ if (refMin !== void 0) {
7324
+ const i = lengths.findIndex((len) => len !== void 0 && len < refMin);
7325
+ if (i >= 0)
7326
+ return `${model.label} takes reference videos of at least ${String(refMin)} s each; video ${i + 1} is ${seconds(lengths[i], refMin)} s.`;
7327
+ }
7328
+ const source = knownLength(input.sourceVideo);
7329
+ const sourceLimits = model.constraints.sourceVideoSeconds;
7330
+ if (limits?.total !== void 0) {
7331
+ const refSum = lengths.reduce((acc, len) => acc + (len ?? 0), 0);
7332
+ const sum = refSum + (sourceLimits?.inReferenceTotal ? source ?? 0 : 0);
7333
+ if (sum > limits.total)
7334
+ return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
7335
+ }
7336
+ if (source === void 0) return void 0;
7337
+ const sourceMin = effectiveMin(sourceLimits, input.taskType);
7338
+ if (sourceLimits?.max !== void 0 && source > sourceLimits.max)
7339
+ return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
7340
+ if (sourceMin !== void 0 && source < sourceMin)
7341
+ return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;
7342
+ return void 0;
7343
+ }
7251
7344
  function resolveImageOptions(model, request, onUnsupported = "error") {
7252
7345
  const warnings = [];
7253
7346
  const c = model.constraints;
@@ -7433,6 +7526,21 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
7433
7526
  model: model.id
7434
7527
  });
7435
7528
  }
7529
+ const lengthViolation = videoLengthViolation(model, {
7530
+ referenceVideos: videos.map((v) => v.durationSeconds),
7531
+ taskType: merged.taskType,
7532
+ ...merged.sourceVideo?.durationSeconds !== void 0 && {
7533
+ sourceVideo: merged.sourceVideo.durationSeconds
7534
+ }
7535
+ });
7536
+ if (lengthViolation !== void 0) {
7537
+ throw new ModelKitError({
7538
+ code: "unsupported_option",
7539
+ message: lengthViolation,
7540
+ model: model.id,
7541
+ retryable: false
7542
+ });
7543
+ }
7436
7544
  setOrDelete(merged, "referenceImages", images);
7437
7545
  setOrDelete(merged, "referenceVideos", videos);
7438
7546
  setOrDelete(merged, "referenceAudios", audios);
@@ -7990,7 +8098,7 @@ function createModelKit(config, adapters) {
7990
8098
  promptExpansion: _promptExpansion,
7991
8099
  mode: _mode
7992
8100
  } = req;
7993
- const seconds = duration ?? durationSeconds;
8101
+ const seconds2 = duration ?? durationSeconds;
7994
8102
  const abortSignal = combineSignals(req.abortSignal, call.signal);
7995
8103
  const options = { model, prompt };
7996
8104
  if (call.maxRetries !== void 0) options.maxRetries = call.maxRetries;
@@ -7999,7 +8107,7 @@ function createModelKit(config, adapters) {
7999
8107
  if (ratio) options.aspectRatio = ratio;
8000
8108
  else if (aspectRatio !== void 0)
8001
8109
  pushIgnored(warnings, "aspectRatio", aspectRatio, model.modelId);
8002
- if (seconds !== void 0) options.duration = seconds;
8110
+ if (seconds2 !== void 0) options.duration = seconds2;
8003
8111
  if (seed !== void 0) options.seed = seed;
8004
8112
  if (generateAudio2 !== void 0) options.generateAudio = generateAudio2;
8005
8113
  const frames = [
@@ -8046,8 +8154,8 @@ function createModelKit(config, adapters) {
8046
8154
  provider: model.provider,
8047
8155
  modality: "VIDEO",
8048
8156
  unit: "seconds",
8049
- quantity: seconds ?? 0,
8050
- ...seconds !== void 0 && { durationSeconds: seconds }
8157
+ quantity: seconds2 ?? 0,
8158
+ ...seconds2 !== void 0 && { durationSeconds: seconds2 }
8051
8159
  };
8052
8160
  settled = {
8053
8161
  video: { bytes: result.video.uint8Array, mime: result.video.mediaType },
@@ -8397,6 +8505,7 @@ export {
8397
8505
  textUsageEvent,
8398
8506
  toGeneratedImage,
8399
8507
  validateInputSpec,
8508
+ videoLengthViolation,
8400
8509
  withRetry,
8401
8510
  xaiVideoAdapter
8402
8511
  };