@picsart/ai-sdk 6.37.0 → 6.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +78 -22
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1065,7 +1065,7 @@ type ModelInputById = {
1065
1065
  negativePrompt?: string;
1066
1066
  aspectRatio?: "21:9" | "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "9:21";
1067
1067
  resolution?: "480p" | "720p" | "1080p";
1068
- numFrames?: number;
1068
+ duration?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
1069
1069
  fps?: number;
1070
1070
  sourceScale?: number;
1071
1071
  videoStrength?: number;
package/index.js CHANGED
@@ -2198,6 +2198,47 @@ var LTX_23_REFRAME_RESOLUTIONS = ["720p", "1080p"];
2198
2198
  var LTX_23_REFRAME_AR = ["16:9", "9:16", "1:1", "4:5", "5:4"];
2199
2199
  var LTX_23_OUTPAINT_RESOLUTIONS = ["480p", "720p", "1080p"];
2200
2200
  var LTX_23_OUTPAINT_AR = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16", "9:21"];
2201
+ var LTX_23_OUTPAINT_DURATIONS = [
2202
+ 1,
2203
+ 2,
2204
+ 3,
2205
+ 4,
2206
+ 5,
2207
+ 6,
2208
+ 7,
2209
+ 8,
2210
+ 9,
2211
+ 10,
2212
+ 11,
2213
+ 12,
2214
+ 13,
2215
+ 14,
2216
+ 15,
2217
+ 16,
2218
+ 17,
2219
+ 18,
2220
+ 19,
2221
+ 20
2222
+ ];
2223
+ var LTX_23_OUTPAINT_MIN_FRAMES = 9;
2224
+ var LTX_23_OUTPAINT_MAX_FRAMES = 481;
2225
+ var LTX_23_OUTPAINT_FPS_MAX = 60;
2226
+ var ltxOutpaintDurationConstraints = [];
2227
+ for (let fps = 1; fps <= LTX_23_OUTPAINT_FPS_MAX; fps++) {
2228
+ const allowed = LTX_23_OUTPAINT_DURATIONS.filter(
2229
+ (d) => d * fps >= LTX_23_OUTPAINT_MIN_FRAMES && d * fps <= LTX_23_OUTPAINT_MAX_FRAMES
2230
+ );
2231
+ if (allowed.length === LTX_23_OUTPAINT_DURATIONS.length) continue;
2232
+ ltxOutpaintDurationConstraints.push({
2233
+ when: { fps: { is: fps } },
2234
+ then: {
2235
+ duration: {
2236
+ allowed,
2237
+ reason: `At ${fps} fps the clip must run ${allowed[0]}\u2013${allowed[allowed.length - 1]}s (the ${LTX_23_OUTPAINT_MIN_FRAMES}\u2013${LTX_23_OUTPAINT_MAX_FRAMES}-frame window).`
2238
+ }
2239
+ }
2240
+ });
2241
+ }
2201
2242
  var LTX_25_AR = ["16:9", "9:16"];
2202
2243
  var LTX_25_PRO_RESOLUTIONS = ["720p", "1080p"];
2203
2244
  var LTX_25_FAST_RESOLUTIONS = ["720p", "1080p", "1440p", "2160p"];
@@ -2543,8 +2584,11 @@ var { MODELS: MODELS2 } = defineModels("ltx", [
2543
2584
  ...params.negativePrompt(),
2544
2585
  ...params.aspectRatio(LTX_23_OUTPAINT_AR),
2545
2586
  ...params.resolution(LTX_23_OUTPAINT_RESOLUTIONS, "720p"),
2546
- ...p.range("numFrames", 9, 481, 121, { label: "Frames" }),
2547
- ...p.range("fps", 1, 60, 24, { label: "FPS" }),
2587
+ // Duration is an enum; fps stays a slider. The per-fps constraint below
2588
+ // trims the duration options, and the builder derives the wire's num_frames
2589
+ // (clamped) from duration × fps.
2590
+ ...params.duration(LTX_23_OUTPAINT_DURATIONS, 6),
2591
+ ...p.range("fps", 1, 60, 24, { step: 1, label: "FPS" }),
2548
2592
  // 1.0 fits the source as large as the canvas allows; lower values zoom it
2549
2593
  // out and leave a wider generated border, which the vendor calls less stable.
2550
2594
  ...p.range("sourceScale", 0.25, 1, 1, { step: 0.05, label: "Source Scale" }),
@@ -2559,7 +2603,10 @@ var { MODELS: MODELS2 } = defineModels("ltx", [
2559
2603
  ...p.boolean("enableSafetyChecker", true, "Safety Checker"),
2560
2604
  // Default-less on purpose: unset means the vendor picks a random seed.
2561
2605
  ...params.seed()
2562
- }
2606
+ },
2607
+ // Raising fps packs more frames per second, so it shortens the longest clip
2608
+ // that fits the vendor's 481-frame ceiling — hence the duration options trim.
2609
+ constraints: ltxOutpaintDurationConstraints
2563
2610
  },
2564
2611
  // ── LTX 2.5 ──────────────────────────────────────────────────────
2565
2612
  // One entry per tier: text-to-video on `workflow`, image-to-video on
@@ -11043,25 +11090,34 @@ var buildLtx23ReframePayload = (input) => ({
11043
11090
  ...input.resolution ? { resolution: input.resolution } : {},
11044
11091
  ...input.aspectRatio ? { aspect_ratio: input.aspectRatio } : {}
11045
11092
  });
11046
- var buildLtx23OutpaintPayload = (input) => ({
11047
- prompt: input.prompt,
11048
- video_url: input.videoUrl,
11049
- ...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
11050
- ...input.aspectRatio ? { aspect_ratio: input.aspectRatio } : {},
11051
- ...input.resolution ? { output_resolution: input.resolution } : {},
11052
- ...input.numFrames != null ? { num_frames: input.numFrames } : {},
11053
- ...input.fps != null ? { frames_per_second: input.fps } : {},
11054
- ...input.sourceScale != null ? { source_scale: input.sourceScale } : {},
11055
- ...input.videoStrength != null ? { video_strength: input.videoStrength } : {},
11056
- ...input.cfgScale != null ? { guidance_scale: input.cfgScale } : {},
11057
- ...input.numInferenceSteps != null ? { num_inference_steps: input.numInferenceSteps } : {},
11058
- ...input.videoQuality ? { video_quality: input.videoQuality } : {},
11059
- ...input.videoWriteMode ? { video_write_mode: input.videoWriteMode } : {},
11060
- ...input.seed != null ? { seed: input.seed } : {},
11061
- enable_prompt_expansion: input.enhancePrompt ?? true,
11062
- generate_audio: input.generateAudio ?? true,
11063
- enable_safety_checker: input.enableSafetyChecker ?? true
11064
- });
11093
+ var OUTPAINT_NUM_FRAMES_MIN = 9;
11094
+ var OUTPAINT_NUM_FRAMES_MAX = 481;
11095
+ var buildLtx23OutpaintPayload = (input) => {
11096
+ const fps = input.fps ?? 24;
11097
+ const numFrames = input.duration != null ? Math.min(
11098
+ OUTPAINT_NUM_FRAMES_MAX,
11099
+ Math.max(OUTPAINT_NUM_FRAMES_MIN, Math.round(input.duration * fps))
11100
+ ) : void 0;
11101
+ return {
11102
+ prompt: input.prompt,
11103
+ video_url: input.videoUrl,
11104
+ ...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
11105
+ ...input.aspectRatio ? { aspect_ratio: input.aspectRatio } : {},
11106
+ ...input.resolution ? { output_resolution: input.resolution } : {},
11107
+ ...numFrames != null ? { num_frames: numFrames } : {},
11108
+ ...input.fps != null ? { frames_per_second: input.fps } : {},
11109
+ ...input.sourceScale != null ? { source_scale: input.sourceScale } : {},
11110
+ ...input.videoStrength != null ? { video_strength: input.videoStrength } : {},
11111
+ ...input.cfgScale != null ? { guidance_scale: input.cfgScale } : {},
11112
+ ...input.numInferenceSteps != null ? { num_inference_steps: input.numInferenceSteps } : {},
11113
+ ...input.videoQuality ? { video_quality: input.videoQuality } : {},
11114
+ ...input.videoWriteMode ? { video_write_mode: input.videoWriteMode } : {},
11115
+ ...input.seed != null ? { seed: input.seed } : {},
11116
+ enable_prompt_expansion: input.enhancePrompt ?? true,
11117
+ generate_audio: input.generateAudio ?? true,
11118
+ enable_safety_checker: input.enableSafetyChecker ?? true
11119
+ };
11120
+ };
11065
11121
  registerPayloads(MODELS2, {
11066
11122
  "ltx-v2.5-pro": buildLtx25ProT2VPayload,
11067
11123
  "ltx-v2.5-fast": buildLtx25FastT2VPayload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.37.0",
3
+ "version": "6.38.0",
4
4
  "type": "module",
5
5
  "description": "Type-safe SDK for 100+ AI models — image, video, audio, and text generation with Picsart",
6
6
  "license": "MIT",