@shop-os/modelkit 0.4.6 → 0.4.7
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 +11 -0
- package/README.md +1 -1
- package/dist/catalog.cjs +1 -0
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +10 -1
- package/dist/catalog.d.ts +10 -1
- package/dist/catalog.js +1 -0
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +55 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +54 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -686,6 +686,15 @@ declare const SurfaceSchema: z.ZodEnum<{
|
|
|
686
686
|
}>;
|
|
687
687
|
declare const SURFACES: ("cowork" | "space_builder")[];
|
|
688
688
|
declare const ExposureSchema: z.ZodType<Surface[], unknown>;
|
|
689
|
+
declare const VideoResolutionSchema: z.ZodEnum<{
|
|
690
|
+
"360p": "360p";
|
|
691
|
+
"480p": "480p";
|
|
692
|
+
"720p": "720p";
|
|
693
|
+
"768p": "768p";
|
|
694
|
+
"1080p": "1080p";
|
|
695
|
+
"2k": "2k";
|
|
696
|
+
"4k": "4k";
|
|
697
|
+
}>;
|
|
689
698
|
declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
690
699
|
id: z.ZodString;
|
|
691
700
|
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -1499,4 +1508,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1499
1508
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1500
1509
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1501
1510
|
|
|
1502
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, 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, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
|
1511
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, 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, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -686,6 +686,15 @@ declare const SurfaceSchema: z.ZodEnum<{
|
|
|
686
686
|
}>;
|
|
687
687
|
declare const SURFACES: ("cowork" | "space_builder")[];
|
|
688
688
|
declare const ExposureSchema: z.ZodType<Surface[], unknown>;
|
|
689
|
+
declare const VideoResolutionSchema: z.ZodEnum<{
|
|
690
|
+
"360p": "360p";
|
|
691
|
+
"480p": "480p";
|
|
692
|
+
"720p": "720p";
|
|
693
|
+
"768p": "768p";
|
|
694
|
+
"1080p": "1080p";
|
|
695
|
+
"2k": "2k";
|
|
696
|
+
"4k": "4k";
|
|
697
|
+
}>;
|
|
689
698
|
declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
690
699
|
id: z.ZodString;
|
|
691
700
|
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -1499,4 +1508,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
|
|
|
1499
1508
|
/** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
|
|
1500
1509
|
declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
|
|
1501
1510
|
|
|
1502
|
-
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, 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, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
|
1511
|
+
export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, 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 FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecDimensions, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, 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, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, VideoResolutionSchema, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
|
package/dist/index.js
CHANGED
|
@@ -3813,17 +3813,19 @@ var SeedanceResponseSchema = z7.object({
|
|
|
3813
3813
|
error: z7.union([z7.string(), z7.object({ message: z7.string().optional() })]).optional()
|
|
3814
3814
|
});
|
|
3815
3815
|
var SeedanceErrorMessageSchema = z7.object({ message: z7.string().optional() });
|
|
3816
|
+
function seedanceResolution(req) {
|
|
3817
|
+
return req.resolution ?? "720p";
|
|
3818
|
+
}
|
|
3816
3819
|
function seedanceUsage(ctx, req, duration) {
|
|
3817
|
-
|
|
3820
|
+
return {
|
|
3818
3821
|
model: ctx.model.id,
|
|
3819
3822
|
provider: "ark",
|
|
3820
3823
|
modality: "VIDEO",
|
|
3821
3824
|
unit: "seconds",
|
|
3822
3825
|
quantity: duration,
|
|
3823
|
-
durationSeconds: duration
|
|
3826
|
+
durationSeconds: duration,
|
|
3827
|
+
resolution: seedanceResolution(req)
|
|
3824
3828
|
};
|
|
3825
|
-
if (req.resolution !== void 0) usage2.resolution = req.resolution;
|
|
3826
|
-
return usage2;
|
|
3827
3829
|
}
|
|
3828
3830
|
function seedanceInitialDuration(req) {
|
|
3829
3831
|
return req.durationSeconds ?? 5;
|
|
@@ -3888,6 +3890,10 @@ function seedanceJob(ctx, key, jobId, usage2) {
|
|
|
3888
3890
|
usage2.quantity = polled.duration;
|
|
3889
3891
|
usage2.durationSeconds = polled.duration;
|
|
3890
3892
|
}
|
|
3893
|
+
const rendered = VideoResolutionSchema.safeParse(
|
|
3894
|
+
polled.resolution?.toLowerCase()
|
|
3895
|
+
);
|
|
3896
|
+
if (rendered.success) usage2.resolution = rendered.data;
|
|
3891
3897
|
const tokens = polled.usage;
|
|
3892
3898
|
if (tokens?.total_tokens !== void 0 && tokens.completion_tokens !== void 0) {
|
|
3893
3899
|
usage2.inputTokens = tokens.total_tokens - tokens.completion_tokens;
|
|
@@ -3924,7 +3930,7 @@ async function generateSeedanceVideo(req, ctx) {
|
|
|
3924
3930
|
const requestedDuration = seedanceInitialDuration(req);
|
|
3925
3931
|
let duration = requestedDuration;
|
|
3926
3932
|
if (taskType === "edit") duration = -1;
|
|
3927
|
-
const resolution = req
|
|
3933
|
+
const resolution = seedanceResolution(req);
|
|
3928
3934
|
const content = [{ type: "text", text: req.prompt }];
|
|
3929
3935
|
if (req.firstFrame) {
|
|
3930
3936
|
content.push({
|
|
@@ -4792,9 +4798,15 @@ function videoUsage(ctx, req, duration) {
|
|
|
4792
4798
|
quantity: duration,
|
|
4793
4799
|
durationSeconds: duration
|
|
4794
4800
|
};
|
|
4795
|
-
|
|
4801
|
+
const resolution = falVideoResolution(ctx.model.providerModelId, req);
|
|
4802
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
4796
4803
|
return event;
|
|
4797
4804
|
}
|
|
4805
|
+
function falVideoResolution(providerModelId, req) {
|
|
4806
|
+
if (isWan(providerModelId)) return wanResolution(req);
|
|
4807
|
+
if (isMinimax(providerModelId)) return minimaxResolution(req, minimaxFamily(providerModelId));
|
|
4808
|
+
return req.resolution;
|
|
4809
|
+
}
|
|
4798
4810
|
async function decodeImage(ctx, url, contentType) {
|
|
4799
4811
|
if (url.startsWith("data:")) {
|
|
4800
4812
|
const comma = url.indexOf(",");
|
|
@@ -4926,12 +4938,14 @@ function isFalVideoKnown(providerModelId) {
|
|
|
4926
4938
|
function minimaxFamily(providerModelId) {
|
|
4927
4939
|
return H3_MAX_MODEL_IDS.has(providerModelId.toLowerCase()) ? "h3-max" : "h3";
|
|
4928
4940
|
}
|
|
4941
|
+
function minimaxResolution(req, family) {
|
|
4942
|
+
return req.resolution ?? (family === "h3-max" ? "768p" : "2k");
|
|
4943
|
+
}
|
|
4929
4944
|
function minimaxBase(req, family) {
|
|
4930
|
-
const resolution = (family === "h3-max" ? req.resolution ?? "768p" : req.resolution ?? "2k").toUpperCase();
|
|
4931
4945
|
const input = {
|
|
4932
4946
|
prompt: req.prompt.trim(),
|
|
4933
4947
|
duration: req.durationSeconds ?? 5,
|
|
4934
|
-
resolution,
|
|
4948
|
+
resolution: minimaxResolution(req, family).toUpperCase(),
|
|
4935
4949
|
prompt_expansion_mode: req.promptExpansion ?? "balanced"
|
|
4936
4950
|
};
|
|
4937
4951
|
if (req.safetyChecker !== void 0) input.enable_safety_checker = req.safetyChecker;
|
|
@@ -4942,11 +4956,14 @@ var WAN_MODEL_IDS = /* @__PURE__ */ new Set(["alibaba/wan-3.0"]);
|
|
|
4942
4956
|
function isWan(providerModelId) {
|
|
4943
4957
|
return WAN_MODEL_IDS.has(providerModelId.toLowerCase());
|
|
4944
4958
|
}
|
|
4959
|
+
function wanResolution(req) {
|
|
4960
|
+
return req.resolution ?? "1080p";
|
|
4961
|
+
}
|
|
4945
4962
|
function wanVideo(req, family) {
|
|
4946
4963
|
const input = {
|
|
4947
4964
|
prompt: req.prompt.trim(),
|
|
4948
4965
|
duration: req.durationSeconds ?? 5,
|
|
4949
|
-
resolution: req
|
|
4966
|
+
resolution: wanResolution(req),
|
|
4950
4967
|
aspect_ratio: req.aspectRatio ?? "adaptive",
|
|
4951
4968
|
audio: req.generateAudio ?? true
|
|
4952
4969
|
};
|
|
@@ -5547,7 +5564,7 @@ async function downloadVideo(ctx, url, apiKey, signal) {
|
|
|
5547
5564
|
mime: res.headers.get("content-type")?.split(";")[0]?.trim() || "video/mp4"
|
|
5548
5565
|
};
|
|
5549
5566
|
}
|
|
5550
|
-
function videoUsage2(ctx,
|
|
5567
|
+
function videoUsage2(ctx, duration, resolution) {
|
|
5551
5568
|
const event = {
|
|
5552
5569
|
model: ctx.model.id,
|
|
5553
5570
|
provider: "google-genai",
|
|
@@ -5556,7 +5573,7 @@ function videoUsage2(ctx, req, duration) {
|
|
|
5556
5573
|
quantity: duration,
|
|
5557
5574
|
durationSeconds: duration
|
|
5558
5575
|
};
|
|
5559
|
-
if (
|
|
5576
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
5560
5577
|
return event;
|
|
5561
5578
|
}
|
|
5562
5579
|
async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
@@ -5650,7 +5667,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
|
|
|
5650
5667
|
}
|
|
5651
5668
|
};
|
|
5652
5669
|
const jobId = operation.name ?? crypto.randomUUID();
|
|
5653
|
-
const usage2 = videoUsage2(ctx,
|
|
5670
|
+
const usage2 = videoUsage2(ctx, duration, req.resolution ?? "720p");
|
|
5654
5671
|
return {
|
|
5655
5672
|
jobId,
|
|
5656
5673
|
async poll() {
|
|
@@ -5774,10 +5791,8 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
5774
5791
|
if (req.sourceVideo === void 0 && !extend && req.aspectRatio !== void 0 && req.aspectRatio !== "adaptive") {
|
|
5775
5792
|
responseFormat.aspect_ratio = toOmniAspect(req.aspectRatio);
|
|
5776
5793
|
}
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
if (omniResolution !== void 0) responseFormat.resolution = omniResolution;
|
|
5780
|
-
}
|
|
5794
|
+
const omniResolution = isOmniV1 ? void 0 : toOmniResolution(req.resolution);
|
|
5795
|
+
if (omniResolution !== void 0) responseFormat.resolution = omniResolution;
|
|
5781
5796
|
if (req.durationSeconds !== void 0) responseFormat.duration = `${req.durationSeconds}s`;
|
|
5782
5797
|
const client2 = createGenAIClient({
|
|
5783
5798
|
apiKey,
|
|
@@ -5895,7 +5910,7 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
|
|
|
5895
5910
|
if (!(extend && !chained)) await cleanupUploads();
|
|
5896
5911
|
}
|
|
5897
5912
|
const jobId = interaction.id ?? crypto.randomUUID();
|
|
5898
|
-
const usage2 = videoUsage2(ctx,
|
|
5913
|
+
const usage2 = videoUsage2(ctx, duration, omniResolution ?? "720p");
|
|
5899
5914
|
const getInteraction = async () => {
|
|
5900
5915
|
try {
|
|
5901
5916
|
const getParams = { stream: false };
|
|
@@ -7477,7 +7492,8 @@ function videoUsage4(ctx, req) {
|
|
|
7477
7492
|
unit: "compute_seconds",
|
|
7478
7493
|
quantity: 0
|
|
7479
7494
|
};
|
|
7480
|
-
|
|
7495
|
+
const resolution = replicateVideoResolution(ctx.model.providerModelId, req);
|
|
7496
|
+
if (resolution !== void 0) event.resolution = resolution;
|
|
7481
7497
|
if (req.durationSeconds !== void 0) event.durationSeconds = req.durationSeconds;
|
|
7482
7498
|
return event;
|
|
7483
7499
|
}
|
|
@@ -7714,7 +7730,7 @@ function klingInput(req) {
|
|
|
7714
7730
|
const input = {
|
|
7715
7731
|
prompt: req.prompt,
|
|
7716
7732
|
duration: req.durationSeconds ?? 10,
|
|
7717
|
-
mode: req.mode
|
|
7733
|
+
mode: klingTier(req).mode,
|
|
7718
7734
|
generate_audio: req.generateAudio ?? false
|
|
7719
7735
|
};
|
|
7720
7736
|
const startImage = images[0];
|
|
@@ -7728,17 +7744,25 @@ function klingInput(req) {
|
|
|
7728
7744
|
if (req.negativePrompt !== void 0) input.negative_prompt = req.negativePrompt;
|
|
7729
7745
|
return input;
|
|
7730
7746
|
}
|
|
7731
|
-
function
|
|
7732
|
-
|
|
7733
|
-
if (
|
|
7734
|
-
if (
|
|
7735
|
-
return req.
|
|
7747
|
+
function replicateVideoResolution(providerModelId, req) {
|
|
7748
|
+
const kind = videoKind(providerModelId);
|
|
7749
|
+
if (kind === "kling" || kind === "kling-omni") return klingTier(req).resolution;
|
|
7750
|
+
if (kind === "hailuo") return hailuoResolution(req);
|
|
7751
|
+
return req.resolution;
|
|
7752
|
+
}
|
|
7753
|
+
var KLING_TIERS = [
|
|
7754
|
+
{ mode: "standard", resolution: "720p" },
|
|
7755
|
+
{ mode: "pro", resolution: "1080p" },
|
|
7756
|
+
{ mode: "4k", resolution: "4k" }
|
|
7757
|
+
];
|
|
7758
|
+
function klingTier(req) {
|
|
7759
|
+
return KLING_TIERS.find((tier) => tier.resolution === req.resolution) ?? KLING_TIERS.find((tier) => tier.mode === req.mode) ?? KLING_TIERS[0];
|
|
7736
7760
|
}
|
|
7737
7761
|
function klingOmniInput(req) {
|
|
7738
7762
|
const input = {
|
|
7739
7763
|
prompt: req.prompt,
|
|
7740
7764
|
duration: req.durationSeconds ?? 10,
|
|
7741
|
-
mode:
|
|
7765
|
+
mode: klingTier(req).mode,
|
|
7742
7766
|
generate_audio: req.generateAudio ?? false
|
|
7743
7767
|
};
|
|
7744
7768
|
const start = req.firstFrame ?? req.lastFrame;
|
|
@@ -7752,11 +7776,14 @@ function klingOmniInput(req) {
|
|
|
7752
7776
|
if (refs.length > 0) input.reference_images = refs;
|
|
7753
7777
|
return input;
|
|
7754
7778
|
}
|
|
7779
|
+
function hailuoResolution(req) {
|
|
7780
|
+
return req.resolution ?? "768p";
|
|
7781
|
+
}
|
|
7755
7782
|
function hailuoInput(req) {
|
|
7756
7783
|
const input = {
|
|
7757
7784
|
prompt: req.prompt,
|
|
7758
7785
|
duration: req.durationSeconds ?? 6,
|
|
7759
|
-
resolution: req
|
|
7786
|
+
resolution: hailuoResolution(req),
|
|
7760
7787
|
prompt_optimizer: true
|
|
7761
7788
|
};
|
|
7762
7789
|
if (req.firstFrame) input.first_frame_image = refToUrl(req.firstFrame);
|
|
@@ -9991,6 +10018,7 @@ export {
|
|
|
9991
10018
|
SurfaceSchema,
|
|
9992
10019
|
VIDEO_INPUT_SPEC_KEYS,
|
|
9993
10020
|
VIDEO_TOOL_MODELS,
|
|
10021
|
+
VideoResolutionSchema,
|
|
9994
10022
|
adapterServesType,
|
|
9995
10023
|
aiSdkTextAdapter,
|
|
9996
10024
|
arkAdapter,
|