@picsart/ai-sdk 5.19.1 → 5.21.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.
- package/index.d.ts +23 -3
- package/index.js +55 -17
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -227,6 +227,13 @@ type ModelInputById = {
|
|
|
227
227
|
count?: 1 | 2 | 4 | 6 | 8 | 10;
|
|
228
228
|
imageUrls?: string[];
|
|
229
229
|
};
|
|
230
|
+
"flux-video-upscale": {
|
|
231
|
+
videoUrl: string;
|
|
232
|
+
upscaleFactor?: number;
|
|
233
|
+
creativity?: 0 | 1;
|
|
234
|
+
prompt?: string;
|
|
235
|
+
safetyTolerance?: number;
|
|
236
|
+
};
|
|
230
237
|
"gemini-2.5-flash-image": {
|
|
231
238
|
prompt: string;
|
|
232
239
|
aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "2:3" | "21:9";
|
|
@@ -2180,9 +2187,10 @@ interface ModelDefinition {
|
|
|
2180
2187
|
editEstimatedTime?: number | Record<string, number>;
|
|
2181
2188
|
testTimeout?: number;
|
|
2182
2189
|
/**
|
|
2183
|
-
* Per-model polling overrides for async jobs.
|
|
2184
|
-
* 2s ×
|
|
2185
|
-
*
|
|
2190
|
+
* Per-model polling overrides for async jobs. Narrows or widens the mode
|
|
2191
|
+
* default (video 2s × 1800 ≈ 1 h; image/audio/text 1s × 1200 ≈ 20 min) for
|
|
2192
|
+
* models whose generations don't fit it. Explicit per-call poll options
|
|
2193
|
+
* still win.
|
|
2186
2194
|
*/
|
|
2187
2195
|
pollOptions?: {
|
|
2188
2196
|
intervalMs?: number;
|
|
@@ -2389,6 +2397,17 @@ interface GenerateTextResult {
|
|
|
2389
2397
|
/** Options for individual generate() / submit() calls. */
|
|
2390
2398
|
interface GenerateOptions {
|
|
2391
2399
|
signal?: AbortSignal;
|
|
2400
|
+
/**
|
|
2401
|
+
* Poll interval for the async status loop, in ms. Overrides the model's
|
|
2402
|
+
* `pollOptions` and the mode default (video 2s; image/audio/text 1s).
|
|
2403
|
+
*/
|
|
2404
|
+
intervalMs?: number;
|
|
2405
|
+
/**
|
|
2406
|
+
* Max poll attempts before the call throws a timeout. Overrides the model's
|
|
2407
|
+
* `pollOptions` and the mode default (video 1800 ≈ 1 hour;
|
|
2408
|
+
* image/audio/text 1200 ≈ 20 min).
|
|
2409
|
+
*/
|
|
2410
|
+
maxAttempts?: number;
|
|
2392
2411
|
/** Save to a specific subfolder instead of the root (legacy — used by SDK DriveConfig). */
|
|
2393
2412
|
folder?: DriveFolder;
|
|
2394
2413
|
/** Save result to Picsart Drive via backend. Injected into the workflow payload. */
|
|
@@ -2493,6 +2512,7 @@ declare const Models: {
|
|
|
2493
2512
|
readonly Flux3Video: "flux-3-video";
|
|
2494
2513
|
readonly FluxKontextMax: "flux-kontext-max";
|
|
2495
2514
|
readonly FluxKontextPro: "flux-kontext-pro";
|
|
2515
|
+
readonly FluxVideoUpscale: "flux-video-upscale";
|
|
2496
2516
|
readonly Gemini25FlashImage: "gemini-2.5-flash-image";
|
|
2497
2517
|
readonly Gemini25FlashTts: "gemini-2.5-flash-tts";
|
|
2498
2518
|
readonly Gemini25ProTts: "gemini-2.5-pro-tts";
|
package/index.js
CHANGED
|
@@ -3129,9 +3129,6 @@ var { MODELS: MODELS10 } = defineModels("wan", [
|
|
|
3129
3129
|
description: "Wan 3.0 all-in-one \u2014 text, image/video/audio references, and start/end frames with adaptive ratio, intelligent duration, and audio.",
|
|
3130
3130
|
features: [...wanV3Features],
|
|
3131
3131
|
constraints: wanV3Constraints,
|
|
3132
|
-
// Generations at 1080P / long durations can outlast the global 10-min
|
|
3133
|
-
// polling default — widen to 5s × 360 attempts (30 min).
|
|
3134
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3135
3132
|
paramConfig: { ...wanV3ParamConfig }
|
|
3136
3133
|
},
|
|
3137
3134
|
{
|
|
@@ -3146,7 +3143,6 @@ var { MODELS: MODELS10 } = defineModels("wan", [
|
|
|
3146
3143
|
description: "Wan 3.0 Prime \u2014 the same all-in-one model as Wan 3.0, up to 7x faster.",
|
|
3147
3144
|
features: [...wanV3Features],
|
|
3148
3145
|
constraints: wanV3Constraints,
|
|
3149
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3150
3146
|
paramConfig: { ...wanV3ParamConfig }
|
|
3151
3147
|
}
|
|
3152
3148
|
]);
|
|
@@ -3786,12 +3782,6 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
|
|
|
3786
3782
|
badge: ["new", "premium", "hot"],
|
|
3787
3783
|
description: "Latest cinematic video with audio, multi-reference input, and mp4/mov output. Up to 30s.",
|
|
3788
3784
|
features: [feat("Reference Image", "frame"), feat("Start/End Frame", "frame"), feat("Audio", "audio"), feat("1080p", "resolution"), feat("4-30 sec", "duration")],
|
|
3789
|
-
// 1080p / 30s runs, and the whole extend path, outlast the global 10-min
|
|
3790
|
-
// polling default: measured p90 for seedance-2.5-video-extend sits above
|
|
3791
|
-
// the 600s ceiling. Widened to 5s × 360 attempts (30 min), same request
|
|
3792
|
-
// count, 3x the wall clock. Deliberately NOT derived from estimatedTime,
|
|
3793
|
-
// which understates seedance latency by ~10x.
|
|
3794
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3795
3785
|
paramConfig: {
|
|
3796
3786
|
...params.prompt(),
|
|
3797
3787
|
...params.aspectRatio(SEEDANCE_AR),
|
|
@@ -3821,7 +3811,6 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
|
|
|
3821
3811
|
badge: ["new", "premium", "hot"],
|
|
3822
3812
|
description: "Edit video \u2014 replace subjects, add or remove objects, restyle scenes with reference images.",
|
|
3823
3813
|
features: [feat("Video Input", "input"), feat("Multi-Image Input", "input"), feat("Audio", "audio"), feat("1080p", "resolution"), feat("Source length", "duration")],
|
|
3824
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3825
3814
|
paramConfig: {
|
|
3826
3815
|
...params.prompt(),
|
|
3827
3816
|
// Editing mode: aspect ratio is fixed to 'adaptive' and duration is
|
|
@@ -3848,7 +3837,6 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
|
|
|
3848
3837
|
badge: ["new", "premium", "hot"],
|
|
3849
3838
|
description: "Stitch up to 10 clips into one continuous, extended video.",
|
|
3850
3839
|
features: [feat("Multi-Video Input", "input"), feat("Audio", "audio"), feat("1080p", "resolution"), feat("4-30 sec", "duration")],
|
|
3851
|
-
pollOptions: { intervalMs: 5e3, maxAttempts: 360 },
|
|
3852
3840
|
paramConfig: {
|
|
3853
3841
|
...params.prompt(),
|
|
3854
3842
|
// Extension mode: aspect ratio is locked to 'adaptive' (vendor rule);
|
|
@@ -5506,6 +5494,36 @@ var { MODELS: MODELS21 } = defineModels("flux", [
|
|
|
5506
5494
|
// draft: fast low-step preview.
|
|
5507
5495
|
...p.boolean("draft", false, "Draft")
|
|
5508
5496
|
}
|
|
5497
|
+
},
|
|
5498
|
+
{
|
|
5499
|
+
// Pure pass-through: the worker Command takes the SDK's own field names
|
|
5500
|
+
// (videoUrl, upscaleFactor, creativity, prompt, safetyTolerance) — no
|
|
5501
|
+
// payload builder needed. webhookUrl is polling plumbing, not surfaced
|
|
5502
|
+
// (same as flux-3-video).
|
|
5503
|
+
id: "flux-video-upscale",
|
|
5504
|
+
name: "Flux Video Upscale",
|
|
5505
|
+
workflow: "flux/v1/video-upscale",
|
|
5506
|
+
mode: "video",
|
|
5507
|
+
inputType: "v2v",
|
|
5508
|
+
addedAt: "2026-08-28",
|
|
5509
|
+
estimatedTime: 180,
|
|
5510
|
+
description: "Upscale videos toward 4K (1.5x\u20133x) in precise (source-faithful) or creative (detail-enhancing) mode. Source clips up to 20 seconds and 2K.",
|
|
5511
|
+
features: [
|
|
5512
|
+
feat("Upscale", "quality"),
|
|
5513
|
+
feat("Video Required", "input"),
|
|
5514
|
+
feat("Up to 4K", "resolution")
|
|
5515
|
+
],
|
|
5516
|
+
paramConfig: {
|
|
5517
|
+
// Vendor source caps: 20s, 50 MB, 2560x1440 (2K).
|
|
5518
|
+
...params.videoInput("Source Video", "asset", true, 20, 1440, 50 * 1024 * 1024),
|
|
5519
|
+
...p.range("upscaleFactor", 1.5, 3, 2, { step: 0.5, label: "Upscale Factor" }),
|
|
5520
|
+
// Vendor switch: 0 preserves the source precisely; 1 (default) allows
|
|
5521
|
+
// creative detail enhancement and is the more expensive pricing tier.
|
|
5522
|
+
...p.enum("creativity", [{ id: 0, label: "Precise" }, { id: 1, label: "Creative" }], 1, { label: "Creativity" }),
|
|
5523
|
+
...params.prompt({ required: false }),
|
|
5524
|
+
// Moderation level: 0 (strict) … 4 (permissive).
|
|
5525
|
+
...p.range("safetyTolerance", 0, 4, 2, { label: "Safety Tolerance" })
|
|
5526
|
+
}
|
|
5509
5527
|
}
|
|
5510
5528
|
]);
|
|
5511
5529
|
|
|
@@ -9874,6 +9892,23 @@ function createCatalogs(transport, options) {
|
|
|
9874
9892
|
}
|
|
9875
9893
|
|
|
9876
9894
|
// src/client/index.ts
|
|
9895
|
+
var MODE_POLL_DEFAULTS = {
|
|
9896
|
+
video: { intervalMs: 2e3, maxAttempts: 1800 },
|
|
9897
|
+
// 2s × 1800 = 1 hour
|
|
9898
|
+
image: { intervalMs: 1e3, maxAttempts: 1200 },
|
|
9899
|
+
// 1s × 1200 = 20 min
|
|
9900
|
+
audio: { intervalMs: 1e3, maxAttempts: 1200 },
|
|
9901
|
+
// 1s × 1200 = 20 min
|
|
9902
|
+
text: { intervalMs: 1e3, maxAttempts: 1200 }
|
|
9903
|
+
// 1s × 1200 = 20 min
|
|
9904
|
+
};
|
|
9905
|
+
function resolvePollOptions(model, overrides) {
|
|
9906
|
+
const resolved = { ...MODE_POLL_DEFAULTS[model.mode], ...model.pollOptions };
|
|
9907
|
+
if (overrides?.intervalMs !== void 0) resolved.intervalMs = overrides.intervalMs;
|
|
9908
|
+
if (overrides?.maxAttempts !== void 0) resolved.maxAttempts = overrides.maxAttempts;
|
|
9909
|
+
if (overrides?.signal !== void 0) resolved.signal = overrides.signal;
|
|
9910
|
+
return resolved;
|
|
9911
|
+
}
|
|
9877
9912
|
function createClient(config) {
|
|
9878
9913
|
const isConfig = isClientConfig(config);
|
|
9879
9914
|
const transport = isConfig ? buildTransport(config) : config;
|
|
@@ -9883,7 +9918,8 @@ function createClient(config) {
|
|
|
9883
9918
|
const catalogs = createCatalogs(transport, isConfig ? config.catalogs : void 0);
|
|
9884
9919
|
const driveConfig = isConfig ? config.drive : void 0;
|
|
9885
9920
|
const driveClient = isConfig && driveConfig ? createDriveClient(resolveFetch(config), config.apiUrl, driveConfig.folder) : null;
|
|
9886
|
-
async function executeModel(model, workflow, payload,
|
|
9921
|
+
async function executeModel(model, workflow, payload, options) {
|
|
9922
|
+
const signal = options?.signal;
|
|
9887
9923
|
if (model.syncExecute || !supportsSubmit) {
|
|
9888
9924
|
const syncResponse = await client.run(
|
|
9889
9925
|
{ workflow, payload, signal },
|
|
@@ -9896,7 +9932,7 @@ function createClient(config) {
|
|
|
9896
9932
|
syncResponse.usage
|
|
9897
9933
|
);
|
|
9898
9934
|
}
|
|
9899
|
-
return client.run({ workflow, payload, signal }, model
|
|
9935
|
+
return client.run({ workflow, payload, signal }, resolvePollOptions(model, options));
|
|
9900
9936
|
}
|
|
9901
9937
|
function buildDrivePayloadOptions(model, params2, options) {
|
|
9902
9938
|
const explicit = options?.drive;
|
|
@@ -9936,7 +9972,7 @@ function createClient(config) {
|
|
|
9936
9972
|
const { workflow, payload, contract } = prepareRequest(resolved, params2);
|
|
9937
9973
|
const drive = buildDrivePayloadOptions(resolved, params2, options);
|
|
9938
9974
|
const finalPayload = injectDriveOptions(payload, drive);
|
|
9939
|
-
const completed = await executeModel(resolved, workflow, finalPayload, options
|
|
9975
|
+
const completed = await executeModel(resolved, workflow, finalPayload, options);
|
|
9940
9976
|
return parseResult(completed, resolved, contract);
|
|
9941
9977
|
},
|
|
9942
9978
|
/**
|
|
@@ -9953,7 +9989,7 @@ function createClient(config) {
|
|
|
9953
9989
|
throw new Error(`${resolved.name} is not a text model \u2014 use generate() instead.`);
|
|
9954
9990
|
}
|
|
9955
9991
|
const { workflow, payload } = prepareRequest(resolved, params2);
|
|
9956
|
-
const completed = await executeModel(resolved, workflow, payload, options
|
|
9992
|
+
const completed = await executeModel(resolved, workflow, payload, options);
|
|
9957
9993
|
return parseTextResult(completed, resolved);
|
|
9958
9994
|
},
|
|
9959
9995
|
/** @deprecated Use `getCredits()` instead. */
|
|
@@ -9997,7 +10033,7 @@ function createClient(config) {
|
|
|
9997
10033
|
async result(handle, model, options) {
|
|
9998
10034
|
const resolved = resolveModel(model);
|
|
9999
10035
|
const contract = getModelContract(resolved.id);
|
|
10000
|
-
const completed = await client.result(handle,
|
|
10036
|
+
const completed = await client.result(handle, resolvePollOptions(resolved, options));
|
|
10001
10037
|
return parseResult(completed, resolved, contract);
|
|
10002
10038
|
},
|
|
10003
10039
|
/**
|
|
@@ -10510,6 +10546,7 @@ var Flux2Pro = "flux-2-pro";
|
|
|
10510
10546
|
var Flux3Video = "flux-3-video";
|
|
10511
10547
|
var FluxKontextMax = "flux-kontext-max";
|
|
10512
10548
|
var FluxKontextPro = "flux-kontext-pro";
|
|
10549
|
+
var FluxVideoUpscale = "flux-video-upscale";
|
|
10513
10550
|
var Gemini25FlashImage = "gemini-2.5-flash-image";
|
|
10514
10551
|
var Gemini25FlashTts = "gemini-2.5-flash-tts";
|
|
10515
10552
|
var Gemini25ProTts = "gemini-2.5-pro-tts";
|
|
@@ -10718,6 +10755,7 @@ var Models = {
|
|
|
10718
10755
|
Flux3Video,
|
|
10719
10756
|
FluxKontextMax,
|
|
10720
10757
|
FluxKontextPro,
|
|
10758
|
+
FluxVideoUpscale,
|
|
10721
10759
|
Gemini25FlashImage,
|
|
10722
10760
|
Gemini25FlashTts,
|
|
10723
10761
|
Gemini25ProTts,
|