@ai-sdk/black-forest-labs 1.0.49 → 1.0.50
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 +6 -0
- package/README.md +16 -2
- package/dist/index.d.mts +27 -4
- package/dist/index.d.ts +27 -4
- package/dist/index.js +741 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +738 -78
- package/dist/index.mjs.map +1 -1
- package/docs/12-black-forest-labs.mdx +245 -3
- package/package.json +1 -1
- package/src/black-forest-labs-api.ts +58 -0
- package/src/black-forest-labs-image-model.ts +4 -51
- package/src/black-forest-labs-provider.ts +29 -2
- package/src/black-forest-labs-video-model-options.ts +92 -0
- package/src/black-forest-labs-video-model.ts +763 -0
- package/src/black-forest-labs-video-settings.ts +22 -0
- package/src/index.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -12,19 +12,61 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
combineHeaders,
|
|
14
14
|
createBinaryResponseHandler,
|
|
15
|
-
createJsonErrorResponseHandler,
|
|
16
15
|
createJsonResponseHandler,
|
|
17
16
|
createStatusCodeErrorResponseHandler,
|
|
18
17
|
delay,
|
|
19
18
|
getFromApi,
|
|
20
|
-
isSameOrigin,
|
|
21
19
|
lazySchema,
|
|
22
20
|
parseProviderOptions,
|
|
23
21
|
postJsonToApi,
|
|
24
22
|
resolve,
|
|
25
23
|
zodSchema
|
|
26
24
|
} from "@ai-sdk/provider-utils";
|
|
25
|
+
import { z as z2 } from "zod/v4";
|
|
26
|
+
|
|
27
|
+
// src/black-forest-labs-api.ts
|
|
28
|
+
import {
|
|
29
|
+
createJsonErrorResponseHandler,
|
|
30
|
+
isSameOrigin
|
|
31
|
+
} from "@ai-sdk/provider-utils";
|
|
27
32
|
import { z } from "zod/v4";
|
|
33
|
+
var bflErrorSchema = z.object({
|
|
34
|
+
message: z.string().optional(),
|
|
35
|
+
detail: z.any().optional()
|
|
36
|
+
});
|
|
37
|
+
function bflErrorToMessage(error) {
|
|
38
|
+
const parsed = bflErrorSchema.safeParse(error);
|
|
39
|
+
if (!parsed.success) return void 0;
|
|
40
|
+
const { message, detail } = parsed.data;
|
|
41
|
+
if (typeof detail === "string") return detail;
|
|
42
|
+
if (detail != null) {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.stringify(detail);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return message;
|
|
49
|
+
}
|
|
50
|
+
var bflFailedResponseHandler = createJsonErrorResponseHandler({
|
|
51
|
+
errorSchema: bflErrorSchema,
|
|
52
|
+
errorToMessage: (error) => {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = bflErrorToMessage(error)) != null ? _a : "Unknown Black Forest Labs error";
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
function isTrustedUrl(url, baseUrl) {
|
|
58
|
+
if (isSameOrigin(url, baseUrl)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const { protocol, hostname } = new URL(url);
|
|
63
|
+
return protocol === "https:" && (hostname === "bfl.ai" || hostname.endsWith(".bfl.ai"));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/black-forest-labs-image-model.ts
|
|
28
70
|
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
29
71
|
var DEFAULT_POLL_TIMEOUT_MILLIS = 6e4;
|
|
30
72
|
var BlackForestLabsImageModel = class {
|
|
@@ -265,54 +307,43 @@ var BlackForestLabsImageModel = class {
|
|
|
265
307
|
throw new Error("Black Forest Labs generation timed out.");
|
|
266
308
|
}
|
|
267
309
|
};
|
|
268
|
-
function isTrustedUrl(url, baseUrl) {
|
|
269
|
-
if (isSameOrigin(url, baseUrl)) {
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
try {
|
|
273
|
-
const { protocol, hostname } = new URL(url);
|
|
274
|
-
return protocol === "https:" && (hostname === "bfl.ai" || hostname.endsWith(".bfl.ai"));
|
|
275
|
-
} catch (e) {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
310
|
var blackForestLabsImageModelOptionsSchema = lazySchema(
|
|
280
311
|
() => zodSchema(
|
|
281
|
-
|
|
282
|
-
imagePrompt:
|
|
283
|
-
imagePromptStrength:
|
|
312
|
+
z2.object({
|
|
313
|
+
imagePrompt: z2.string().optional(),
|
|
314
|
+
imagePromptStrength: z2.number().min(0).max(1).optional(),
|
|
284
315
|
/** @deprecated use prompt.images instead */
|
|
285
|
-
inputImage:
|
|
316
|
+
inputImage: z2.string().optional(),
|
|
286
317
|
/** @deprecated use prompt.images instead */
|
|
287
|
-
inputImage2:
|
|
318
|
+
inputImage2: z2.string().optional(),
|
|
288
319
|
/** @deprecated use prompt.images instead */
|
|
289
|
-
inputImage3:
|
|
320
|
+
inputImage3: z2.string().optional(),
|
|
290
321
|
/** @deprecated use prompt.images instead */
|
|
291
|
-
inputImage4:
|
|
322
|
+
inputImage4: z2.string().optional(),
|
|
292
323
|
/** @deprecated use prompt.images instead */
|
|
293
|
-
inputImage5:
|
|
324
|
+
inputImage5: z2.string().optional(),
|
|
294
325
|
/** @deprecated use prompt.images instead */
|
|
295
|
-
inputImage6:
|
|
326
|
+
inputImage6: z2.string().optional(),
|
|
296
327
|
/** @deprecated use prompt.images instead */
|
|
297
|
-
inputImage7:
|
|
328
|
+
inputImage7: z2.string().optional(),
|
|
298
329
|
/** @deprecated use prompt.images instead */
|
|
299
|
-
inputImage8:
|
|
330
|
+
inputImage8: z2.string().optional(),
|
|
300
331
|
/** @deprecated use prompt.images instead */
|
|
301
|
-
inputImage9:
|
|
332
|
+
inputImage9: z2.string().optional(),
|
|
302
333
|
/** @deprecated use prompt.images instead */
|
|
303
|
-
inputImage10:
|
|
304
|
-
steps:
|
|
305
|
-
guidance:
|
|
306
|
-
width:
|
|
307
|
-
height:
|
|
308
|
-
outputFormat:
|
|
309
|
-
promptUpsampling:
|
|
310
|
-
raw:
|
|
311
|
-
safetyTolerance:
|
|
312
|
-
webhookSecret:
|
|
313
|
-
webhookUrl:
|
|
314
|
-
pollIntervalMillis:
|
|
315
|
-
pollTimeoutMillis:
|
|
334
|
+
inputImage10: z2.string().optional(),
|
|
335
|
+
steps: z2.number().int().positive().optional(),
|
|
336
|
+
guidance: z2.number().min(0).optional(),
|
|
337
|
+
width: z2.number().int().min(256).max(1920).optional(),
|
|
338
|
+
height: z2.number().int().min(256).max(1920).optional(),
|
|
339
|
+
outputFormat: z2.enum(["jpeg", "png"]).optional(),
|
|
340
|
+
promptUpsampling: z2.boolean().optional(),
|
|
341
|
+
raw: z2.boolean().optional(),
|
|
342
|
+
safetyTolerance: z2.number().int().min(0).max(6).optional(),
|
|
343
|
+
webhookSecret: z2.string().optional(),
|
|
344
|
+
webhookUrl: z2.url().optional(),
|
|
345
|
+
pollIntervalMillis: z2.number().int().positive().optional(),
|
|
346
|
+
pollTimeoutMillis: z2.number().int().positive().optional()
|
|
316
347
|
})
|
|
317
348
|
)
|
|
318
349
|
);
|
|
@@ -336,30 +367,30 @@ function gcd(a, b) {
|
|
|
336
367
|
}
|
|
337
368
|
return x;
|
|
338
369
|
}
|
|
339
|
-
var bflSubmitSchema =
|
|
340
|
-
id:
|
|
341
|
-
polling_url:
|
|
342
|
-
cost:
|
|
343
|
-
input_mp:
|
|
344
|
-
output_mp:
|
|
370
|
+
var bflSubmitSchema = z2.object({
|
|
371
|
+
id: z2.string(),
|
|
372
|
+
polling_url: z2.url(),
|
|
373
|
+
cost: z2.number().nullish(),
|
|
374
|
+
input_mp: z2.number().nullish(),
|
|
375
|
+
output_mp: z2.number().nullish()
|
|
345
376
|
});
|
|
346
|
-
var bflStatus =
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
377
|
+
var bflStatus = z2.union([
|
|
378
|
+
z2.literal("Pending"),
|
|
379
|
+
z2.literal("Ready"),
|
|
380
|
+
z2.literal("Error"),
|
|
381
|
+
z2.literal("Failed"),
|
|
382
|
+
z2.literal("Request Moderated")
|
|
352
383
|
]);
|
|
353
|
-
var bflPollSchema =
|
|
384
|
+
var bflPollSchema = z2.object({
|
|
354
385
|
status: bflStatus.optional(),
|
|
355
386
|
state: bflStatus.optional(),
|
|
356
|
-
details:
|
|
357
|
-
result:
|
|
358
|
-
sample:
|
|
359
|
-
seed:
|
|
360
|
-
start_time:
|
|
361
|
-
end_time:
|
|
362
|
-
duration:
|
|
387
|
+
details: z2.unknown().optional(),
|
|
388
|
+
result: z2.object({
|
|
389
|
+
sample: z2.url(),
|
|
390
|
+
seed: z2.number().optional(),
|
|
391
|
+
start_time: z2.number().optional(),
|
|
392
|
+
end_time: z2.number().optional(),
|
|
393
|
+
duration: z2.number().optional()
|
|
363
394
|
}).nullish()
|
|
364
395
|
}).refine((v) => v.status != null || v.state != null, {
|
|
365
396
|
message: "Missing status in Black Forest Labs poll response"
|
|
@@ -370,33 +401,652 @@ var bflPollSchema = z.object({
|
|
|
370
401
|
result: v.result
|
|
371
402
|
};
|
|
372
403
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
404
|
+
|
|
405
|
+
// src/black-forest-labs-video-model.ts
|
|
406
|
+
import {
|
|
407
|
+
AISDKError,
|
|
408
|
+
InvalidArgumentError
|
|
409
|
+
} from "@ai-sdk/provider";
|
|
410
|
+
import {
|
|
411
|
+
combineHeaders as combineHeaders2,
|
|
412
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
413
|
+
delay as delay2,
|
|
414
|
+
getFromApi as getFromApi2,
|
|
415
|
+
parseProviderOptions as parseProviderOptions2,
|
|
416
|
+
postJsonToApi as postJsonToApi2,
|
|
417
|
+
resolve as resolve2
|
|
418
|
+
} from "@ai-sdk/provider-utils";
|
|
419
|
+
import { z as z4 } from "zod/v4";
|
|
420
|
+
|
|
421
|
+
// src/black-forest-labs-video-model-options.ts
|
|
422
|
+
import {
|
|
423
|
+
lazySchema as lazySchema2,
|
|
424
|
+
zodSchema as zodSchema2
|
|
425
|
+
} from "@ai-sdk/provider-utils";
|
|
426
|
+
import { z as z3 } from "zod/v4";
|
|
427
|
+
|
|
428
|
+
// src/black-forest-labs-video-settings.ts
|
|
429
|
+
var blackForestLabsVideoAspectRatios = [
|
|
430
|
+
"21:9",
|
|
431
|
+
"2:1",
|
|
432
|
+
"16:9",
|
|
433
|
+
"4:3",
|
|
434
|
+
"1:1",
|
|
435
|
+
"3:4",
|
|
436
|
+
"9:16",
|
|
437
|
+
"auto"
|
|
438
|
+
];
|
|
439
|
+
var blackForestLabsVideoResolutions = ["hd", "fhd"];
|
|
440
|
+
|
|
441
|
+
// src/black-forest-labs-video-model-options.ts
|
|
442
|
+
var blackForestLabsTimedVideoKeyframeSchema = z3.tuple([
|
|
443
|
+
z3.number().min(0).max(20),
|
|
444
|
+
z3.string()
|
|
445
|
+
]);
|
|
446
|
+
var blackForestLabsVideoKeyframesSchema = z3.union([
|
|
447
|
+
z3.array(z3.string()).min(1).max(10),
|
|
448
|
+
z3.array(blackForestLabsTimedVideoKeyframeSchema).min(1).max(10).refine(
|
|
449
|
+
(keyframes) => keyframes.every(
|
|
450
|
+
(keyframe, index) => index === 0 || keyframe[0] > keyframes[index - 1][0]
|
|
451
|
+
),
|
|
452
|
+
{ message: "Timed keyframes must be in chronological order." }
|
|
453
|
+
)
|
|
454
|
+
]);
|
|
455
|
+
var blackForestLabsVideoProviderOptions = z3.object({
|
|
456
|
+
/**
|
|
457
|
+
* Output resolution tier. Takes precedence over the top-level `resolution`,
|
|
458
|
+
* which is expressed as `{width}x{height}` and has to be mapped onto a tier.
|
|
459
|
+
*/
|
|
460
|
+
resolution: z3.enum(blackForestLabsVideoResolutions).optional(),
|
|
461
|
+
/**
|
|
462
|
+
* Aspect ratio of the generated video. Takes precedence over the top-level
|
|
463
|
+
* `aspectRatio`, and unlike it can be set to `auto`.
|
|
464
|
+
*/
|
|
465
|
+
aspectRatio: z3.enum(blackForestLabsVideoAspectRatios).optional(),
|
|
466
|
+
/**
|
|
467
|
+
* Keyframes for image-to-video generation, for the shapes the top-level
|
|
468
|
+
* `image` and `frameImages` options cannot express: more than two images, or
|
|
469
|
+
* images pinned to a specific second. Takes precedence over both.
|
|
470
|
+
*
|
|
471
|
+
* One image opens the clip, two open and close it, and with more the extras
|
|
472
|
+
* are spaced evenly in between. Three or more plain images require an
|
|
473
|
+
* explicit `duration`.
|
|
474
|
+
*/
|
|
475
|
+
keyframes: blackForestLabsVideoKeyframesSchema.optional(),
|
|
476
|
+
/**
|
|
477
|
+
* Moderation strictness from 0 (strictest) to 4. Defaults to 2. Sexual
|
|
478
|
+
* content is capped at 3 and hate content at 2 regardless of the request,
|
|
479
|
+
* and any request carrying conditioning media is capped at 2.
|
|
480
|
+
*/
|
|
481
|
+
safetyTolerance: z3.number().int().min(0).max(4).optional(),
|
|
482
|
+
/**
|
|
483
|
+
* Render a fast, lower-quality preview instead of the finished video.
|
|
484
|
+
* Defaults to `false`.
|
|
485
|
+
*/
|
|
486
|
+
draft: z3.boolean().optional(),
|
|
487
|
+
/**
|
|
488
|
+
* Encrypted draft-cache bundle from a prior `draft` generation, which
|
|
489
|
+
* switches the request to draft-enhance mode: the bundle is replayed at full
|
|
490
|
+
* quality.
|
|
491
|
+
*
|
|
492
|
+
* Either the base64-encoded `.bin` downloaded from the draft's `draftCache`
|
|
493
|
+
* URL, or that URL itself while it is still in its expiry window.
|
|
494
|
+
*/
|
|
495
|
+
draftCache: z3.string().optional(),
|
|
496
|
+
/**
|
|
497
|
+
* Model version to pin. Only `latest` is available today.
|
|
498
|
+
*/
|
|
499
|
+
version: z3.literal("latest").optional()
|
|
376
500
|
});
|
|
377
|
-
var
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
501
|
+
var blackForestLabsVideoModelOptionsSchema = lazySchema2(
|
|
502
|
+
() => zodSchema2(blackForestLabsVideoProviderOptions)
|
|
503
|
+
);
|
|
504
|
+
|
|
505
|
+
// src/black-forest-labs-video-model.ts
|
|
506
|
+
var DEFAULT_POLL_INTERVAL_MILLIS2 = 2e3;
|
|
507
|
+
var DEFAULT_POLL_TIMEOUT_MILLIS2 = 6e5;
|
|
508
|
+
var MIN_DURATION_SECONDS = 5;
|
|
509
|
+
var MAX_DURATION_SECONDS = 20;
|
|
510
|
+
var UNTIMED_KEYFRAMES_NEEDING_DURATION = 3;
|
|
511
|
+
var allowedAspectRatios = new Set(blackForestLabsVideoAspectRatios);
|
|
512
|
+
var allowedResolutions = new Set(blackForestLabsVideoResolutions);
|
|
513
|
+
var TERMINAL_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
514
|
+
"Error",
|
|
515
|
+
"Failed",
|
|
516
|
+
"Request Moderated",
|
|
517
|
+
"Content Moderated",
|
|
518
|
+
"Task not found"
|
|
519
|
+
]);
|
|
520
|
+
function getTopLevelMediaType(mediaType) {
|
|
521
|
+
return mediaType.split("/")[0];
|
|
522
|
+
}
|
|
523
|
+
function resolveTopLevelResolution(resolution) {
|
|
524
|
+
const named = resolution.toLowerCase();
|
|
525
|
+
if (allowedResolutions.has(named)) {
|
|
526
|
+
return { tier: named, derived: false };
|
|
382
527
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
528
|
+
const match = resolution.match(/^(\d+)x(\d+)$/);
|
|
529
|
+
if (match == null) {
|
|
530
|
+
return void 0;
|
|
531
|
+
}
|
|
532
|
+
const shorterSide = Math.min(Number(match[1]), Number(match[2]));
|
|
533
|
+
return {
|
|
534
|
+
tier: shorterSide <= 720 ? "hd" : "fhd",
|
|
535
|
+
derived: shorterSide !== 720 && shorterSide !== 1080
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function nonImageFrameMediaType(file) {
|
|
539
|
+
if (file.mediaType == null) {
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
const topLevelMediaType = getTopLevelMediaType(file.mediaType);
|
|
543
|
+
return topLevelMediaType === "image" ? void 0 : topLevelMediaType;
|
|
544
|
+
}
|
|
545
|
+
function getDraftEnhanceArgs(options, bflOptions) {
|
|
546
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
547
|
+
const warnings = [];
|
|
548
|
+
const pinnedByBundle = [
|
|
549
|
+
["prompt", ((_b = (_a = options.prompt) == null ? void 0 : _a.trim().length) != null ? _b : 0) > 0],
|
|
550
|
+
[
|
|
551
|
+
"aspectRatio",
|
|
552
|
+
options.aspectRatio != null || bflOptions.aspectRatio != null
|
|
553
|
+
],
|
|
554
|
+
["resolution", options.resolution != null || bflOptions.resolution != null],
|
|
555
|
+
["duration", options.duration != null],
|
|
556
|
+
["fps", options.fps != null],
|
|
557
|
+
["seed", options.seed != null],
|
|
558
|
+
["generateAudio", options.generateAudio != null],
|
|
559
|
+
["image", options.image != null],
|
|
560
|
+
["frameImages", ((_d = (_c = options.frameImages) == null ? void 0 : _c.length) != null ? _d : 0) > 0],
|
|
561
|
+
["inputReferences", ((_f = (_e = options.inputReferences) == null ? void 0 : _e.length) != null ? _f : 0) > 0],
|
|
562
|
+
["keyframes", ((_h = (_g = bflOptions.keyframes) == null ? void 0 : _g.length) != null ? _h : 0) > 0],
|
|
563
|
+
["version", bflOptions.version != null]
|
|
564
|
+
];
|
|
565
|
+
for (const [feature, isSet] of pinnedByBundle) {
|
|
566
|
+
if (isSet) {
|
|
567
|
+
warnings.push({
|
|
568
|
+
type: "unsupported",
|
|
569
|
+
feature,
|
|
570
|
+
details: `FLUX 3 draft enhance replays the draft bundle as it was generated, so "${feature}" was ignored. Set it on the original draft request instead.`
|
|
571
|
+
});
|
|
393
572
|
}
|
|
394
573
|
}
|
|
395
|
-
|
|
574
|
+
if (bflOptions.draft != null) {
|
|
575
|
+
warnings.push({
|
|
576
|
+
type: "unsupported",
|
|
577
|
+
feature: "draft",
|
|
578
|
+
details: "FLUX 3 draft enhance always renders at full quality. The draft option was ignored."
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
if (options.n != null && options.n > 1) {
|
|
582
|
+
warnings.push({
|
|
583
|
+
type: "unsupported",
|
|
584
|
+
feature: "n",
|
|
585
|
+
details: "FLUX 3 video generates a single video per call. Only 1 video will be generated."
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return {
|
|
589
|
+
body: {
|
|
590
|
+
mode: "draft_enhance",
|
|
591
|
+
draft_cache: bflOptions.draftCache,
|
|
592
|
+
safety_tolerance: bflOptions.safetyTolerance
|
|
593
|
+
},
|
|
594
|
+
warnings
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function describePollDetails(details) {
|
|
598
|
+
if (details == null) {
|
|
599
|
+
return void 0;
|
|
600
|
+
}
|
|
601
|
+
if (typeof details === "string") {
|
|
602
|
+
return details;
|
|
603
|
+
}
|
|
604
|
+
try {
|
|
605
|
+
return JSON.stringify(details);
|
|
606
|
+
} catch (e) {
|
|
607
|
+
return void 0;
|
|
608
|
+
}
|
|
396
609
|
}
|
|
610
|
+
function toBlackForestLabsFile(file) {
|
|
611
|
+
if (file.type === "url") {
|
|
612
|
+
return file.url;
|
|
613
|
+
}
|
|
614
|
+
if (typeof file.data === "string") {
|
|
615
|
+
return file.data;
|
|
616
|
+
}
|
|
617
|
+
return Buffer.from(file.data).toString("base64");
|
|
618
|
+
}
|
|
619
|
+
var BlackForestLabsVideoModel = class {
|
|
620
|
+
constructor(modelId, config) {
|
|
621
|
+
this.modelId = modelId;
|
|
622
|
+
this.config = config;
|
|
623
|
+
this.specificationVersion = "v3";
|
|
624
|
+
this.maxVideosPerCall = 1;
|
|
625
|
+
}
|
|
626
|
+
get provider() {
|
|
627
|
+
return this.config.provider;
|
|
628
|
+
}
|
|
629
|
+
async getArgs(options) {
|
|
630
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
631
|
+
const warnings = [];
|
|
632
|
+
const bflOptions = await parseProviderOptions2({
|
|
633
|
+
provider: "blackForestLabs",
|
|
634
|
+
providerOptions: options.providerOptions,
|
|
635
|
+
schema: blackForestLabsVideoModelOptionsSchema
|
|
636
|
+
});
|
|
637
|
+
if ((bflOptions == null ? void 0 : bflOptions.draftCache) != null) {
|
|
638
|
+
return getDraftEnhanceArgs(options, bflOptions);
|
|
639
|
+
}
|
|
640
|
+
if (options.fps != null) {
|
|
641
|
+
warnings.push({
|
|
642
|
+
type: "unsupported",
|
|
643
|
+
feature: "fps",
|
|
644
|
+
details: "FLUX 3 video does not support a custom frame rate."
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
if (options.seed != null) {
|
|
648
|
+
warnings.push({
|
|
649
|
+
type: "unsupported",
|
|
650
|
+
feature: "seed",
|
|
651
|
+
details: "FLUX 3 video does not accept a seed."
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
if (options.n != null && options.n > 1) {
|
|
655
|
+
warnings.push({
|
|
656
|
+
type: "unsupported",
|
|
657
|
+
feature: "n",
|
|
658
|
+
details: "FLUX 3 video generates a single video per call. Only 1 video will be generated."
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
let resolution = bflOptions == null ? void 0 : bflOptions.resolution;
|
|
662
|
+
if (options.resolution != null) {
|
|
663
|
+
const resolved = resolveTopLevelResolution(options.resolution);
|
|
664
|
+
if (resolution != null) {
|
|
665
|
+
if (resolved == null) {
|
|
666
|
+
warnings.push({
|
|
667
|
+
type: "unsupported",
|
|
668
|
+
feature: "resolution",
|
|
669
|
+
details: `Unrecognized resolution "${options.resolution}". FLUX 3 video supports "hd" and "fhd", so providerOptions.blackForestLabs.resolution ("${resolution}") was used instead.`
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
} else if (resolved == null) {
|
|
673
|
+
warnings.push({
|
|
674
|
+
type: "unsupported",
|
|
675
|
+
feature: "resolution",
|
|
676
|
+
details: `Unrecognized resolution "${options.resolution}". FLUX 3 video supports "hd" and "fhd", or a {width}x{height} value to map onto one.`
|
|
677
|
+
});
|
|
678
|
+
} else {
|
|
679
|
+
resolution = resolved.tier;
|
|
680
|
+
if (resolved.derived) {
|
|
681
|
+
warnings.push({
|
|
682
|
+
type: "compatibility",
|
|
683
|
+
feature: "resolution",
|
|
684
|
+
details: `FLUX 3 video renders at "hd" or "fhd"; the requested resolution "${options.resolution}" was mapped to "${resolved.tier}".`
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
let aspectRatio = bflOptions == null ? void 0 : bflOptions.aspectRatio;
|
|
690
|
+
if (aspectRatio == null && options.aspectRatio != null) {
|
|
691
|
+
if (allowedAspectRatios.has(options.aspectRatio)) {
|
|
692
|
+
aspectRatio = options.aspectRatio;
|
|
693
|
+
} else {
|
|
694
|
+
warnings.push({
|
|
695
|
+
type: "unsupported",
|
|
696
|
+
feature: "aspectRatio",
|
|
697
|
+
details: `FLUX 3 video does not support the aspect ratio "${options.aspectRatio}". Using the provider default (auto).`
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
const firstFrameImage = (_b = (_a = options.frameImages) == null ? void 0 : _a.find(
|
|
702
|
+
(frame) => frame.frameType === "first_frame"
|
|
703
|
+
)) == null ? void 0 : _b.image;
|
|
704
|
+
let firstFrame = firstFrameImage != null ? firstFrameImage : options.image;
|
|
705
|
+
let lastFrame = (_d = (_c = options.frameImages) == null ? void 0 : _c.find(
|
|
706
|
+
(frame) => frame.frameType === "last_frame"
|
|
707
|
+
)) == null ? void 0 : _d.image;
|
|
708
|
+
const firstFrameMediaType = firstFrame != null ? nonImageFrameMediaType(firstFrame) : void 0;
|
|
709
|
+
if (firstFrame != null && firstFrameMediaType != null) {
|
|
710
|
+
warnings.push({
|
|
711
|
+
type: "unsupported",
|
|
712
|
+
feature: firstFrameImage != null ? "frameImages" : "image",
|
|
713
|
+
details: firstFrameMediaType === "video" ? "FLUX 3 video does not accept a video as a keyframe. Pass it as an inputReference to continue from it instead." : `FLUX 3 video only accepts an image as a keyframe; the "${firstFrame.mediaType}" file was ignored.`
|
|
714
|
+
});
|
|
715
|
+
firstFrame = void 0;
|
|
716
|
+
}
|
|
717
|
+
if (lastFrame != null) {
|
|
718
|
+
if (firstFrame == null) {
|
|
719
|
+
warnings.push({
|
|
720
|
+
type: "unsupported",
|
|
721
|
+
feature: "frameImages",
|
|
722
|
+
details: "FLUX 3 video requires a first_frame when a last_frame is provided. The last_frame was ignored."
|
|
723
|
+
});
|
|
724
|
+
lastFrame = void 0;
|
|
725
|
+
} else {
|
|
726
|
+
const lastFrameMediaType = nonImageFrameMediaType(lastFrame);
|
|
727
|
+
if (lastFrameMediaType != null) {
|
|
728
|
+
warnings.push({
|
|
729
|
+
type: "unsupported",
|
|
730
|
+
feature: "frameImages",
|
|
731
|
+
details: lastFrameMediaType === "video" ? "FLUX 3 video does not accept a video as a keyframe. The last_frame video was ignored." : `FLUX 3 video only accepts an image as a keyframe; the "${lastFrame.mediaType}" last_frame was ignored.`
|
|
732
|
+
});
|
|
733
|
+
lastFrame = void 0;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
let keyframes = (bflOptions == null ? void 0 : bflOptions.keyframes) != null && bflOptions.keyframes.length > 0 ? [...bflOptions.keyframes] : void 0;
|
|
738
|
+
if (keyframes != null) {
|
|
739
|
+
if (firstFrame != null || lastFrame != null) {
|
|
740
|
+
warnings.push({
|
|
741
|
+
type: "unsupported",
|
|
742
|
+
feature: options.frameImages != null ? "frameImages" : "image",
|
|
743
|
+
details: "FLUX 3 video takes a single keyframe list. providerOptions.blackForestLabs.keyframes was used and the top-level frame images were ignored."
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
} else if (firstFrame != null) {
|
|
747
|
+
keyframes = [toBlackForestLabsFile(firstFrame)];
|
|
748
|
+
if (lastFrame != null) {
|
|
749
|
+
keyframes.push(toBlackForestLabsFile(lastFrame));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
let startVideo;
|
|
753
|
+
const referenceFiles = (_e = options.inputReferences) != null ? _e : [];
|
|
754
|
+
const referenceVideos = [];
|
|
755
|
+
for (const file of referenceFiles) {
|
|
756
|
+
const topLevelMediaType = file.mediaType != null ? getTopLevelMediaType(file.mediaType) : void 0;
|
|
757
|
+
if (topLevelMediaType === "video") {
|
|
758
|
+
referenceVideos.push(file);
|
|
759
|
+
} else if (topLevelMediaType == null) {
|
|
760
|
+
warnings.push({
|
|
761
|
+
type: "compatibility",
|
|
762
|
+
feature: "inputReferences",
|
|
763
|
+
details: 'FLUX 3 video only accepts a video reference, so the reference with no mediaType was treated as the video to continue from. Pass { url, mediaType: "video/mp4" } to be explicit.'
|
|
764
|
+
});
|
|
765
|
+
referenceVideos.push(file);
|
|
766
|
+
} else if (topLevelMediaType === "image") {
|
|
767
|
+
warnings.push({
|
|
768
|
+
type: "unsupported",
|
|
769
|
+
feature: "inputReferences",
|
|
770
|
+
details: "FLUX 3 video has no reference-image input. Pass images as `image`, `frameImages`, or providerOptions.blackForestLabs.keyframes instead. The reference was ignored."
|
|
771
|
+
});
|
|
772
|
+
} else {
|
|
773
|
+
warnings.push({
|
|
774
|
+
type: "unsupported",
|
|
775
|
+
feature: "inputReferences",
|
|
776
|
+
details: `FLUX 3 video only accepts a video reference; the "${file.mediaType}" reference was ignored.`
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (referenceVideos.length > 0) {
|
|
781
|
+
if (keyframes != null) {
|
|
782
|
+
warnings.push({
|
|
783
|
+
type: "unsupported",
|
|
784
|
+
feature: "inputReferences",
|
|
785
|
+
details: "FLUX 3 video cannot combine keyframes with a video to continue from. The video reference was ignored."
|
|
786
|
+
});
|
|
787
|
+
} else {
|
|
788
|
+
startVideo = toBlackForestLabsFile(referenceVideos[0]);
|
|
789
|
+
if (referenceVideos.length > 1) {
|
|
790
|
+
warnings.push({
|
|
791
|
+
type: "unsupported",
|
|
792
|
+
feature: "inputReferences",
|
|
793
|
+
details: "FLUX 3 video continues from a single video. Only the first video reference was used."
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
let duration = options.duration;
|
|
799
|
+
if (duration != null) {
|
|
800
|
+
if (!Number.isInteger(duration)) {
|
|
801
|
+
const rounded = Math.round(duration);
|
|
802
|
+
warnings.push({
|
|
803
|
+
type: "unsupported",
|
|
804
|
+
feature: "duration",
|
|
805
|
+
details: `FLUX 3 video requires a whole number of seconds. The requested duration of ${duration} was rounded to ${rounded}.`
|
|
806
|
+
});
|
|
807
|
+
duration = rounded;
|
|
808
|
+
}
|
|
809
|
+
if (duration > MAX_DURATION_SECONDS) {
|
|
810
|
+
warnings.push({
|
|
811
|
+
type: "unsupported",
|
|
812
|
+
feature: "duration",
|
|
813
|
+
details: `FLUX 3 video supports at most ${MAX_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MAX_DURATION_SECONDS}.`
|
|
814
|
+
});
|
|
815
|
+
duration = MAX_DURATION_SECONDS;
|
|
816
|
+
} else if (duration < MIN_DURATION_SECONDS) {
|
|
817
|
+
warnings.push({
|
|
818
|
+
type: "unsupported",
|
|
819
|
+
feature: "duration",
|
|
820
|
+
details: `FLUX 3 video requires at least ${MIN_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MIN_DURATION_SECONDS}.`
|
|
821
|
+
});
|
|
822
|
+
duration = MIN_DURATION_SECONDS;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const untimedKeyframeCount = (_f = keyframes == null ? void 0 : keyframes.filter((keyframe) => typeof keyframe === "string").length) != null ? _f : 0;
|
|
826
|
+
if (duration == null && untimedKeyframeCount >= UNTIMED_KEYFRAMES_NEEDING_DURATION) {
|
|
827
|
+
throw new InvalidArgumentError({
|
|
828
|
+
argument: "duration",
|
|
829
|
+
message: `FLUX 3 video requires an explicit duration when ${UNTIMED_KEYFRAMES_NEEDING_DURATION} or more keyframes are sent without a timestamp.`
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
const mode = keyframes != null ? "i2v" : startVideo != null ? "v2v" : "t2v";
|
|
833
|
+
const body = {
|
|
834
|
+
mode,
|
|
835
|
+
prompt: (_g = options.prompt) != null ? _g : "",
|
|
836
|
+
aspect_ratio: aspectRatio,
|
|
837
|
+
duration,
|
|
838
|
+
resolution,
|
|
839
|
+
version: bflOptions == null ? void 0 : bflOptions.version,
|
|
840
|
+
generate_audio: options.generateAudio,
|
|
841
|
+
safety_tolerance: bflOptions == null ? void 0 : bflOptions.safetyTolerance,
|
|
842
|
+
draft: bflOptions == null ? void 0 : bflOptions.draft,
|
|
843
|
+
...mode === "i2v" && { keyframes },
|
|
844
|
+
...mode === "v2v" && { start_video: startVideo }
|
|
845
|
+
};
|
|
846
|
+
return { body, warnings };
|
|
847
|
+
}
|
|
848
|
+
async start(options) {
|
|
849
|
+
var _a, _b, _c;
|
|
850
|
+
const { body, warnings } = await this.getArgs(options);
|
|
851
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
852
|
+
const combinedHeaders = combineHeaders2(
|
|
853
|
+
await resolve2(this.config.headers),
|
|
854
|
+
options.headers
|
|
855
|
+
);
|
|
856
|
+
const { value: submit, responseHeaders } = await postJsonToApi2({
|
|
857
|
+
url: `${this.config.baseURL}/${this.modelId}`,
|
|
858
|
+
headers: combinedHeaders,
|
|
859
|
+
body,
|
|
860
|
+
failedResponseHandler: bflFailedResponseHandler,
|
|
861
|
+
successfulResponseHandler: createJsonResponseHandler2(bflVideoSubmitSchema),
|
|
862
|
+
abortSignal: options.abortSignal,
|
|
863
|
+
fetch: this.config.fetch
|
|
864
|
+
});
|
|
865
|
+
return {
|
|
866
|
+
operation: {
|
|
867
|
+
requestId: submit.id,
|
|
868
|
+
pollingUrl: submit.polling_url,
|
|
869
|
+
...submit.cost != null && { cost: submit.cost },
|
|
870
|
+
...submit.input_mp != null && {
|
|
871
|
+
inputMegapixels: submit.input_mp
|
|
872
|
+
},
|
|
873
|
+
...submit.output_mp != null && {
|
|
874
|
+
outputMegapixels: submit.output_mp
|
|
875
|
+
}
|
|
876
|
+
},
|
|
877
|
+
warnings,
|
|
878
|
+
response: {
|
|
879
|
+
modelId: this.modelId,
|
|
880
|
+
timestamp: currentDate,
|
|
881
|
+
headers: responseHeaders
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
async getStatus(options) {
|
|
886
|
+
var _a, _b, _c;
|
|
887
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
888
|
+
const operation = options.operation;
|
|
889
|
+
const url = new URL(operation.pollingUrl);
|
|
890
|
+
if (!url.searchParams.has("id")) {
|
|
891
|
+
url.searchParams.set("id", operation.requestId);
|
|
892
|
+
}
|
|
893
|
+
const combinedHeaders = combineHeaders2(
|
|
894
|
+
await resolve2(this.config.headers),
|
|
895
|
+
options.headers
|
|
896
|
+
);
|
|
897
|
+
const pollingUrl = url.toString();
|
|
898
|
+
if (!isTrustedUrl(pollingUrl, this.config.baseURL)) {
|
|
899
|
+
throw new AISDKError({
|
|
900
|
+
name: "BLACK_FOREST_LABS_VIDEO_GENERATION_ERROR",
|
|
901
|
+
message: `Black Forest Labs returned an untrusted polling URL: ${pollingUrl}`
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
const { value, responseHeaders } = await getFromApi2({
|
|
905
|
+
url: pollingUrl,
|
|
906
|
+
headers: combinedHeaders,
|
|
907
|
+
failedResponseHandler: bflFailedResponseHandler,
|
|
908
|
+
successfulResponseHandler: createJsonResponseHandler2(bflVideoPollSchema),
|
|
909
|
+
abortSignal: options.abortSignal,
|
|
910
|
+
fetch: this.config.fetch
|
|
911
|
+
});
|
|
912
|
+
const response = {
|
|
913
|
+
modelId: this.modelId,
|
|
914
|
+
timestamp: currentDate,
|
|
915
|
+
headers: responseHeaders
|
|
916
|
+
};
|
|
917
|
+
const { status, result } = value;
|
|
918
|
+
if (status === "Ready") {
|
|
919
|
+
const parsed = bflVideoResultSchema.safeParse(result);
|
|
920
|
+
if (!parsed.success) {
|
|
921
|
+
throw new AISDKError({
|
|
922
|
+
name: "BLACK_FOREST_LABS_VIDEO_GENERATION_ERROR",
|
|
923
|
+
message: `Black Forest Labs reported the video as Ready but returned no result.sample URL. Request id: ${operation.requestId}`
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
return {
|
|
927
|
+
status: "completed",
|
|
928
|
+
videos: [
|
|
929
|
+
{
|
|
930
|
+
type: "url",
|
|
931
|
+
url: parsed.data.sample,
|
|
932
|
+
mediaType: "video/mp4"
|
|
933
|
+
}
|
|
934
|
+
],
|
|
935
|
+
warnings: [],
|
|
936
|
+
providerMetadata: {
|
|
937
|
+
blackForestLabs: {
|
|
938
|
+
videos: [
|
|
939
|
+
{
|
|
940
|
+
id: operation.requestId,
|
|
941
|
+
videoUrl: parsed.data.sample,
|
|
942
|
+
...parsed.data.seed != null && { seed: parsed.data.seed },
|
|
943
|
+
...parsed.data.start_time != null && {
|
|
944
|
+
start_time: parsed.data.start_time
|
|
945
|
+
},
|
|
946
|
+
...parsed.data.end_time != null && {
|
|
947
|
+
end_time: parsed.data.end_time
|
|
948
|
+
},
|
|
949
|
+
...parsed.data.duration != null && {
|
|
950
|
+
duration: parsed.data.duration
|
|
951
|
+
},
|
|
952
|
+
...parsed.data.draft_cache != null && {
|
|
953
|
+
draftCache: parsed.data.draft_cache
|
|
954
|
+
},
|
|
955
|
+
...operation.cost != null && { cost: operation.cost },
|
|
956
|
+
...operation.inputMegapixels != null && {
|
|
957
|
+
inputMegapixels: operation.inputMegapixels
|
|
958
|
+
},
|
|
959
|
+
...operation.outputMegapixels != null && {
|
|
960
|
+
outputMegapixels: operation.outputMegapixels
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
]
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
response
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
if (TERMINAL_FAILURE_STATUSES.has(status)) {
|
|
970
|
+
const detail = describePollDetails(value.details);
|
|
971
|
+
return {
|
|
972
|
+
status: "error",
|
|
973
|
+
error: `Black Forest Labs video generation failed with status "${status}"${detail != null ? `: ${detail}` : ""}. Request id: ${operation.requestId}`,
|
|
974
|
+
response
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
return { status: "pending", response };
|
|
978
|
+
}
|
|
979
|
+
async doGenerate(options) {
|
|
980
|
+
var _a, _b;
|
|
981
|
+
const startResult = await this.start(options);
|
|
982
|
+
const operation = startResult.operation;
|
|
983
|
+
const pollIntervalMillis = (_a = this.config.pollIntervalMillis) != null ? _a : DEFAULT_POLL_INTERVAL_MILLIS2;
|
|
984
|
+
const pollTimeoutMillis = (_b = this.config.pollTimeoutMillis) != null ? _b : DEFAULT_POLL_TIMEOUT_MILLIS2;
|
|
985
|
+
const startTime = Date.now();
|
|
986
|
+
while (true) {
|
|
987
|
+
await delay2(pollIntervalMillis, { abortSignal: options.abortSignal });
|
|
988
|
+
if (Date.now() - startTime > pollTimeoutMillis) {
|
|
989
|
+
throw new AISDKError({
|
|
990
|
+
name: "BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT",
|
|
991
|
+
message: `Black Forest Labs video generation timed out after ${pollTimeoutMillis}ms. Request id: ${operation.requestId}`
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
const statusResult = await this.getStatus({
|
|
995
|
+
operation,
|
|
996
|
+
headers: options.headers,
|
|
997
|
+
abortSignal: options.abortSignal
|
|
998
|
+
});
|
|
999
|
+
if (statusResult.status === "pending") {
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
if (statusResult.status === "error") {
|
|
1003
|
+
throw new AISDKError({
|
|
1004
|
+
name: "BLACK_FOREST_LABS_VIDEO_GENERATION_FAILED",
|
|
1005
|
+
message: statusResult.error
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
return {
|
|
1009
|
+
videos: statusResult.videos,
|
|
1010
|
+
warnings: [...startResult.warnings, ...statusResult.warnings],
|
|
1011
|
+
providerMetadata: statusResult.providerMetadata,
|
|
1012
|
+
response: statusResult.response
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
var bflVideoSubmitSchema = z4.object({
|
|
1018
|
+
id: z4.string(),
|
|
1019
|
+
polling_url: z4.url(),
|
|
1020
|
+
cost: z4.number().nullish(),
|
|
1021
|
+
input_mp: z4.number().nullish(),
|
|
1022
|
+
output_mp: z4.number().nullish()
|
|
1023
|
+
});
|
|
1024
|
+
var bflVideoResultSchema = z4.object({
|
|
1025
|
+
sample: z4.url(),
|
|
1026
|
+
seed: z4.number().nullish(),
|
|
1027
|
+
start_time: z4.number().nullish(),
|
|
1028
|
+
end_time: z4.number().nullish(),
|
|
1029
|
+
duration: z4.number().nullish(),
|
|
1030
|
+
draft_cache: z4.string().nullish()
|
|
1031
|
+
});
|
|
1032
|
+
var bflVideoPollSchema = z4.object({
|
|
1033
|
+
status: z4.string().optional(),
|
|
1034
|
+
state: z4.string().optional(),
|
|
1035
|
+
details: z4.unknown().optional(),
|
|
1036
|
+
result: z4.unknown().optional()
|
|
1037
|
+
}).refine((v) => v.status != null || v.state != null, {
|
|
1038
|
+
message: "Missing status in Black Forest Labs poll response"
|
|
1039
|
+
}).transform((v) => {
|
|
1040
|
+
var _a;
|
|
1041
|
+
return {
|
|
1042
|
+
status: (_a = v.status) != null ? _a : v.state,
|
|
1043
|
+
details: v.details,
|
|
1044
|
+
result: v.result
|
|
1045
|
+
};
|
|
1046
|
+
});
|
|
397
1047
|
|
|
398
1048
|
// src/version.ts
|
|
399
|
-
var VERSION = true ? "1.0.
|
|
1049
|
+
var VERSION = true ? "1.0.50" : "0.0.0-test";
|
|
400
1050
|
|
|
401
1051
|
// src/black-forest-labs-provider.ts
|
|
402
1052
|
var defaultBaseURL = "https://api.bfl.ai/v1";
|
|
@@ -422,6 +1072,14 @@ function createBlackForestLabs(options = {}) {
|
|
|
422
1072
|
pollIntervalMillis: options.pollIntervalMillis,
|
|
423
1073
|
pollTimeoutMillis: options.pollTimeoutMillis
|
|
424
1074
|
});
|
|
1075
|
+
const createVideoModel = (modelId) => new BlackForestLabsVideoModel(modelId, {
|
|
1076
|
+
provider: "black-forest-labs.video",
|
|
1077
|
+
baseURL: baseURL != null ? baseURL : defaultBaseURL,
|
|
1078
|
+
headers: getHeaders,
|
|
1079
|
+
fetch: options.fetch,
|
|
1080
|
+
pollIntervalMillis: options.pollIntervalMillis,
|
|
1081
|
+
pollTimeoutMillis: options.pollTimeoutMillis
|
|
1082
|
+
});
|
|
425
1083
|
const embeddingModel = (modelId) => {
|
|
426
1084
|
throw new NoSuchModelError({
|
|
427
1085
|
modelId,
|
|
@@ -432,6 +1090,8 @@ function createBlackForestLabs(options = {}) {
|
|
|
432
1090
|
specificationVersion: "v3",
|
|
433
1091
|
imageModel: createImageModel,
|
|
434
1092
|
image: createImageModel,
|
|
1093
|
+
videoModel: createVideoModel,
|
|
1094
|
+
video: createVideoModel,
|
|
435
1095
|
languageModel: (modelId) => {
|
|
436
1096
|
throw new NoSuchModelError({
|
|
437
1097
|
modelId,
|