@ai-sdk/fal 3.0.0-beta.2 → 3.0.0-beta.21
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 +168 -8
- package/README.md +2 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +290 -235
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/src/fal-config.ts +1 -1
- package/src/fal-image-model.ts +26 -9
- package/src/fal-provider.ts +13 -13
- package/src/fal-speech-model.ts +25 -8
- package/src/fal-transcription-model.ts +27 -10
- package/src/fal-video-model.ts +9 -9
- package/dist/index.d.mts +0 -156
- package/dist/index.mjs +0 -1126
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,72 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
createFal: () => createFal,
|
|
25
|
-
fal: () => fal
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/fal-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
withoutTrailingSlash,
|
|
7
|
+
withUserAgentSuffix
|
|
8
|
+
} from "@ai-sdk/provider-utils";
|
|
32
9
|
|
|
33
10
|
// src/fal-image-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
import {
|
|
12
|
+
combineHeaders,
|
|
13
|
+
convertImageModelFileToDataUri,
|
|
14
|
+
createBinaryResponseHandler,
|
|
15
|
+
createJsonErrorResponseHandler,
|
|
16
|
+
createJsonResponseHandler,
|
|
17
|
+
createStatusCodeErrorResponseHandler,
|
|
18
|
+
getFromApi,
|
|
19
|
+
parseProviderOptions,
|
|
20
|
+
postJsonToApi,
|
|
21
|
+
resolve,
|
|
22
|
+
serializeModelOptions,
|
|
23
|
+
WORKFLOW_SERIALIZE,
|
|
24
|
+
WORKFLOW_DESERIALIZE
|
|
25
|
+
} from "@ai-sdk/provider-utils";
|
|
26
|
+
import { z as z2 } from "zod/v4";
|
|
36
27
|
|
|
37
28
|
// src/fal-image-options.ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var falImageModelOptionsSchema =
|
|
41
|
-
() =>
|
|
42
|
-
|
|
29
|
+
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
30
|
+
import { z } from "zod/v4";
|
|
31
|
+
var falImageModelOptionsSchema = lazySchema(
|
|
32
|
+
() => zodSchema(
|
|
33
|
+
z.object({
|
|
43
34
|
/** @deprecated use prompt.images instead */
|
|
44
|
-
imageUrl:
|
|
35
|
+
imageUrl: z.string().nullish().meta({
|
|
45
36
|
deprecated: true,
|
|
46
37
|
description: "Use `prompt.images` instead"
|
|
47
38
|
}),
|
|
48
|
-
maskUrl:
|
|
49
|
-
guidanceScale:
|
|
50
|
-
numInferenceSteps:
|
|
51
|
-
enableSafetyChecker:
|
|
52
|
-
outputFormat:
|
|
53
|
-
syncMode:
|
|
54
|
-
strength:
|
|
55
|
-
acceleration:
|
|
56
|
-
safetyTolerance:
|
|
39
|
+
maskUrl: z.string().nullish().meta({ deprecated: true, description: "Use `prompt.mask` instead" }),
|
|
40
|
+
guidanceScale: z.number().min(1).max(20).nullish(),
|
|
41
|
+
numInferenceSteps: z.number().min(1).max(50).nullish(),
|
|
42
|
+
enableSafetyChecker: z.boolean().nullish(),
|
|
43
|
+
outputFormat: z.enum(["jpeg", "png"]).nullish(),
|
|
44
|
+
syncMode: z.boolean().nullish(),
|
|
45
|
+
strength: z.number().nullish(),
|
|
46
|
+
acceleration: z.enum(["none", "regular", "high"]).nullish(),
|
|
47
|
+
safetyTolerance: z.enum(["1", "2", "3", "4", "5", "6"]).or(z.number().min(1).max(6)).nullish(),
|
|
57
48
|
/**
|
|
58
49
|
* When true, converts multiple input images to `image_urls` array instead of `image_url` string.
|
|
59
50
|
*/
|
|
60
|
-
useMultipleImages:
|
|
51
|
+
useMultipleImages: z.boolean().nullish(),
|
|
61
52
|
// Deprecated snake_case versions
|
|
62
|
-
image_url:
|
|
63
|
-
mask_url:
|
|
64
|
-
guidance_scale:
|
|
65
|
-
num_inference_steps:
|
|
66
|
-
enable_safety_checker:
|
|
67
|
-
output_format:
|
|
68
|
-
sync_mode:
|
|
69
|
-
safety_tolerance:
|
|
53
|
+
image_url: z.string().nullish(),
|
|
54
|
+
mask_url: z.string().nullish(),
|
|
55
|
+
guidance_scale: z.number().min(1).max(20).nullish(),
|
|
56
|
+
num_inference_steps: z.number().min(1).max(50).nullish(),
|
|
57
|
+
enable_safety_checker: z.boolean().nullish(),
|
|
58
|
+
output_format: z.enum(["jpeg", "png"]).nullish(),
|
|
59
|
+
sync_mode: z.boolean().nullish(),
|
|
60
|
+
safety_tolerance: z.enum(["1", "2", "3", "4", "5", "6"]).or(z.number().min(1).max(6)).nullish()
|
|
70
61
|
}).passthrough().transform((data) => {
|
|
71
62
|
const result = {};
|
|
72
63
|
const deprecatedKeys = [];
|
|
@@ -133,16 +124,25 @@ var falImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
133
124
|
);
|
|
134
125
|
|
|
135
126
|
// src/fal-image-model.ts
|
|
136
|
-
var FalImageModel = class {
|
|
127
|
+
var FalImageModel = class _FalImageModel {
|
|
137
128
|
constructor(modelId, config) {
|
|
138
129
|
this.modelId = modelId;
|
|
139
130
|
this.config = config;
|
|
140
|
-
this.specificationVersion = "
|
|
131
|
+
this.specificationVersion = "v4";
|
|
141
132
|
this.maxImagesPerCall = 1;
|
|
142
133
|
}
|
|
143
134
|
get provider() {
|
|
144
135
|
return this.config.provider;
|
|
145
136
|
}
|
|
137
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
138
|
+
return serializeModelOptions({
|
|
139
|
+
modelId: model.modelId,
|
|
140
|
+
config: model.config
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
144
|
+
return new _FalImageModel(options.modelId, options.config);
|
|
145
|
+
}
|
|
146
146
|
async getArgs({
|
|
147
147
|
prompt,
|
|
148
148
|
n,
|
|
@@ -162,7 +162,7 @@ var FalImageModel = class {
|
|
|
162
162
|
} else if (aspectRatio) {
|
|
163
163
|
imageSize = convertAspectRatioToSize(aspectRatio);
|
|
164
164
|
}
|
|
165
|
-
const falOptions = await
|
|
165
|
+
const falOptions = await parseProviderOptions({
|
|
166
166
|
provider: "fal",
|
|
167
167
|
providerOptions,
|
|
168
168
|
schema: falImageModelOptionsSchema
|
|
@@ -177,10 +177,10 @@ var FalImageModel = class {
|
|
|
177
177
|
const useMultipleImages = (falOptions == null ? void 0 : falOptions.useMultipleImages) === true;
|
|
178
178
|
if (useMultipleImages) {
|
|
179
179
|
requestBody.image_urls = files.map(
|
|
180
|
-
(file) =>
|
|
180
|
+
(file) => convertImageModelFileToDataUri(file)
|
|
181
181
|
);
|
|
182
182
|
} else {
|
|
183
|
-
requestBody.image_url =
|
|
183
|
+
requestBody.image_url = convertImageModelFileToDataUri(files[0]);
|
|
184
184
|
if (files.length > 1) {
|
|
185
185
|
warnings.push({
|
|
186
186
|
type: "other",
|
|
@@ -190,7 +190,7 @@ var FalImageModel = class {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
if (mask != null) {
|
|
193
|
-
requestBody.mask_url =
|
|
193
|
+
requestBody.mask_url = convertImageModelFileToDataUri(mask);
|
|
194
194
|
}
|
|
195
195
|
if (falOptions) {
|
|
196
196
|
const deprecatedKeys = "__deprecatedKeys" in falOptions ? falOptions.__deprecatedKeys : void 0;
|
|
@@ -231,15 +231,15 @@ var FalImageModel = class {
|
|
|
231
231
|
var _a, _b, _c;
|
|
232
232
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
233
233
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
234
|
-
const { value, responseHeaders } = await
|
|
234
|
+
const { value, responseHeaders } = await postJsonToApi({
|
|
235
235
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
236
|
-
headers:
|
|
237
|
-
await
|
|
236
|
+
headers: combineHeaders(
|
|
237
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
238
238
|
options.headers
|
|
239
239
|
),
|
|
240
240
|
body: requestBody,
|
|
241
241
|
failedResponseHandler: falFailedResponseHandler,
|
|
242
|
-
successfulResponseHandler:
|
|
242
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
243
243
|
falImageResponseSchema
|
|
244
244
|
),
|
|
245
245
|
abortSignal: options.abortSignal,
|
|
@@ -273,7 +273,7 @@ var FalImageModel = class {
|
|
|
273
273
|
images: targetImages.map((image, index) => {
|
|
274
274
|
var _a2;
|
|
275
275
|
const {
|
|
276
|
-
url,
|
|
276
|
+
url: _url,
|
|
277
277
|
content_type: contentType,
|
|
278
278
|
file_name: fileName,
|
|
279
279
|
file_data: fileData,
|
|
@@ -298,13 +298,13 @@ var FalImageModel = class {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
async downloadImage(url, abortSignal) {
|
|
301
|
-
const { value: response } = await
|
|
301
|
+
const { value: response } = await getFromApi({
|
|
302
302
|
url,
|
|
303
303
|
// No specific headers should be needed for this request as it's a
|
|
304
304
|
// generated image provided by fal.ai.
|
|
305
305
|
abortSignal,
|
|
306
|
-
failedResponseHandler:
|
|
307
|
-
successfulResponseHandler:
|
|
306
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
307
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
308
308
|
fetch: this.config.fetch
|
|
309
309
|
});
|
|
310
310
|
return response;
|
|
@@ -338,60 +338,60 @@ function convertAspectRatioToSize(aspectRatio) {
|
|
|
338
338
|
}
|
|
339
339
|
return void 0;
|
|
340
340
|
}
|
|
341
|
-
var falValidationErrorSchema =
|
|
342
|
-
detail:
|
|
343
|
-
|
|
344
|
-
loc:
|
|
345
|
-
msg:
|
|
346
|
-
type:
|
|
341
|
+
var falValidationErrorSchema = z2.object({
|
|
342
|
+
detail: z2.array(
|
|
343
|
+
z2.object({
|
|
344
|
+
loc: z2.array(z2.string()),
|
|
345
|
+
msg: z2.string(),
|
|
346
|
+
type: z2.string()
|
|
347
347
|
})
|
|
348
348
|
)
|
|
349
349
|
});
|
|
350
|
-
var falHttpErrorSchema =
|
|
351
|
-
message:
|
|
350
|
+
var falHttpErrorSchema = z2.object({
|
|
351
|
+
message: z2.string()
|
|
352
352
|
});
|
|
353
|
-
var falErrorSchema =
|
|
354
|
-
var falImageSchema =
|
|
355
|
-
url:
|
|
356
|
-
width:
|
|
357
|
-
height:
|
|
353
|
+
var falErrorSchema = z2.union([falValidationErrorSchema, falHttpErrorSchema]);
|
|
354
|
+
var falImageSchema = z2.object({
|
|
355
|
+
url: z2.string(),
|
|
356
|
+
width: z2.number().nullish(),
|
|
357
|
+
height: z2.number().nullish(),
|
|
358
358
|
// e.g. https://fal.ai/models/fal-ai/fashn/tryon/v1.6/api#schema-output
|
|
359
|
-
content_type:
|
|
359
|
+
content_type: z2.string().nullish(),
|
|
360
360
|
// e.g. https://fal.ai/models/fal-ai/flowedit/api#schema-output
|
|
361
|
-
file_name:
|
|
362
|
-
file_data:
|
|
363
|
-
file_size:
|
|
361
|
+
file_name: z2.string().nullish(),
|
|
362
|
+
file_data: z2.string().optional(),
|
|
363
|
+
file_size: z2.number().nullish()
|
|
364
364
|
});
|
|
365
|
-
var loraFileSchema =
|
|
366
|
-
url:
|
|
367
|
-
content_type:
|
|
368
|
-
file_name:
|
|
369
|
-
file_data:
|
|
370
|
-
file_size:
|
|
365
|
+
var loraFileSchema = z2.object({
|
|
366
|
+
url: z2.string(),
|
|
367
|
+
content_type: z2.string().optional(),
|
|
368
|
+
file_name: z2.string().nullable().optional(),
|
|
369
|
+
file_data: z2.string().optional(),
|
|
370
|
+
file_size: z2.number().nullable().optional()
|
|
371
371
|
});
|
|
372
|
-
var commonResponseSchema =
|
|
373
|
-
timings:
|
|
374
|
-
inference:
|
|
372
|
+
var commonResponseSchema = z2.object({
|
|
373
|
+
timings: z2.object({
|
|
374
|
+
inference: z2.number().optional()
|
|
375
375
|
}).optional(),
|
|
376
|
-
seed:
|
|
377
|
-
has_nsfw_concepts:
|
|
378
|
-
prompt:
|
|
376
|
+
seed: z2.number().optional(),
|
|
377
|
+
has_nsfw_concepts: z2.array(z2.boolean()).optional(),
|
|
378
|
+
prompt: z2.string().optional(),
|
|
379
379
|
// https://fal.ai/models/fal-ai/lcm/api#schema-output
|
|
380
|
-
nsfw_content_detected:
|
|
381
|
-
num_inference_steps:
|
|
380
|
+
nsfw_content_detected: z2.array(z2.boolean()).optional(),
|
|
381
|
+
num_inference_steps: z2.number().optional(),
|
|
382
382
|
// https://fal.ai/models/fal-ai/lora/api#schema-output
|
|
383
383
|
debug_latents: loraFileSchema.optional(),
|
|
384
384
|
debug_per_pass_latents: loraFileSchema.optional()
|
|
385
385
|
});
|
|
386
|
-
var base =
|
|
387
|
-
var falImageResponseSchema =
|
|
388
|
-
base.extend({ images:
|
|
386
|
+
var base = z2.looseObject(commonResponseSchema.shape);
|
|
387
|
+
var falImageResponseSchema = z2.union([
|
|
388
|
+
base.extend({ images: z2.array(falImageSchema) }),
|
|
389
389
|
base.extend({ image: falImageSchema })
|
|
390
|
-
]).transform((v) => "images" in v ? v : { ...v, images: [v.image] }).pipe(base.extend({ images:
|
|
390
|
+
]).transform((v) => "images" in v ? v : { ...v, images: [v.image] }).pipe(base.extend({ images: z2.array(falImageSchema) }));
|
|
391
391
|
function isValidationError(error) {
|
|
392
392
|
return falValidationErrorSchema.safeParse(error).success;
|
|
393
393
|
}
|
|
394
|
-
var falFailedResponseHandler =
|
|
394
|
+
var falFailedResponseHandler = createJsonErrorResponseHandler({
|
|
395
395
|
errorSchema: falErrorSchema,
|
|
396
396
|
errorToMessage: (error) => {
|
|
397
397
|
var _a;
|
|
@@ -403,68 +403,91 @@ var falFailedResponseHandler = (0, import_provider_utils2.createJsonErrorRespons
|
|
|
403
403
|
});
|
|
404
404
|
|
|
405
405
|
// src/fal-transcription-model.ts
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
import {
|
|
407
|
+
AISDKError
|
|
408
|
+
} from "@ai-sdk/provider";
|
|
409
|
+
import {
|
|
410
|
+
combineHeaders as combineHeaders2,
|
|
411
|
+
convertUint8ArrayToBase64,
|
|
412
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
|
|
413
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
414
|
+
delay,
|
|
415
|
+
getFromApi as getFromApi2,
|
|
416
|
+
parseProviderOptions as parseProviderOptions2,
|
|
417
|
+
postJsonToApi as postJsonToApi2,
|
|
418
|
+
serializeModelOptions as serializeModelOptions2,
|
|
419
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
|
|
420
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
|
|
421
|
+
} from "@ai-sdk/provider-utils";
|
|
422
|
+
import { z as z4 } from "zod/v4";
|
|
409
423
|
|
|
410
424
|
// src/fal-error.ts
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
var falErrorDataSchema =
|
|
414
|
-
error:
|
|
415
|
-
message:
|
|
416
|
-
code:
|
|
425
|
+
import { z as z3 } from "zod/v4";
|
|
426
|
+
import { createJsonErrorResponseHandler as createJsonErrorResponseHandler2 } from "@ai-sdk/provider-utils";
|
|
427
|
+
var falErrorDataSchema = z3.object({
|
|
428
|
+
error: z3.object({
|
|
429
|
+
message: z3.string(),
|
|
430
|
+
code: z3.number()
|
|
417
431
|
})
|
|
418
432
|
});
|
|
419
|
-
var falFailedResponseHandler2 = (
|
|
433
|
+
var falFailedResponseHandler2 = createJsonErrorResponseHandler2({
|
|
420
434
|
errorSchema: falErrorDataSchema,
|
|
421
435
|
errorToMessage: (data) => data.error.message
|
|
422
436
|
});
|
|
423
437
|
|
|
424
438
|
// src/fal-transcription-model.ts
|
|
425
|
-
var falTranscriptionModelOptionsSchema =
|
|
439
|
+
var falTranscriptionModelOptionsSchema = z4.object({
|
|
426
440
|
/**
|
|
427
441
|
* Language of the audio file. If set to null, the language will be automatically detected. Defaults to null.
|
|
428
442
|
*
|
|
429
443
|
* If translate is selected as the task, the audio will be translated to English, regardless of the language selected.
|
|
430
444
|
*/
|
|
431
|
-
language:
|
|
445
|
+
language: z4.union([z4.enum(["en"]), z4.string()]).nullish().default("en"),
|
|
432
446
|
/**
|
|
433
447
|
* Whether to diarize the audio file. Defaults to true.
|
|
434
448
|
*/
|
|
435
|
-
diarize:
|
|
449
|
+
diarize: z4.boolean().nullish().default(true),
|
|
436
450
|
/**
|
|
437
451
|
* Level of the chunks to return. Either segment or word. Default value: "segment"
|
|
438
452
|
*/
|
|
439
|
-
chunkLevel:
|
|
453
|
+
chunkLevel: z4.enum(["segment", "word"]).nullish().default("segment"),
|
|
440
454
|
/**
|
|
441
455
|
* Version of the model to use. All of the models are the Whisper large variant. Default value: "3"
|
|
442
456
|
*/
|
|
443
|
-
version:
|
|
457
|
+
version: z4.enum(["3"]).nullish().default("3"),
|
|
444
458
|
/**
|
|
445
459
|
* Default value: 64
|
|
446
460
|
*/
|
|
447
|
-
batchSize:
|
|
461
|
+
batchSize: z4.number().nullish().default(64),
|
|
448
462
|
/**
|
|
449
463
|
* Number of speakers in the audio file. Defaults to null. If not provided, the number of speakers will be automatically detected.
|
|
450
464
|
*/
|
|
451
|
-
numSpeakers:
|
|
465
|
+
numSpeakers: z4.number().nullable().nullish()
|
|
452
466
|
});
|
|
453
|
-
var FalTranscriptionModel = class {
|
|
467
|
+
var FalTranscriptionModel = class _FalTranscriptionModel {
|
|
454
468
|
constructor(modelId, config) {
|
|
455
469
|
this.modelId = modelId;
|
|
456
470
|
this.config = config;
|
|
457
|
-
this.specificationVersion = "
|
|
471
|
+
this.specificationVersion = "v4";
|
|
458
472
|
}
|
|
459
473
|
get provider() {
|
|
460
474
|
return this.config.provider;
|
|
461
475
|
}
|
|
476
|
+
static [WORKFLOW_SERIALIZE2](model) {
|
|
477
|
+
return serializeModelOptions2({
|
|
478
|
+
modelId: model.modelId,
|
|
479
|
+
config: model.config
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
static [WORKFLOW_DESERIALIZE2](options) {
|
|
483
|
+
return new _FalTranscriptionModel(options.modelId, options.config);
|
|
484
|
+
}
|
|
462
485
|
async getArgs({
|
|
463
486
|
providerOptions
|
|
464
487
|
}) {
|
|
465
488
|
var _a, _b, _c;
|
|
466
489
|
const warnings = [];
|
|
467
|
-
const falOptions = await (
|
|
490
|
+
const falOptions = await parseProviderOptions2({
|
|
468
491
|
provider: "fal",
|
|
469
492
|
providerOptions,
|
|
470
493
|
schema: falTranscriptionModelOptionsSchema
|
|
@@ -492,23 +515,23 @@ var FalTranscriptionModel = class {
|
|
|
492
515
|
};
|
|
493
516
|
}
|
|
494
517
|
async doGenerate(options) {
|
|
495
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
518
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
496
519
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
497
520
|
const { body, warnings } = await this.getArgs(options);
|
|
498
|
-
const base64Audio = typeof options.audio === "string" ? options.audio :
|
|
521
|
+
const base64Audio = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase64(options.audio);
|
|
499
522
|
const audioUrl = `data:${options.mediaType};base64,${base64Audio}`;
|
|
500
|
-
const { value: queueResponse } = await (
|
|
523
|
+
const { value: queueResponse } = await postJsonToApi2({
|
|
501
524
|
url: this.config.url({
|
|
502
525
|
path: `https://queue.fal.run/fal-ai/${this.modelId}`,
|
|
503
526
|
modelId: this.modelId
|
|
504
527
|
}),
|
|
505
|
-
headers: (
|
|
528
|
+
headers: combineHeaders2((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
506
529
|
body: {
|
|
507
530
|
...body,
|
|
508
531
|
audio_url: audioUrl
|
|
509
532
|
},
|
|
510
533
|
failedResponseHandler: falFailedResponseHandler2,
|
|
511
|
-
successfulResponseHandler: (
|
|
534
|
+
successfulResponseHandler: createJsonResponseHandler2(falJobResponseSchema),
|
|
512
535
|
abortSignal: options.abortSignal,
|
|
513
536
|
fetch: this.config.fetch
|
|
514
537
|
});
|
|
@@ -524,12 +547,12 @@ var FalTranscriptionModel = class {
|
|
|
524
547
|
value: statusResponse,
|
|
525
548
|
responseHeaders: statusHeaders,
|
|
526
549
|
rawValue: statusRawResponse
|
|
527
|
-
} = await (
|
|
550
|
+
} = await getFromApi2({
|
|
528
551
|
url: this.config.url({
|
|
529
552
|
path: `https://queue.fal.run/fal-ai/${this.modelId}/requests/${queueResponse.request_id}`,
|
|
530
553
|
modelId: this.modelId
|
|
531
554
|
}),
|
|
532
|
-
headers: (
|
|
555
|
+
headers: combineHeaders2((_g = (_f = this.config).headers) == null ? void 0 : _g.call(_f), options.headers),
|
|
533
556
|
failedResponseHandler: async ({
|
|
534
557
|
requestBodyValues,
|
|
535
558
|
response: response2,
|
|
@@ -544,12 +567,12 @@ var FalTranscriptionModel = class {
|
|
|
544
567
|
responseHeaders: {}
|
|
545
568
|
};
|
|
546
569
|
}
|
|
547
|
-
return (
|
|
570
|
+
return createJsonErrorResponseHandler3({
|
|
548
571
|
errorSchema: falErrorDataSchema,
|
|
549
572
|
errorToMessage: (data) => data.error.message
|
|
550
573
|
})({ requestBodyValues, response: response2, url });
|
|
551
574
|
},
|
|
552
|
-
successfulResponseHandler: (
|
|
575
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
553
576
|
falTranscriptionResponseSchema
|
|
554
577
|
),
|
|
555
578
|
abortSignal: options.abortSignal,
|
|
@@ -566,26 +589,26 @@ var FalTranscriptionModel = class {
|
|
|
566
589
|
}
|
|
567
590
|
}
|
|
568
591
|
if (Date.now() - startTime > timeoutMs) {
|
|
569
|
-
throw new
|
|
592
|
+
throw new AISDKError({
|
|
570
593
|
message: "Transcription request timed out after 60 seconds",
|
|
571
594
|
name: "TranscriptionRequestTimedOut",
|
|
572
595
|
cause: response
|
|
573
596
|
});
|
|
574
597
|
}
|
|
575
|
-
await
|
|
598
|
+
await delay(pollIntervalMs);
|
|
576
599
|
}
|
|
577
600
|
return {
|
|
578
601
|
text: response.text,
|
|
579
|
-
segments: (
|
|
602
|
+
segments: (_i = (_h = response.chunks) == null ? void 0 : _h.map((chunk) => {
|
|
580
603
|
var _a2, _b2, _c2, _d2;
|
|
581
604
|
return {
|
|
582
605
|
text: chunk.text,
|
|
583
606
|
startSecond: (_b2 = (_a2 = chunk.timestamp) == null ? void 0 : _a2.at(0)) != null ? _b2 : 0,
|
|
584
607
|
endSecond: (_d2 = (_c2 = chunk.timestamp) == null ? void 0 : _c2.at(1)) != null ? _d2 : 0
|
|
585
608
|
};
|
|
586
|
-
})) != null ?
|
|
587
|
-
language: (
|
|
588
|
-
durationInSeconds: (
|
|
609
|
+
})) != null ? _i : [],
|
|
610
|
+
language: (_k = (_j = response.inferred_languages) == null ? void 0 : _j.at(0)) != null ? _k : void 0,
|
|
611
|
+
durationInSeconds: (_o = (_n = (_m = (_l = response.chunks) == null ? void 0 : _l.at(-1)) == null ? void 0 : _m.timestamp) == null ? void 0 : _n.at(1)) != null ? _o : void 0,
|
|
589
612
|
warnings,
|
|
590
613
|
response: {
|
|
591
614
|
timestamp: currentDate,
|
|
@@ -596,23 +619,34 @@ var FalTranscriptionModel = class {
|
|
|
596
619
|
};
|
|
597
620
|
}
|
|
598
621
|
};
|
|
599
|
-
var falJobResponseSchema =
|
|
600
|
-
request_id:
|
|
622
|
+
var falJobResponseSchema = z4.object({
|
|
623
|
+
request_id: z4.string().nullish()
|
|
601
624
|
});
|
|
602
|
-
var falTranscriptionResponseSchema =
|
|
603
|
-
text:
|
|
604
|
-
chunks:
|
|
605
|
-
|
|
606
|
-
text:
|
|
607
|
-
timestamp:
|
|
625
|
+
var falTranscriptionResponseSchema = z4.object({
|
|
626
|
+
text: z4.string(),
|
|
627
|
+
chunks: z4.array(
|
|
628
|
+
z4.object({
|
|
629
|
+
text: z4.string(),
|
|
630
|
+
timestamp: z4.array(z4.number()).nullish()
|
|
608
631
|
})
|
|
609
632
|
).nullish(),
|
|
610
|
-
inferred_languages:
|
|
633
|
+
inferred_languages: z4.array(z4.string()).nullish()
|
|
611
634
|
});
|
|
612
635
|
|
|
613
636
|
// src/fal-speech-model.ts
|
|
614
|
-
|
|
615
|
-
|
|
637
|
+
import {
|
|
638
|
+
combineHeaders as combineHeaders3,
|
|
639
|
+
createBinaryResponseHandler as createBinaryResponseHandler2,
|
|
640
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
641
|
+
createStatusCodeErrorResponseHandler as createStatusCodeErrorResponseHandler2,
|
|
642
|
+
getFromApi as getFromApi3,
|
|
643
|
+
parseProviderOptions as parseProviderOptions3,
|
|
644
|
+
postJsonToApi as postJsonToApi3,
|
|
645
|
+
serializeModelOptions as serializeModelOptions3,
|
|
646
|
+
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
647
|
+
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
|
|
648
|
+
} from "@ai-sdk/provider-utils";
|
|
649
|
+
import { z as z5 } from "zod/v4";
|
|
616
650
|
|
|
617
651
|
// src/fal-api-types.ts
|
|
618
652
|
var FAL_LANGUAGE_BOOSTS = [
|
|
@@ -653,28 +687,37 @@ var FAL_EMOTIONS = [
|
|
|
653
687
|
];
|
|
654
688
|
|
|
655
689
|
// src/fal-speech-model.ts
|
|
656
|
-
var falSpeechModelOptionsSchema =
|
|
657
|
-
voice_setting:
|
|
658
|
-
speed:
|
|
659
|
-
vol:
|
|
660
|
-
voice_id:
|
|
661
|
-
pitch:
|
|
662
|
-
english_normalization:
|
|
663
|
-
emotion:
|
|
690
|
+
var falSpeechModelOptionsSchema = z5.looseObject({
|
|
691
|
+
voice_setting: z5.object({
|
|
692
|
+
speed: z5.number().nullish(),
|
|
693
|
+
vol: z5.number().nullish(),
|
|
694
|
+
voice_id: z5.string().nullish(),
|
|
695
|
+
pitch: z5.number().nullish(),
|
|
696
|
+
english_normalization: z5.boolean().nullish(),
|
|
697
|
+
emotion: z5.enum(FAL_EMOTIONS).nullish()
|
|
664
698
|
}).partial().nullish(),
|
|
665
|
-
audio_setting:
|
|
666
|
-
language_boost:
|
|
667
|
-
pronunciation_dict:
|
|
699
|
+
audio_setting: z5.record(z5.string(), z5.unknown()).nullish(),
|
|
700
|
+
language_boost: z5.enum(FAL_LANGUAGE_BOOSTS).nullish(),
|
|
701
|
+
pronunciation_dict: z5.record(z5.string(), z5.string()).nullish()
|
|
668
702
|
});
|
|
669
|
-
var FalSpeechModel = class {
|
|
703
|
+
var FalSpeechModel = class _FalSpeechModel {
|
|
670
704
|
constructor(modelId, config) {
|
|
671
705
|
this.modelId = modelId;
|
|
672
706
|
this.config = config;
|
|
673
|
-
this.specificationVersion = "
|
|
707
|
+
this.specificationVersion = "v4";
|
|
674
708
|
}
|
|
675
709
|
get provider() {
|
|
676
710
|
return this.config.provider;
|
|
677
711
|
}
|
|
712
|
+
static [WORKFLOW_SERIALIZE3](model) {
|
|
713
|
+
return serializeModelOptions3({
|
|
714
|
+
modelId: model.modelId,
|
|
715
|
+
config: model.config
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
static [WORKFLOW_DESERIALIZE3](options) {
|
|
719
|
+
return new _FalSpeechModel(options.modelId, options.config);
|
|
720
|
+
}
|
|
678
721
|
async getArgs({
|
|
679
722
|
text,
|
|
680
723
|
voice,
|
|
@@ -684,7 +727,7 @@ var FalSpeechModel = class {
|
|
|
684
727
|
providerOptions
|
|
685
728
|
}) {
|
|
686
729
|
const warnings = [];
|
|
687
|
-
const falOptions = await (
|
|
730
|
+
const falOptions = await parseProviderOptions3({
|
|
688
731
|
provider: "fal",
|
|
689
732
|
providerOptions,
|
|
690
733
|
schema: falSpeechModelOptionsSchema
|
|
@@ -713,32 +756,32 @@ var FalSpeechModel = class {
|
|
|
713
756
|
return { requestBody, warnings };
|
|
714
757
|
}
|
|
715
758
|
async doGenerate(options) {
|
|
716
|
-
var _a, _b, _c;
|
|
759
|
+
var _a, _b, _c, _d, _e;
|
|
717
760
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
718
761
|
const { requestBody, warnings } = await this.getArgs(options);
|
|
719
762
|
const {
|
|
720
763
|
value: json,
|
|
721
764
|
responseHeaders,
|
|
722
765
|
rawValue
|
|
723
|
-
} = await (
|
|
766
|
+
} = await postJsonToApi3({
|
|
724
767
|
url: this.config.url({
|
|
725
768
|
path: `https://fal.run/${this.modelId}`,
|
|
726
769
|
modelId: this.modelId
|
|
727
770
|
}),
|
|
728
|
-
headers: (
|
|
771
|
+
headers: combineHeaders3((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
729
772
|
body: requestBody,
|
|
730
773
|
failedResponseHandler: falFailedResponseHandler2,
|
|
731
|
-
successfulResponseHandler: (
|
|
774
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
732
775
|
falSpeechResponseSchema
|
|
733
776
|
),
|
|
734
777
|
abortSignal: options.abortSignal,
|
|
735
778
|
fetch: this.config.fetch
|
|
736
779
|
});
|
|
737
780
|
const audioUrl = json.audio.url;
|
|
738
|
-
const { value: audio } = await (
|
|
781
|
+
const { value: audio } = await getFromApi3({
|
|
739
782
|
url: audioUrl,
|
|
740
|
-
failedResponseHandler: (
|
|
741
|
-
successfulResponseHandler: (
|
|
783
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler2(),
|
|
784
|
+
successfulResponseHandler: createBinaryResponseHandler2(),
|
|
742
785
|
abortSignal: options.abortSignal,
|
|
743
786
|
fetch: this.config.fetch
|
|
744
787
|
});
|
|
@@ -757,31 +800,44 @@ var FalSpeechModel = class {
|
|
|
757
800
|
};
|
|
758
801
|
}
|
|
759
802
|
};
|
|
760
|
-
var falSpeechResponseSchema =
|
|
761
|
-
audio:
|
|
762
|
-
duration_ms:
|
|
763
|
-
request_id:
|
|
803
|
+
var falSpeechResponseSchema = z5.object({
|
|
804
|
+
audio: z5.object({ url: z5.string() }),
|
|
805
|
+
duration_ms: z5.number().optional(),
|
|
806
|
+
request_id: z5.string().optional()
|
|
764
807
|
});
|
|
765
808
|
|
|
766
809
|
// src/fal-video-model.ts
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
810
|
+
import {
|
|
811
|
+
AISDKError as AISDKError2
|
|
812
|
+
} from "@ai-sdk/provider";
|
|
813
|
+
import {
|
|
814
|
+
combineHeaders as combineHeaders4,
|
|
815
|
+
convertImageModelFileToDataUri as convertImageModelFileToDataUri2,
|
|
816
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
|
|
817
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
818
|
+
delay as delay2,
|
|
819
|
+
getFromApi as getFromApi4,
|
|
820
|
+
lazySchema as lazySchema2,
|
|
821
|
+
parseProviderOptions as parseProviderOptions4,
|
|
822
|
+
postJsonToApi as postJsonToApi4,
|
|
823
|
+
zodSchema as zodSchema2
|
|
824
|
+
} from "@ai-sdk/provider-utils";
|
|
825
|
+
import { z as z6 } from "zod/v4";
|
|
826
|
+
var falVideoModelOptionsSchema = lazySchema2(
|
|
827
|
+
() => zodSchema2(
|
|
828
|
+
z6.object({
|
|
773
829
|
// Video loop - only for Luma models
|
|
774
|
-
loop:
|
|
830
|
+
loop: z6.boolean().nullish(),
|
|
775
831
|
// Motion strength (provider-specific)
|
|
776
|
-
motionStrength:
|
|
832
|
+
motionStrength: z6.number().min(0).max(1).nullish(),
|
|
777
833
|
// Polling configuration
|
|
778
|
-
pollIntervalMs:
|
|
779
|
-
pollTimeoutMs:
|
|
834
|
+
pollIntervalMs: z6.number().positive().nullish(),
|
|
835
|
+
pollTimeoutMs: z6.number().positive().nullish(),
|
|
780
836
|
// Resolution (model-specific, e.g., '480p', '720p', '1080p')
|
|
781
|
-
resolution:
|
|
837
|
+
resolution: z6.string().nullish(),
|
|
782
838
|
// Model-specific parameters
|
|
783
|
-
negativePrompt:
|
|
784
|
-
promptOptimizer:
|
|
839
|
+
negativePrompt: z6.string().nullish(),
|
|
840
|
+
promptOptimizer: z6.boolean().nullish()
|
|
785
841
|
}).passthrough()
|
|
786
842
|
)
|
|
787
843
|
);
|
|
@@ -789,7 +845,7 @@ var FalVideoModel = class {
|
|
|
789
845
|
constructor(modelId, config) {
|
|
790
846
|
this.modelId = modelId;
|
|
791
847
|
this.config = config;
|
|
792
|
-
this.specificationVersion = "
|
|
848
|
+
this.specificationVersion = "v4";
|
|
793
849
|
this.maxVideosPerCall = 1;
|
|
794
850
|
}
|
|
795
851
|
// FAL video models support 1 video at a time
|
|
@@ -800,10 +856,10 @@ var FalVideoModel = class {
|
|
|
800
856
|
return this.modelId.replace(/^fal-ai\//, "").replace(/^fal\//, "");
|
|
801
857
|
}
|
|
802
858
|
async doGenerate(options) {
|
|
803
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
859
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
804
860
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
805
861
|
const warnings = [];
|
|
806
|
-
const falOptions = await (
|
|
862
|
+
const falOptions = await parseProviderOptions4({
|
|
807
863
|
provider: "fal",
|
|
808
864
|
providerOptions: options.providerOptions,
|
|
809
865
|
schema: falVideoModelOptionsSchema
|
|
@@ -816,7 +872,7 @@ var FalVideoModel = class {
|
|
|
816
872
|
if (options.image.type === "url") {
|
|
817
873
|
body.image_url = options.image.url;
|
|
818
874
|
} else {
|
|
819
|
-
body.image_url = (
|
|
875
|
+
body.image_url = convertImageModelFileToDataUri2(options.image);
|
|
820
876
|
}
|
|
821
877
|
}
|
|
822
878
|
if (options.aspectRatio) {
|
|
@@ -859,38 +915,38 @@ var FalVideoModel = class {
|
|
|
859
915
|
}
|
|
860
916
|
}
|
|
861
917
|
}
|
|
862
|
-
const { value: queueResponse } = await (
|
|
918
|
+
const { value: queueResponse } = await postJsonToApi4({
|
|
863
919
|
url: this.config.url({
|
|
864
920
|
path: `https://queue.fal.run/fal-ai/${this.normalizedModelId}`,
|
|
865
921
|
modelId: this.modelId
|
|
866
922
|
}),
|
|
867
|
-
headers: (
|
|
923
|
+
headers: combineHeaders4((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers),
|
|
868
924
|
body,
|
|
869
925
|
failedResponseHandler: falFailedResponseHandler2,
|
|
870
|
-
successfulResponseHandler: (
|
|
926
|
+
successfulResponseHandler: createJsonResponseHandler4(falJobResponseSchema2),
|
|
871
927
|
abortSignal: options.abortSignal,
|
|
872
928
|
fetch: this.config.fetch
|
|
873
929
|
});
|
|
874
930
|
const responseUrl = queueResponse.response_url;
|
|
875
931
|
if (!responseUrl) {
|
|
876
|
-
throw new
|
|
932
|
+
throw new AISDKError2({
|
|
877
933
|
name: "FAL_VIDEO_GENERATION_ERROR",
|
|
878
934
|
message: "No response URL returned from queue endpoint"
|
|
879
935
|
});
|
|
880
936
|
}
|
|
881
|
-
const pollIntervalMs = (
|
|
882
|
-
const pollTimeoutMs = (
|
|
937
|
+
const pollIntervalMs = (_f = falOptions == null ? void 0 : falOptions.pollIntervalMs) != null ? _f : 2e3;
|
|
938
|
+
const pollTimeoutMs = (_g = falOptions == null ? void 0 : falOptions.pollTimeoutMs) != null ? _g : 3e5;
|
|
883
939
|
const startTime = Date.now();
|
|
884
940
|
let response;
|
|
885
941
|
let responseHeaders;
|
|
886
942
|
while (true) {
|
|
887
943
|
try {
|
|
888
|
-
const { value: statusResponse, responseHeaders: statusHeaders } = await (
|
|
944
|
+
const { value: statusResponse, responseHeaders: statusHeaders } = await getFromApi4({
|
|
889
945
|
url: this.config.url({
|
|
890
946
|
path: responseUrl,
|
|
891
947
|
modelId: this.modelId
|
|
892
948
|
}),
|
|
893
|
-
headers: (
|
|
949
|
+
headers: combineHeaders4((_i = (_h = this.config).headers) == null ? void 0 : _i.call(_h), options.headers),
|
|
894
950
|
failedResponseHandler: async ({
|
|
895
951
|
response: response2,
|
|
896
952
|
url,
|
|
@@ -904,12 +960,12 @@ var FalVideoModel = class {
|
|
|
904
960
|
responseHeaders: {}
|
|
905
961
|
};
|
|
906
962
|
}
|
|
907
|
-
return (
|
|
963
|
+
return createJsonErrorResponseHandler4({
|
|
908
964
|
errorSchema: falErrorDataSchema,
|
|
909
965
|
errorToMessage: (data) => data.error.message
|
|
910
966
|
})({ response: response2, url, requestBodyValues });
|
|
911
967
|
},
|
|
912
|
-
successfulResponseHandler: (
|
|
968
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
913
969
|
falVideoResponseSchema
|
|
914
970
|
),
|
|
915
971
|
abortSignal: options.abortSignal,
|
|
@@ -925,22 +981,22 @@ var FalVideoModel = class {
|
|
|
925
981
|
}
|
|
926
982
|
}
|
|
927
983
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
928
|
-
throw new
|
|
984
|
+
throw new AISDKError2({
|
|
929
985
|
name: "FAL_VIDEO_GENERATION_TIMEOUT",
|
|
930
986
|
message: `Video generation request timed out after ${pollTimeoutMs}ms`
|
|
931
987
|
});
|
|
932
988
|
}
|
|
933
|
-
await (
|
|
934
|
-
if ((
|
|
935
|
-
throw new
|
|
989
|
+
await delay2(pollIntervalMs);
|
|
990
|
+
if ((_j = options.abortSignal) == null ? void 0 : _j.aborted) {
|
|
991
|
+
throw new AISDKError2({
|
|
936
992
|
name: "FAL_VIDEO_GENERATION_ABORTED",
|
|
937
993
|
message: "Video generation request was aborted"
|
|
938
994
|
});
|
|
939
995
|
}
|
|
940
996
|
}
|
|
941
|
-
const videoUrl = (
|
|
997
|
+
const videoUrl = (_k = response.video) == null ? void 0 : _k.url;
|
|
942
998
|
if (!videoUrl || !response.video) {
|
|
943
|
-
throw new
|
|
999
|
+
throw new AISDKError2({
|
|
944
1000
|
name: "FAL_VIDEO_GENERATION_ERROR",
|
|
945
1001
|
message: "No video URL in response"
|
|
946
1002
|
});
|
|
@@ -980,29 +1036,29 @@ var FalVideoModel = class {
|
|
|
980
1036
|
};
|
|
981
1037
|
}
|
|
982
1038
|
};
|
|
983
|
-
var falJobResponseSchema2 =
|
|
984
|
-
request_id:
|
|
985
|
-
response_url:
|
|
1039
|
+
var falJobResponseSchema2 = z6.object({
|
|
1040
|
+
request_id: z6.string().nullish(),
|
|
1041
|
+
response_url: z6.string().nullish()
|
|
986
1042
|
});
|
|
987
|
-
var falVideoResponseSchema =
|
|
988
|
-
video:
|
|
989
|
-
url:
|
|
990
|
-
width:
|
|
991
|
-
height:
|
|
992
|
-
duration:
|
|
993
|
-
fps:
|
|
994
|
-
content_type:
|
|
1043
|
+
var falVideoResponseSchema = z6.object({
|
|
1044
|
+
video: z6.object({
|
|
1045
|
+
url: z6.string(),
|
|
1046
|
+
width: z6.number().nullish(),
|
|
1047
|
+
height: z6.number().nullish(),
|
|
1048
|
+
duration: z6.number().nullish(),
|
|
1049
|
+
fps: z6.number().nullish(),
|
|
1050
|
+
content_type: z6.string().nullish()
|
|
995
1051
|
}).nullish(),
|
|
996
|
-
seed:
|
|
997
|
-
timings:
|
|
998
|
-
inference:
|
|
1052
|
+
seed: z6.number().nullish(),
|
|
1053
|
+
timings: z6.object({
|
|
1054
|
+
inference: z6.number().nullish()
|
|
999
1055
|
}).nullish(),
|
|
1000
|
-
has_nsfw_concepts:
|
|
1001
|
-
prompt:
|
|
1056
|
+
has_nsfw_concepts: z6.array(z6.boolean()).nullish(),
|
|
1057
|
+
prompt: z6.string().nullish()
|
|
1002
1058
|
});
|
|
1003
1059
|
|
|
1004
1060
|
// src/version.ts
|
|
1005
|
-
var VERSION = true ? "3.0.0-beta.
|
|
1061
|
+
var VERSION = true ? "3.0.0-beta.21" : "0.0.0-test";
|
|
1006
1062
|
|
|
1007
1063
|
// src/fal-provider.ts
|
|
1008
1064
|
var defaultBaseURL = "https://fal.run";
|
|
@@ -1039,8 +1095,8 @@ function loadFalApiKey({
|
|
|
1039
1095
|
}
|
|
1040
1096
|
function createFal(options = {}) {
|
|
1041
1097
|
var _a;
|
|
1042
|
-
const baseURL =
|
|
1043
|
-
const getHeaders = () =>
|
|
1098
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
1099
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
1044
1100
|
{
|
|
1045
1101
|
Authorization: `Key ${loadFalApiKey({
|
|
1046
1102
|
apiKey: options.apiKey
|
|
@@ -1074,17 +1130,17 @@ function createFal(options = {}) {
|
|
|
1074
1130
|
fetch: options.fetch
|
|
1075
1131
|
});
|
|
1076
1132
|
const embeddingModel = (modelId) => {
|
|
1077
|
-
throw new
|
|
1133
|
+
throw new NoSuchModelError({
|
|
1078
1134
|
modelId,
|
|
1079
1135
|
modelType: "embeddingModel"
|
|
1080
1136
|
});
|
|
1081
1137
|
};
|
|
1082
1138
|
return {
|
|
1083
|
-
specificationVersion: "
|
|
1139
|
+
specificationVersion: "v4",
|
|
1084
1140
|
imageModel: createImageModel,
|
|
1085
1141
|
image: createImageModel,
|
|
1086
1142
|
languageModel: (modelId) => {
|
|
1087
|
-
throw new
|
|
1143
|
+
throw new NoSuchModelError({
|
|
1088
1144
|
modelId,
|
|
1089
1145
|
modelType: "languageModel"
|
|
1090
1146
|
});
|
|
@@ -1098,10 +1154,9 @@ function createFal(options = {}) {
|
|
|
1098
1154
|
};
|
|
1099
1155
|
}
|
|
1100
1156
|
var fal = createFal();
|
|
1101
|
-
|
|
1102
|
-
0 && (module.exports = {
|
|
1157
|
+
export {
|
|
1103
1158
|
VERSION,
|
|
1104
1159
|
createFal,
|
|
1105
1160
|
fal
|
|
1106
|
-
}
|
|
1161
|
+
};
|
|
1107
1162
|
//# sourceMappingURL=index.js.map
|