@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/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
- var import_provider3 = require("@ai-sdk/provider");
31
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
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
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
35
- var import_v42 = require("zod/v4");
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
- var import_provider_utils = require("@ai-sdk/provider-utils");
39
- var import_v4 = require("zod/v4");
40
- var falImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
41
- () => (0, import_provider_utils.zodSchema)(
42
- import_v4.z.object({
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: import_v4.z.string().nullish().meta({
35
+ imageUrl: z.string().nullish().meta({
45
36
  deprecated: true,
46
37
  description: "Use `prompt.images` instead"
47
38
  }),
48
- maskUrl: import_v4.z.string().nullish().meta({ deprecated: true, description: "Use `prompt.mask` instead" }),
49
- guidanceScale: import_v4.z.number().min(1).max(20).nullish(),
50
- numInferenceSteps: import_v4.z.number().min(1).max(50).nullish(),
51
- enableSafetyChecker: import_v4.z.boolean().nullish(),
52
- outputFormat: import_v4.z.enum(["jpeg", "png"]).nullish(),
53
- syncMode: import_v4.z.boolean().nullish(),
54
- strength: import_v4.z.number().nullish(),
55
- acceleration: import_v4.z.enum(["none", "regular", "high"]).nullish(),
56
- safetyTolerance: import_v4.z.enum(["1", "2", "3", "4", "5", "6"]).or(import_v4.z.number().min(1).max(6)).nullish(),
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: import_v4.z.boolean().nullish(),
51
+ useMultipleImages: z.boolean().nullish(),
61
52
  // Deprecated snake_case versions
62
- image_url: import_v4.z.string().nullish(),
63
- mask_url: import_v4.z.string().nullish(),
64
- guidance_scale: import_v4.z.number().min(1).max(20).nullish(),
65
- num_inference_steps: import_v4.z.number().min(1).max(50).nullish(),
66
- enable_safety_checker: import_v4.z.boolean().nullish(),
67
- output_format: import_v4.z.enum(["jpeg", "png"]).nullish(),
68
- sync_mode: import_v4.z.boolean().nullish(),
69
- safety_tolerance: import_v4.z.enum(["1", "2", "3", "4", "5", "6"]).or(import_v4.z.number().min(1).max(6)).nullish()
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 = "v3";
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 (0, import_provider_utils2.parseProviderOptions)({
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) => (0, import_provider_utils2.convertImageModelFileToDataUri)(file)
180
+ (file) => convertImageModelFileToDataUri(file)
181
181
  );
182
182
  } else {
183
- requestBody.image_url = (0, import_provider_utils2.convertImageModelFileToDataUri)(files[0]);
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 = (0, import_provider_utils2.convertImageModelFileToDataUri)(mask);
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 (0, import_provider_utils2.postJsonToApi)({
234
+ const { value, responseHeaders } = await postJsonToApi({
235
235
  url: `${this.config.baseURL}/${this.modelId}`,
236
- headers: (0, import_provider_utils2.combineHeaders)(
237
- await (0, import_provider_utils2.resolve)(this.config.headers),
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: (0, import_provider_utils2.createJsonResponseHandler)(
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 (0, import_provider_utils2.getFromApi)({
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: (0, import_provider_utils2.createStatusCodeErrorResponseHandler)(),
307
- successfulResponseHandler: (0, import_provider_utils2.createBinaryResponseHandler)(),
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 = import_v42.z.object({
342
- detail: import_v42.z.array(
343
- import_v42.z.object({
344
- loc: import_v42.z.array(import_v42.z.string()),
345
- msg: import_v42.z.string(),
346
- type: import_v42.z.string()
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 = import_v42.z.object({
351
- message: import_v42.z.string()
350
+ var falHttpErrorSchema = z2.object({
351
+ message: z2.string()
352
352
  });
353
- var falErrorSchema = import_v42.z.union([falValidationErrorSchema, falHttpErrorSchema]);
354
- var falImageSchema = import_v42.z.object({
355
- url: import_v42.z.string(),
356
- width: import_v42.z.number().nullish(),
357
- height: import_v42.z.number().nullish(),
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: import_v42.z.string().nullish(),
359
+ content_type: z2.string().nullish(),
360
360
  // e.g. https://fal.ai/models/fal-ai/flowedit/api#schema-output
361
- file_name: import_v42.z.string().nullish(),
362
- file_data: import_v42.z.string().optional(),
363
- file_size: import_v42.z.number().nullish()
361
+ file_name: z2.string().nullish(),
362
+ file_data: z2.string().optional(),
363
+ file_size: z2.number().nullish()
364
364
  });
365
- var loraFileSchema = import_v42.z.object({
366
- url: import_v42.z.string(),
367
- content_type: import_v42.z.string().optional(),
368
- file_name: import_v42.z.string().nullable().optional(),
369
- file_data: import_v42.z.string().optional(),
370
- file_size: import_v42.z.number().nullable().optional()
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 = import_v42.z.object({
373
- timings: import_v42.z.object({
374
- inference: import_v42.z.number().optional()
372
+ var commonResponseSchema = z2.object({
373
+ timings: z2.object({
374
+ inference: z2.number().optional()
375
375
  }).optional(),
376
- seed: import_v42.z.number().optional(),
377
- has_nsfw_concepts: import_v42.z.array(import_v42.z.boolean()).optional(),
378
- prompt: import_v42.z.string().optional(),
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: import_v42.z.array(import_v42.z.boolean()).optional(),
381
- num_inference_steps: import_v42.z.number().optional(),
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 = import_v42.z.looseObject(commonResponseSchema.shape);
387
- var falImageResponseSchema = import_v42.z.union([
388
- base.extend({ images: import_v42.z.array(falImageSchema) }),
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: import_v42.z.array(falImageSchema) }));
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 = (0, import_provider_utils2.createJsonErrorResponseHandler)({
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
- var import_provider = require("@ai-sdk/provider");
407
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
408
- var import_v44 = require("zod/v4");
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
- var import_v43 = require("zod/v4");
412
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
413
- var falErrorDataSchema = import_v43.z.object({
414
- error: import_v43.z.object({
415
- message: import_v43.z.string(),
416
- code: import_v43.z.number()
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 = (0, import_provider_utils3.createJsonErrorResponseHandler)({
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 = import_v44.z.object({
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: import_v44.z.union([import_v44.z.enum(["en"]), import_v44.z.string()]).nullish().default("en"),
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: import_v44.z.boolean().nullish().default(true),
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: import_v44.z.enum(["segment", "word"]).nullish().default("segment"),
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: import_v44.z.enum(["3"]).nullish().default("3"),
457
+ version: z4.enum(["3"]).nullish().default("3"),
444
458
  /**
445
459
  * Default value: 64
446
460
  */
447
- batchSize: import_v44.z.number().nullish().default(64),
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: import_v44.z.number().nullable().nullish()
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 = "v3";
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 (0, import_provider_utils4.parseProviderOptions)({
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 : (0, import_provider_utils4.convertUint8ArrayToBase64)(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 (0, import_provider_utils4.postJsonToApi)({
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: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.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: (0, import_provider_utils4.createJsonResponseHandler)(falJobResponseSchema),
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 (0, import_provider_utils4.getFromApi)({
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: (0, import_provider_utils4.combineHeaders)(this.config.headers(), options.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 (0, import_provider_utils4.createJsonErrorResponseHandler)({
570
+ return createJsonErrorResponseHandler3({
548
571
  errorSchema: falErrorDataSchema,
549
572
  errorToMessage: (data) => data.error.message
550
573
  })({ requestBodyValues, response: response2, url });
551
574
  },
552
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
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 import_provider.AISDKError({
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 (0, import_provider_utils4.delay)(pollIntervalMs);
598
+ await delay(pollIntervalMs);
576
599
  }
577
600
  return {
578
601
  text: response.text,
579
- segments: (_e = (_d = response.chunks) == null ? void 0 : _d.map((chunk) => {
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 ? _e : [],
587
- language: (_g = (_f = response.inferred_languages) == null ? void 0 : _f.at(0)) != null ? _g : void 0,
588
- durationInSeconds: (_k = (_j = (_i = (_h = response.chunks) == null ? void 0 : _h.at(-1)) == null ? void 0 : _i.timestamp) == null ? void 0 : _j.at(1)) != null ? _k : void 0,
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 = import_v44.z.object({
600
- request_id: import_v44.z.string().nullish()
622
+ var falJobResponseSchema = z4.object({
623
+ request_id: z4.string().nullish()
601
624
  });
602
- var falTranscriptionResponseSchema = import_v44.z.object({
603
- text: import_v44.z.string(),
604
- chunks: import_v44.z.array(
605
- import_v44.z.object({
606
- text: import_v44.z.string(),
607
- timestamp: import_v44.z.array(import_v44.z.number()).nullish()
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: import_v44.z.array(import_v44.z.string()).nullish()
633
+ inferred_languages: z4.array(z4.string()).nullish()
611
634
  });
612
635
 
613
636
  // src/fal-speech-model.ts
614
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
615
- var import_v45 = require("zod/v4");
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 = import_v45.z.looseObject({
657
- voice_setting: import_v45.z.object({
658
- speed: import_v45.z.number().nullish(),
659
- vol: import_v45.z.number().nullish(),
660
- voice_id: import_v45.z.string().nullish(),
661
- pitch: import_v45.z.number().nullish(),
662
- english_normalization: import_v45.z.boolean().nullish(),
663
- emotion: import_v45.z.enum(FAL_EMOTIONS).nullish()
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: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish(),
666
- language_boost: import_v45.z.enum(FAL_LANGUAGE_BOOSTS).nullish(),
667
- pronunciation_dict: import_v45.z.record(import_v45.z.string(), import_v45.z.string()).nullish()
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 = "v3";
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 (0, import_provider_utils5.parseProviderOptions)({
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 (0, import_provider_utils5.postJsonToApi)({
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: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.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: (0, import_provider_utils5.createJsonResponseHandler)(
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 (0, import_provider_utils5.getFromApi)({
781
+ const { value: audio } = await getFromApi3({
739
782
  url: audioUrl,
740
- failedResponseHandler: (0, import_provider_utils5.createStatusCodeErrorResponseHandler)(),
741
- successfulResponseHandler: (0, import_provider_utils5.createBinaryResponseHandler)(),
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 = import_v45.z.object({
761
- audio: import_v45.z.object({ url: import_v45.z.string() }),
762
- duration_ms: import_v45.z.number().optional(),
763
- request_id: import_v45.z.string().optional()
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
- var import_provider2 = require("@ai-sdk/provider");
768
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
769
- var import_v46 = require("zod/v4");
770
- var falVideoModelOptionsSchema = (0, import_provider_utils6.lazySchema)(
771
- () => (0, import_provider_utils6.zodSchema)(
772
- import_v46.z.object({
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: import_v46.z.boolean().nullish(),
830
+ loop: z6.boolean().nullish(),
775
831
  // Motion strength (provider-specific)
776
- motionStrength: import_v46.z.number().min(0).max(1).nullish(),
832
+ motionStrength: z6.number().min(0).max(1).nullish(),
777
833
  // Polling configuration
778
- pollIntervalMs: import_v46.z.number().positive().nullish(),
779
- pollTimeoutMs: import_v46.z.number().positive().nullish(),
834
+ pollIntervalMs: z6.number().positive().nullish(),
835
+ pollTimeoutMs: z6.number().positive().nullish(),
780
836
  // Resolution (model-specific, e.g., '480p', '720p', '1080p')
781
- resolution: import_v46.z.string().nullish(),
837
+ resolution: z6.string().nullish(),
782
838
  // Model-specific parameters
783
- negativePrompt: import_v46.z.string().nullish(),
784
- promptOptimizer: import_v46.z.boolean().nullish()
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 = "v3";
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 (0, import_provider_utils6.parseProviderOptions)({
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 = (0, import_provider_utils6.convertImageModelFileToDataUri)(options.image);
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 (0, import_provider_utils6.postJsonToApi)({
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: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.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: (0, import_provider_utils6.createJsonResponseHandler)(falJobResponseSchema2),
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 import_provider2.AISDKError({
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 = (_d = falOptions == null ? void 0 : falOptions.pollIntervalMs) != null ? _d : 2e3;
882
- const pollTimeoutMs = (_e = falOptions == null ? void 0 : falOptions.pollTimeoutMs) != null ? _e : 3e5;
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 (0, import_provider_utils6.getFromApi)({
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: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.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 (0, import_provider_utils6.createJsonErrorResponseHandler)({
963
+ return createJsonErrorResponseHandler4({
908
964
  errorSchema: falErrorDataSchema,
909
965
  errorToMessage: (data) => data.error.message
910
966
  })({ response: response2, url, requestBodyValues });
911
967
  },
912
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
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 import_provider2.AISDKError({
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 (0, import_provider_utils6.delay)(pollIntervalMs);
934
- if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
935
- throw new import_provider2.AISDKError({
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 = (_g = response.video) == null ? void 0 : _g.url;
997
+ const videoUrl = (_k = response.video) == null ? void 0 : _k.url;
942
998
  if (!videoUrl || !response.video) {
943
- throw new import_provider2.AISDKError({
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 = import_v46.z.object({
984
- request_id: import_v46.z.string().nullish(),
985
- response_url: import_v46.z.string().nullish()
1039
+ var falJobResponseSchema2 = z6.object({
1040
+ request_id: z6.string().nullish(),
1041
+ response_url: z6.string().nullish()
986
1042
  });
987
- var falVideoResponseSchema = import_v46.z.object({
988
- video: import_v46.z.object({
989
- url: import_v46.z.string(),
990
- width: import_v46.z.number().nullish(),
991
- height: import_v46.z.number().nullish(),
992
- duration: import_v46.z.number().nullish(),
993
- fps: import_v46.z.number().nullish(),
994
- content_type: import_v46.z.string().nullish()
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: import_v46.z.number().nullish(),
997
- timings: import_v46.z.object({
998
- inference: import_v46.z.number().nullish()
1052
+ seed: z6.number().nullish(),
1053
+ timings: z6.object({
1054
+ inference: z6.number().nullish()
999
1055
  }).nullish(),
1000
- has_nsfw_concepts: import_v46.z.array(import_v46.z.boolean()).nullish(),
1001
- prompt: import_v46.z.string().nullish()
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.2" : "0.0.0-test";
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 = (0, import_provider_utils7.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : defaultBaseURL);
1043
- const getHeaders = () => (0, import_provider_utils7.withUserAgentSuffix)(
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 import_provider3.NoSuchModelError({
1133
+ throw new NoSuchModelError({
1078
1134
  modelId,
1079
1135
  modelType: "embeddingModel"
1080
1136
  });
1081
1137
  };
1082
1138
  return {
1083
- specificationVersion: "v3",
1139
+ specificationVersion: "v4",
1084
1140
  imageModel: createImageModel,
1085
1141
  image: createImageModel,
1086
1142
  languageModel: (modelId) => {
1087
- throw new import_provider3.NoSuchModelError({
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
- // Annotate the CommonJS export names for ESM import in node:
1102
- 0 && (module.exports = {
1157
+ export {
1103
1158
  VERSION,
1104
1159
  createFal,
1105
1160
  fal
1106
- });
1161
+ };
1107
1162
  //# sourceMappingURL=index.js.map