@shop-os/modelkit 0.17.1 → 0.18.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/dist/index.cjs CHANGED
@@ -58,6 +58,7 @@ __export(index_exports, {
58
58
  VideoResolutionSchema: () => VideoResolutionSchema,
59
59
  adapterServesType: () => adapterServesType,
60
60
  aiSdkTextAdapter: () => aiSdkTextAdapter,
61
+ animationTier: () => animationTier,
61
62
  arkAdapter: () => arkAdapter,
62
63
  aspectRatioToSize: () => aspectRatioToSize,
63
64
  byokProviderForModel: () => byokProviderForModel,
@@ -83,6 +84,7 @@ __export(index_exports, {
83
84
  googleImageAdapter: () => googleImageAdapter,
84
85
  hasAwsCredentials: () => hasAwsCredentials,
85
86
  higgsfieldAdapter: () => higgsfieldAdapter,
87
+ imageOutputFormats: () => imageOutputFormats,
86
88
  isArrayInputSpecKey: () => isArrayInputSpecKey,
87
89
  isInputSpecKey: () => isInputSpecKey,
88
90
  isListed: () => isListed,
@@ -598,6 +600,25 @@ var NANO_BANANA_2_1_RATIOS = [
598
600
  "adaptive"
599
601
  ];
600
602
  var GEMINI_PROMPT_MAX_CHARS = 5e4;
603
+ var GPT_IMAGE_2_6_ANIMATION = {
604
+ frameSizes: [
605
+ { size: "288x288", minFrames: 2, maxFrames: 16 },
606
+ { size: "384x384", minFrames: 2, maxFrames: 16 },
607
+ { size: "512x288", minFrames: 2, maxFrames: 16 },
608
+ { size: "288x512", minFrames: 2, maxFrames: 16 },
609
+ { size: "512x512", minFrames: 2, maxFrames: 16 },
610
+ { size: "768x768", minFrames: 2, maxFrames: 12 }
611
+ ],
612
+ frameDurationMs: { min: 20, max: 2e3 },
613
+ defaultFrameCount: 9,
614
+ defaultFrameDurationMs: 200
615
+ };
616
+ var GPT_IMAGE_2_6_OUTPUT = {
617
+ imageFormats: ["png", "gif", "svg"],
618
+ backgrounds: ["auto", "opaque", "transparent"],
619
+ animation: GPT_IMAGE_2_6_ANIMATION,
620
+ svgModel: "gpt-6.1-sol"
621
+ };
601
622
  var GPT_IMAGE_PROMPT = { referenceSyntax: "numbered", maxChars: 32e3 };
602
623
  function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars, aspectRatios = GEMINI_RATIOS) {
603
624
  const prompt = { referenceSyntax: "caption" };
@@ -766,7 +787,8 @@ var IMAGE_MODELS = [
766
787
  qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
767
788
  references: { images: 16 },
768
789
  supports: ["quality", "count", "outputFormat"],
769
- prompt: GPT_IMAGE_PROMPT
790
+ prompt: GPT_IMAGE_PROMPT,
791
+ ...GPT_IMAGE_2_6_OUTPUT
770
792
  },
771
793
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
772
794
  usage: { ...IMAGE_USAGE3 },
@@ -801,7 +823,8 @@ var IMAGE_MODELS = [
801
823
  qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
802
824
  references: { images: 16 },
803
825
  supports: ["quality", "count", "outputFormat"],
804
- prompt: GPT_IMAGE_PROMPT
826
+ prompt: GPT_IMAGE_PROMPT,
827
+ ...GPT_IMAGE_2_6_OUTPUT
805
828
  },
806
829
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
807
830
  usage: { ...IMAGE_USAGE3 },
@@ -6174,6 +6197,44 @@ var VIDEO_MODELS = [
6174
6197
  lastFrameRequiresFirstFrame: true
6175
6198
  }
6176
6199
  },
6200
+ {
6201
+ // https://aistudio.google.com/docs/omni (2026-11-05): the 1.1 Interactions API with
6202
+ // 3-15 s output; first-to-last-frame and each extension stay at 3-10 s (the adapter
6203
+ // refuses more), extended clips stop at 30 s, and 11-15 s clips take one reference video.
6204
+ id: "gemini-omni-1.2-flash",
6205
+ aliases: ["gemini-omni-1.2-video", "gemini-omni-1.2-reference", "gemini-omni-1.2-edit"],
6206
+ label: "Gemini Omni 1.2 Flash",
6207
+ type: "video",
6208
+ adapter: "google-genai",
6209
+ providerModelId: "gemini-omni-1.2-flash",
6210
+ lifecycle: "active",
6211
+ exposure: ["cowork", "space_builder"],
6212
+ constraints: {
6213
+ aspectRatios: [...OMNI_RATIOS],
6214
+ resolutions: ["360p", "720p", "1080p", "4k"],
6215
+ durations: { min: 3, max: 15 },
6216
+ durationPresets: [3, 5, 8, 10, 15],
6217
+ references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
6218
+ sourceVideoSeconds: { max: 15 },
6219
+ supports: ["videoExtension", "lastFrame"],
6220
+ extension: { segmentSeconds: 10, maxTotalSeconds: 30, returns: "joined" },
6221
+ prompt: OMNI_PROMPT,
6222
+ audio: "always"
6223
+ },
6224
+ defaults: {},
6225
+ usage: { ...VIDEO_USAGE3 },
6226
+ pricingKind: "video_per_second",
6227
+ display: {
6228
+ provider: "google",
6229
+ logo: GOOGLE_LOGO3,
6230
+ description: "Google Gemini Omni Flash 1.2 conversational video generation, editing and extension; text, image, and up to 15-second video input, 3-15 second output at up to 4K and 24 FPS (start and end frames up to 10 seconds), extendable to 30 seconds."
6231
+ },
6232
+ capabilities: {
6233
+ acceptsSourceVideo: true,
6234
+ videoEdit: true,
6235
+ lastFrameRequiresFirstFrame: true
6236
+ }
6237
+ },
6177
6238
  {
6178
6239
  // vibe-triggers and Space Builder drop the ratio when a frame is wired; Cowork always sends it.
6179
6240
  id: "seedance-2.0",
@@ -8027,7 +8088,20 @@ var AspectRatioSchema = import_zod3.z.enum([
8027
8088
  var ImageSizeSchema = import_zod3.z.enum(["512", "1K", "2K", "4K"]);
8028
8089
  var VideoResolutionSchema = import_zod3.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
8029
8090
  var ImageQualitySchema = import_zod3.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
8030
- var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp"]);
8091
+ var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp", "gif", "svg"]);
8092
+ var ImageBackgroundSchema = import_zod3.z.enum(["auto", "opaque", "transparent"]);
8093
+ var AnimationLimitsSchema = import_zod3.z.looseObject({
8094
+ frameSizes: import_zod3.z.array(
8095
+ import_zod3.z.looseObject({
8096
+ size: import_zod3.z.string().regex(/^\d+x\d+$/u),
8097
+ minFrames: import_zod3.z.number().int().positive(),
8098
+ maxFrames: import_zod3.z.number().int().positive()
8099
+ })
8100
+ ).min(1),
8101
+ frameDurationMs: import_zod3.z.looseObject({ min: import_zod3.z.number().positive(), max: import_zod3.z.number().positive() }),
8102
+ defaultFrameCount: import_zod3.z.number().int().positive(),
8103
+ defaultFrameDurationMs: import_zod3.z.number().positive()
8104
+ });
8031
8105
  var RequiredInputSchema = import_zod3.z.enum(["firstFrame", "sourceVideo", "references", "sourceAudio"]);
8032
8106
  var SupportedOptionSchema = import_zod3.z.enum([
8033
8107
  "seed",
@@ -8181,6 +8255,10 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
8181
8255
  }).optional(),
8182
8256
  languages: import_zod3.z.array(LanguageOptionSchema).optional(),
8183
8257
  outputFormats: import_zod3.z.array(import_zod3.z.string().min(1)).min(1).optional(),
8258
+ imageFormats: import_zod3.z.array(OutputFormatSchema).min(1).optional(),
8259
+ backgrounds: import_zod3.z.array(ImageBackgroundSchema).min(1).optional(),
8260
+ animation: AnimationLimitsSchema.optional(),
8261
+ svgModel: import_zod3.z.string().min(1).optional(),
8184
8262
  sourceVideoPixels: VideoPixelLimitsSchema.optional(),
8185
8263
  sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod3.z.boolean().optional() }).optional(),
8186
8264
  // segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
@@ -13969,6 +14047,7 @@ var VEO_POLL_INTERVAL_MS = 5e3;
13969
14047
  var OMNI_POLL_INTERVAL_MS = 1e4;
13970
14048
  var RESULT_TIMEOUT_MS3 = 15 * 60 * 1e3;
13971
14049
  var OMNI_INLINE_LIMIT_BYTES = 4 * 1024 * 1024;
14050
+ var OMNI_FRAMES_MAX_SECONDS = 10;
13972
14051
  var MEDIA_PART_INLINE_LIMIT_BYTES = 10 * 1024 * 1024;
13973
14052
  var errorTextSchema = import_zod24.z.string();
13974
14053
  function isGoogleGenaiVideoKnown(providerModelId) {
@@ -14283,6 +14362,13 @@ async function generateOmniVideo(req, ctx, createGenAIClient) {
14283
14362
  model: modelId
14284
14363
  });
14285
14364
  }
14365
+ if ((extend || lastFrame !== void 0) && duration > OMNI_FRAMES_MAX_SECONDS) {
14366
+ throw new ModelKitError({
14367
+ code: "unsupported_option",
14368
+ message: `${modelId} ${extend ? "extension" : "start-and-end-frame video"} is at most ${OMNI_FRAMES_MAX_SECONDS} s; got ${duration} s`,
14369
+ model: modelId
14370
+ });
14371
+ }
14286
14372
  const task = extend ? "extend" : req.sourceVideo ? "edit" : firstFrame ? "image_to_video" : images.length > 0 || videos.length > 0 ? "reference_to_video" : "text_to_video";
14287
14373
  const isOmniV1 = providerModelId === "gemini-omni-flash-preview";
14288
14374
  const responseFormat = { type: "video", delivery: "uri" };
@@ -15977,7 +16063,37 @@ var lumaAdapter = {
15977
16063
  // src/adapters/openai-image.ts
15978
16064
  var import_openai2 = __toESM(require("openai"), 1);
15979
16065
  var import_zod28 = require("zod");
16066
+
16067
+ // src/adapters/svg-sanitize.ts
16068
+ var BLOCK_ELEMENTS = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[\s\S]*?<\/\1\s*>/giu;
16069
+ var SELF_CLOSING = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[^>]*\/>/giu;
16070
+ var EVENT_ATTRIBUTE = /\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/giu;
16071
+ var EXTERNAL_HREF = /\s+(xlink:)?href\s*=\s*("(?!#)[^"]*"|'(?!#)[^']*')/giu;
16072
+ var STYLE_IMPORT = /@import\b[^;]*;?/giu;
16073
+ var STILL_ACTIVE = /<(script|foreignObject|iframe|object|embed)\b|\son[a-z]+\s*=|javascript:|<!ENTITY|<\?xml-stylesheet/iu;
16074
+ function sanitizeSvg(svg, model) {
16075
+ const cleaned = svg.replace(BLOCK_ELEMENTS, "").replace(SELF_CLOSING, "").replace(EVENT_ATTRIBUTE, "").replace(EXTERNAL_HREF, "").replace(STYLE_IMPORT, "");
16076
+ if (!/<svg\b/iu.test(cleaned) || STILL_ACTIVE.test(cleaned)) {
16077
+ throw new ModelKitError({
16078
+ code: "provider_rejected",
16079
+ message: `${model} returned an SVG that could not be made safe`,
16080
+ provider: "openai-image",
16081
+ model,
16082
+ retryable: false
16083
+ });
16084
+ }
16085
+ return cleaned;
16086
+ }
16087
+
16088
+ // src/adapters/openai-image.ts
15980
16089
  var MAX_EDIT_REFERENCES = 16;
16090
+ var MIME_BY_FORMAT = {
16091
+ png: "image/png",
16092
+ jpeg: "image/jpeg",
16093
+ webp: "image/webp",
16094
+ gif: "image/gif",
16095
+ svg: "image/svg+xml"
16096
+ };
15981
16097
  function aspectRatioToSize(ratio, tier) {
15982
16098
  const TIER_LONG_EDGE = {
15983
16099
  "1K": 1024,
@@ -16089,7 +16205,6 @@ var openaiImageAdapter = {
16089
16205
  const isEdit = refs.length > 0;
16090
16206
  const quality = req.quality ?? (isEdit ? "medium" : "auto");
16091
16207
  const sdkQuality = quality;
16092
- const count2 = req.count !== void 0 && req.count > 1 ? { n: req.count } : {};
16093
16208
  let outputFormat = req.outputFormat;
16094
16209
  if (outputFormat === "webp") {
16095
16210
  ctx.warnings.push({
@@ -16101,35 +16216,50 @@ var openaiImageAdapter = {
16101
16216
  });
16102
16217
  outputFormat = "png";
16103
16218
  }
16104
- const format = outputFormat !== void 0 ? { output_format: outputFormat } : {};
16105
- const mime = outputFormat === "jpeg" ? "image/jpeg" : "image/png";
16219
+ if (isEdit && outputFormat === "svg") {
16220
+ throw new ModelKitError({
16221
+ code: "unsupported_option",
16222
+ message: `${ctx.model.id} cannot make an SVG from reference images`,
16223
+ provider: "openai-image",
16224
+ model: ctx.model.id,
16225
+ retryable: false
16226
+ });
16227
+ }
16228
+ const svgModel = ctx.model.constraints.svgModel;
16229
+ if (outputFormat === "svg" && !svgModel) {
16230
+ throw new ModelKitError({
16231
+ code: "unsupported_option",
16232
+ message: `${ctx.model.id} names no svgModel to write the SVG`,
16233
+ provider: "openai-image",
16234
+ model: ctx.model.id,
16235
+ retryable: false
16236
+ });
16237
+ }
16238
+ const params = {
16239
+ model: ctx.model.providerModelId,
16240
+ prompt: req.prompt,
16241
+ quality: sdkQuality,
16242
+ ...size !== void 0 && { size },
16243
+ // SVG takes no `n` at all (OpenAI: "Use n=1"), not even 1.
16244
+ ...req.count !== void 0 && req.count > 1 && outputFormat !== "svg" && { n: req.count },
16245
+ ...outputFormat !== void 0 && { output_format: outputFormat },
16246
+ ...req.background !== void 0 && { background: req.background },
16247
+ ...outputFormat === "gif" && req.animation?.frameCount !== void 0 && {
16248
+ frame_count: req.animation.frameCount
16249
+ },
16250
+ ...outputFormat === "gif" && req.animation?.frameDurationMs !== void 0 && {
16251
+ frame_duration_ms: req.animation.frameDurationMs
16252
+ },
16253
+ ...outputFormat === "svg" && { svg: { model: svgModel } }
16254
+ };
16255
+ const mime = MIME_BY_FORMAT[outputFormat ?? "png"];
16106
16256
  const retryOptions = mediaRetryOptions(ctx.call, ctx.signal);
16107
16257
  const response = await withRetry(async () => {
16108
16258
  try {
16109
16259
  if (!isEdit) {
16110
- if (size !== void 0) {
16111
- return await client2.images.generate(
16112
- {
16113
- model: ctx.model.providerModelId,
16114
- prompt: req.prompt,
16115
- size,
16116
- quality: sdkQuality,
16117
- ...count2,
16118
- ...format
16119
- },
16120
- { signal: ctx.signal }
16121
- );
16122
- }
16123
- return await client2.images.generate(
16124
- {
16125
- model: ctx.model.providerModelId,
16126
- prompt: req.prompt,
16127
- quality: sdkQuality,
16128
- ...count2,
16129
- ...format
16130
- },
16131
- { signal: ctx.signal }
16132
- );
16260
+ return await client2.images.generate(params, {
16261
+ signal: ctx.signal
16262
+ });
16133
16263
  }
16134
16264
  const files = await Promise.all(
16135
16265
  refs.slice(0, MAX_EDIT_REFERENCES).map(async (ref, i) => {
@@ -16144,37 +16274,19 @@ var openaiImageAdapter = {
16144
16274
  );
16145
16275
  const single = files.length === 1 ? files[0] : void 0;
16146
16276
  const imageInput = single ?? files;
16147
- if (size !== void 0) {
16148
- return await client2.images.edit(
16149
- {
16150
- model: ctx.model.providerModelId,
16151
- image: imageInput,
16152
- prompt: req.prompt,
16153
- size,
16154
- quality: sdkQuality,
16155
- ...count2,
16156
- ...format
16157
- },
16158
- { signal: ctx.signal }
16159
- );
16160
- }
16161
16277
  return await client2.images.edit(
16162
- {
16163
- model: ctx.model.providerModelId,
16164
- image: imageInput,
16165
- prompt: req.prompt,
16166
- quality: sdkQuality,
16167
- ...count2,
16168
- ...format
16169
- },
16278
+ { ...params, image: imageInput },
16170
16279
  { signal: ctx.signal }
16171
16280
  );
16172
16281
  } catch (cause) {
16173
16282
  throw toProviderError2(cause, ctx);
16174
16283
  }
16175
16284
  }, retryOptions);
16285
+ const decode = (b64) => outputFormat === "svg" ? new TextEncoder().encode(
16286
+ sanitizeSvg(new TextDecoder().decode(base64ToBytes(b64)), ctx.model.id)
16287
+ ) : base64ToBytes(b64);
16176
16288
  const images = (response.data ?? []).flatMap(
16177
- (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime }] : []
16289
+ (item) => item.b64_json ? [{ bytes: decode(item.b64_json), mime }] : []
16178
16290
  );
16179
16291
  if (images.length === 0)
16180
16292
  throw classifyHttpError(
@@ -17758,6 +17870,155 @@ function fileCatalogCache(path) {
17758
17870
  };
17759
17871
  }
17760
17872
 
17873
+ // src/resolve-image-output.ts
17874
+ var BASE_FORMATS = ["png", "jpeg", "webp"];
17875
+ var ONE_K_FRAME_PIXELS = 288 * 512;
17876
+ function imageOutputFormats(model) {
17877
+ return model.constraints.imageFormats ?? BASE_FORMATS;
17878
+ }
17879
+ function animationTier(model, frameSize) {
17880
+ const [w, h] = frameSize.split("x").map(Number);
17881
+ const tier = (w ?? 0) * (h ?? 0) <= ONE_K_FRAME_PIXELS ? "1K" : "2K";
17882
+ const offered = model.constraints.sizes ?? ["1K", "2K", "4K"];
17883
+ if (offered.includes(tier)) return tier;
17884
+ return offered[offered.length - 1] ?? tier;
17885
+ }
17886
+ function refuse(model, message) {
17887
+ throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
17888
+ }
17889
+ function clamp(value, min, max) {
17890
+ return Math.min(Math.max(value, min), max);
17891
+ }
17892
+ function applyAnimation(model, req, onUnsupported, warnings) {
17893
+ const limits = model.constraints.animation;
17894
+ if (!limits) return;
17895
+ const sizes = limits.frameSizes;
17896
+ let frameSize = sizes.find((s) => s.size === req.exactSize);
17897
+ if (!frameSize) {
17898
+ const fallback = sizes[0];
17899
+ if (req.exactSize !== void 0) {
17900
+ if (onUnsupported === "error") {
17901
+ refuse(
17902
+ model,
17903
+ `${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
17904
+ );
17905
+ }
17906
+ warnings.push({
17907
+ code: "option_ignored",
17908
+ field: "exactSize",
17909
+ from: req.exactSize,
17910
+ to: fallback.size,
17911
+ message: `${model.id} has no ${req.exactSize} GIF frame; using ${fallback.size}`
17912
+ });
17913
+ }
17914
+ frameSize = fallback;
17915
+ }
17916
+ req.exactSize = frameSize.size;
17917
+ delete req.aspectRatio;
17918
+ const animation = { ...req.animation };
17919
+ const asked = animation.frameCount;
17920
+ const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
17921
+ if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
17922
+ if (onUnsupported === "error") {
17923
+ refuse(
17924
+ model,
17925
+ `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
17926
+ );
17927
+ }
17928
+ const snapped = clamp(Math.round(frames), frameSize.minFrames, frameSize.maxFrames);
17929
+ warnings.push({
17930
+ code: "option_ignored",
17931
+ field: "animation.frameCount",
17932
+ from: frames,
17933
+ to: snapped,
17934
+ message: `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; using ${snapped}`
17935
+ });
17936
+ animation.frameCount = snapped;
17937
+ } else {
17938
+ animation.frameCount = frames;
17939
+ }
17940
+ const { min, max } = limits.frameDurationMs;
17941
+ const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
17942
+ if (duration < min || duration > max) {
17943
+ if (onUnsupported === "error") {
17944
+ refuse(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
17945
+ }
17946
+ const snapped = clamp(duration, min, max);
17947
+ warnings.push({
17948
+ code: "option_ignored",
17949
+ field: "animation.frameDurationMs",
17950
+ from: duration,
17951
+ to: snapped,
17952
+ message: `${model.id} shows each GIF frame ${min} to ${max} ms; using ${snapped}`
17953
+ });
17954
+ animation.frameDurationMs = snapped;
17955
+ } else {
17956
+ animation.frameDurationMs = duration;
17957
+ }
17958
+ req.animation = animation;
17959
+ req.size = animationTier(model, frameSize.size);
17960
+ }
17961
+ function applyImageOutputRules(model, req, onUnsupported, warnings) {
17962
+ const c = model.constraints;
17963
+ const format = req.outputFormat;
17964
+ if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
17965
+ if (onUnsupported === "error") {
17966
+ refuse(
17967
+ model,
17968
+ `${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
17969
+ );
17970
+ }
17971
+ warnings.push({
17972
+ code: "option_ignored",
17973
+ field: "outputFormat",
17974
+ from: format,
17975
+ message: `${model.id} does not offer ${format}; ignored`
17976
+ });
17977
+ delete req.outputFormat;
17978
+ }
17979
+ if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
17980
+ if (onUnsupported === "error") {
17981
+ refuse(model, `${model.id} does not offer background ${req.background}`);
17982
+ }
17983
+ warnings.push({
17984
+ code: "option_ignored",
17985
+ field: "background",
17986
+ from: req.background,
17987
+ message: `${model.id} does not offer background ${req.background}; ignored`
17988
+ });
17989
+ delete req.background;
17990
+ }
17991
+ if (req.outputFormat === "gif") {
17992
+ applyAnimation(model, req, onUnsupported, warnings);
17993
+ } else if (req.animation !== void 0) {
17994
+ warnings.push({
17995
+ code: "option_ignored",
17996
+ field: "animation",
17997
+ message: `animation applies to GIF output only; ignored`
17998
+ });
17999
+ delete req.animation;
18000
+ }
18001
+ if (req.outputFormat === "svg") {
18002
+ if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
18003
+ if ((req.references ?? []).length > 0) {
18004
+ refuse(model, `${model.label} cannot make an SVG from reference images`);
18005
+ }
18006
+ if ((req.count ?? 1) > 1) {
18007
+ if (onUnsupported === "error") {
18008
+ refuse(model, `${model.label} makes one SVG per call`);
18009
+ }
18010
+ warnings.push({
18011
+ code: "option_ignored",
18012
+ field: "count",
18013
+ from: req.count,
18014
+ to: 1,
18015
+ message: `${model.id} makes one SVG per call; using 1`
18016
+ });
18017
+ req.count = 1;
18018
+ }
18019
+ }
18020
+ }
18021
+
17761
18022
  // src/resolve-lists.ts
17762
18023
  function preview(listed2) {
17763
18024
  const shown = listed2.slice(0, 12).join(", ");
@@ -18070,6 +18331,7 @@ function resolveImageOptions(model, request, onUnsupported = "error") {
18070
18331
  "points",
18071
18332
  "boxes"
18072
18333
  ]);
18334
+ applyImageOutputRules(model, merged, onUnsupported, warnings);
18073
18335
  const factor = merged.scaleFactor;
18074
18336
  if (factor !== void 0 && c.scaleFactors && !c.scaleFactors.includes(factor)) {
18075
18337
  if (onUnsupported === "error") {
@@ -18406,7 +18668,7 @@ function setOrDelete(req, field, refs) {
18406
18668
  else delete req[field];
18407
18669
  }
18408
18670
  function isImageFormat(format) {
18409
- return format === "png" || format === "jpeg" || format === "webp";
18671
+ return format === "png" || format === "jpeg" || format === "webp" || format === "gif" || format === "svg";
18410
18672
  }
18411
18673
  function stripUndefined(obj) {
18412
18674
  return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
@@ -18613,7 +18875,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
18613
18875
  }
18614
18876
 
18615
18877
  // src/resolve-voice.ts
18616
- function refuse(model, code, message) {
18878
+ function refuse2(model, code, message) {
18617
18879
  return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
18618
18880
  }
18619
18881
  function checkSample(model, sample, index) {
@@ -18622,7 +18884,7 @@ function checkSample(model, sample, index) {
18622
18884
  if (limits === void 0 || length === void 0) return;
18623
18885
  if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
18624
18886
  const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
18625
- throw refuse(
18887
+ throw refuse2(
18626
18888
  model,
18627
18889
  "unsupported_option",
18628
18890
  `takes samples of ${range2}; sample ${index + 1} is ${length} s`
@@ -18631,11 +18893,11 @@ function checkSample(model, sample, index) {
18631
18893
  }
18632
18894
  function resolveVoiceCloneOptions(model, request) {
18633
18895
  const title = request.title.trim();
18634
- if (!title) throw refuse(model, "missing_input", "needs a title");
18635
- if (request.samples.length === 0) throw refuse(model, "missing_input", "needs a voice sample");
18896
+ if (!title) throw refuse2(model, "missing_input", "needs a title");
18897
+ if (request.samples.length === 0) throw refuse2(model, "missing_input", "needs a voice sample");
18636
18898
  const max = model.constraints.references?.audios;
18637
18899
  if (max !== void 0 && request.samples.length > max) {
18638
- throw refuse(
18900
+ throw refuse2(
18639
18901
  model,
18640
18902
  "unsupported_option",
18641
18903
  `takes up to ${max} samples; got ${request.samples.length}`
@@ -18645,7 +18907,7 @@ function resolveVoiceCloneOptions(model, request) {
18645
18907
  const total = model.constraints.references?.audioSeconds?.total;
18646
18908
  const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
18647
18909
  if (total !== void 0 && seconds3 > total) {
18648
- throw refuse(
18910
+ throw refuse2(
18649
18911
  model,
18650
18912
  "unsupported_option",
18651
18913
  `takes up to ${total} s of samples; got ${seconds3} s`
@@ -18654,7 +18916,7 @@ function resolveVoiceCloneOptions(model, request) {
18654
18916
  for (const field of ["transcript", "designSignature"]) {
18655
18917
  const set = request.samples.filter((s) => s[field]?.trim()).length;
18656
18918
  if (set !== 0 && set !== request.samples.length) {
18657
- throw refuse(model, "missing_input", `needs ${field} on every sample or on none`);
18919
+ throw refuse2(model, "missing_input", `needs ${field} on every sample or on none`);
18658
18920
  }
18659
18921
  }
18660
18922
  return { request: { ...request, model: model.id, title }, warnings: [] };
@@ -18662,10 +18924,10 @@ function resolveVoiceCloneOptions(model, request) {
18662
18924
  function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18663
18925
  const warnings = [];
18664
18926
  const prompt = request.prompt.trim();
18665
- if (!prompt) throw refuse(model, "missing_input", "needs a voice description");
18927
+ if (!prompt) throw refuse2(model, "missing_input", "needs a voice description");
18666
18928
  const maxChars = promptConventions(model).maxChars;
18667
18929
  if (maxChars !== void 0 && prompt.length > maxChars) {
18668
- throw refuse(
18930
+ throw refuse2(
18669
18931
  model,
18670
18932
  "unsupported_option",
18671
18933
  `takes up to ${maxChars} characters; got ${prompt.length}`
@@ -18676,7 +18938,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18676
18938
  const preview2 = request.previewText?.trim();
18677
18939
  if (preview2) {
18678
18940
  if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
18679
- throw refuse(
18941
+ throw refuse2(
18680
18942
  model,
18681
18943
  "unsupported_option",
18682
18944
  `takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
@@ -18692,7 +18954,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18692
18954
  const cap = limits?.maxCandidates ?? count2;
18693
18955
  if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
18694
18956
  if (onUnsupported === "error" || !Number.isInteger(count2)) {
18695
- throw refuse(
18957
+ throw refuse2(
18696
18958
  model,
18697
18959
  "unsupported_option",
18698
18960
  `returns 1-${cap} candidates; got ${count2}`
@@ -20202,6 +20464,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
20202
20464
  VideoResolutionSchema,
20203
20465
  adapterServesType,
20204
20466
  aiSdkTextAdapter,
20467
+ animationTier,
20205
20468
  arkAdapter,
20206
20469
  aspectRatioToSize,
20207
20470
  byokProviderForModel,
@@ -20227,6 +20490,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
20227
20490
  googleImageAdapter,
20228
20491
  hasAwsCredentials,
20229
20492
  higgsfieldAdapter,
20493
+ imageOutputFormats,
20230
20494
  isArrayInputSpecKey,
20231
20495
  isInputSpecKey,
20232
20496
  isListed,