@tanstack/ai-fal 0.16.6 → 1.0.1

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/README.md CHANGED
@@ -52,6 +52,7 @@ import { falImage } from '@tanstack/ai-fal'
52
52
 
53
53
  const result = await generateImage({
54
54
  adapter: falImage('fal-ai/flux/dev'),
55
+ threadId: 'thread-1',
55
56
  prompt: 'A futuristic cityscape at sunset',
56
57
  numberOfImages: 1,
57
58
  })
@@ -61,7 +62,7 @@ console.log(result.images)
61
62
 
62
63
  Model ids are string literals with full type safety, so `size` and `modelOptions` are checked against the model you picked.
63
64
 
64
- ### Video generation (experimental)
65
+ ### Video generation
65
66
 
66
67
  Video runs as a job: submit, then poll.
67
68
 
@@ -73,6 +74,7 @@ const adapter = falVideo('fal-ai/kling-video/v2.6/pro/text-to-video')
73
74
 
74
75
  const job = await generateVideo({
75
76
  adapter,
77
+ threadId: 'thread-1',
76
78
  prompt: 'A timelapse of a flower blooming',
77
79
  size: '16:9',
78
80
  duration: '5',
@@ -92,6 +94,7 @@ import { falSpeech } from '@tanstack/ai-fal'
92
94
 
93
95
  const result = await generateSpeech({
94
96
  adapter: falSpeech('fal-ai/kokoro/american-english'),
97
+ threadId: 'thread-1',
95
98
  text: 'Hello from fal!',
96
99
  voice: 'af_heart',
97
100
  speed: 1.0,
@@ -110,6 +113,7 @@ import { falTranscription } from '@tanstack/ai-fal'
110
113
 
111
114
  const result = await generateTranscription({
112
115
  adapter: falTranscription('fal-ai/whisper'),
116
+ threadId: 'thread-1',
113
117
  audio: 'https://example.com/recording.mp3',
114
118
  language: 'en',
115
119
  })
@@ -127,6 +131,7 @@ import { falAudio } from '@tanstack/ai-fal'
127
131
 
128
132
  const music = await generateAudio({
129
133
  adapter: falAudio('fal-ai/minimax-music/v2.6'),
134
+ threadId: 'thread-1',
130
135
  prompt: 'City Pop, 80s retro, groovy synth bass, warm female vocal, 104 BPM',
131
136
  })
132
137
 
@@ -151,7 +156,6 @@ console.log(music.audio.url)
151
156
  ## Limitations
152
157
 
153
158
  - No text/chat, tools, or summarization — use a text adapter for `chat()` and `summarize()`
154
- - Video generation is experimental and its API may change
155
159
 
156
160
  ## Documentation
157
161
 
@@ -8,8 +8,6 @@ import { FalClientConfig } from '../utils/client.js';
8
8
  *
9
9
  * Uses fal.ai's comprehensive type system to provide autocomplete
10
10
  * and type safety for all supported video models.
11
- *
12
- * @experimental Video generation is an experimental feature and may change.
13
11
  */
14
12
  export declare class FalVideoAdapter<TModel extends FalModel> extends BaseVideoAdapter<TModel, FalVideoProviderOptions<TModel>, Record<TModel, FalVideoProviderOptions<TModel>>, Record<TModel, FalModelVideoSize<TModel>>, Record<TModel, FalVideoPromptModalitiesFor<TModel>>, Record<TModel, FalModelVideoDuration<TModel>>> {
15
13
  readonly kind: "video";
@@ -24,13 +22,9 @@ export declare class FalVideoAdapter<TModel extends FalModel> extends BaseVideoA
24
22
  }
25
23
  /**
26
24
  * Create a fal.ai video adapter with an explicit API key.
27
- *
28
- * @experimental Video generation is an experimental feature and may change.
29
25
  */
30
26
  export declare function createFalVideo<TModel extends FalModel>(model: TModel, config?: FalClientConfig): FalVideoAdapter<TModel>;
31
27
  /**
32
28
  * Create a fal.ai video adapter using config.apiKey or the FAL_KEY environment variable.
33
- *
34
- * @experimental Video generation is an experimental feature and may change.
35
29
  */
36
30
  export declare function falVideo<TModel extends FalModel>(model: TModel, config?: FalClientConfig): FalVideoAdapter<TModel>;
@@ -57,8 +57,6 @@ function mapFalStatusToVideoStatus(falStatus) {
57
57
  *
58
58
  * Uses fal.ai's comprehensive type system to provide autocomplete
59
59
  * and type safety for all supported video models.
60
- *
61
- * @experimental Video generation is an experimental feature and may change.
62
60
  */
63
61
  var FalVideoAdapter = class extends BaseVideoAdapter {
64
62
  kind = "video";
@@ -148,16 +146,12 @@ var FalVideoAdapter = class extends BaseVideoAdapter {
148
146
  };
149
147
  /**
150
148
  * Create a fal.ai video adapter with an explicit API key.
151
- *
152
- * @experimental Video generation is an experimental feature and may change.
153
149
  */
154
150
  function createFalVideo(model, config) {
155
151
  return new FalVideoAdapter(model, config);
156
152
  }
157
153
  /**
158
154
  * Create a fal.ai video adapter using config.apiKey or the FAL_KEY environment variable.
159
- *
160
- * @experimental Video generation is an experimental feature and may change.
161
155
  */
162
156
  function falVideo(model, config) {
163
157
  return createFalVideo(model, config);
@@ -1 +1 @@
1
- {"version":3,"file":"video.js","names":[],"sources":["../../../src/adapters/video.ts"],"sourcesContent":["import { fal } from '@fal-ai/client'\nimport { resolveMediaPrompt } from '@tanstack/ai'\nimport { BaseVideoAdapter } from '@tanstack/ai/adapters'\nimport {\n configureFalClient,\n generateId as utilGenerateId,\n} from '../utils/client'\nimport { buildFalUsage, takeBillableUnits } from '../utils/billing'\nimport {\n getFalVideoDurationOptions,\n mapVideoSizeToFalFormat,\n} from '../video/video-provider-options'\nimport {\n contentSourceToFalUrl,\n mapImageInputsToFalVideoFields,\n} from '../image/image-inputs'\nimport type { DurationOptions } from '@tanstack/ai/adapters'\nimport type {\n AudioPart,\n MediaInputMetadata,\n VideoGenerationOptions,\n VideoJobResult,\n VideoPart,\n VideoStatusResult,\n VideoUrlResult,\n} from '@tanstack/ai'\nimport type {\n FalModel,\n FalModelInput,\n FalModelVideoDuration,\n FalModelVideoSize,\n FalVideoPromptModalitiesFor,\n FalVideoProviderOptions,\n} from '../model-meta'\nimport type { FalClientConfig } from '../utils/client'\n\n/**\n * Map video conditioning inputs onto fal field names.\n * Video-to-video endpoints on fal almost universally use `video_url`; the\n * occasional model takes `video_urls` (rare). Mirror the image-input logic\n * positionally with a `reference` role escape hatch via `reference_video_urls`.\n */\nfunction mapVideoInputsToFalFields(\n videoInputs?: ReadonlyArray<VideoPart<MediaInputMetadata>>,\n): Record<string, unknown> {\n if (!videoInputs || videoInputs.length === 0) return {}\n const references: Array<string> = []\n const sources: Array<string> = []\n for (const part of videoInputs) {\n const url = videoPartToUrl(part)\n if (\n part.metadata?.role === 'reference' ||\n part.metadata?.role === 'character'\n ) {\n references.push(url)\n } else {\n sources.push(url)\n }\n }\n const out: Record<string, unknown> = {}\n if (references.length > 0) out.reference_video_urls = references\n if (sources.length === 1) {\n out.video_url = sources[0]\n } else if (sources.length > 1) {\n out.video_urls = sources\n }\n return out\n}\n\nfunction mapAudioInputsToFalFields(\n audioInputs?: ReadonlyArray<AudioPart<MediaInputMetadata>>,\n): Record<string, unknown> {\n if (!audioInputs || audioInputs.length === 0) return {}\n const [part, ...rest] = audioInputs\n if (!part || rest.length > 0) {\n throw new Error(\n `fal: exactly one audio prompt part is supported (received ${audioInputs.length}).`,\n )\n }\n return {\n audio_url: contentSourceToFalUrl(part.source),\n }\n}\n\nfunction videoPartToUrl(part: VideoPart<MediaInputMetadata>): string {\n return contentSourceToFalUrl(part.source)\n}\n\ntype FalQueueStatus = 'IN_QUEUE' | 'IN_PROGRESS' | 'COMPLETED'\n\ninterface FalStatusResponse {\n status: FalQueueStatus\n queue_position?: number\n logs?: Array<{ message: string }>\n}\n\ninterface FalVideoResultData {\n video?: { url: string }\n video_url?: string\n}\n\n/**\n * Maps fal.ai queue status to TanStack AI video status.\n *\n * Note: fal.ai does not return a FAILED queue status. Errors surface\n * as exceptions when fetching results from a COMPLETED job (e.g. 422\n * validation errors). Those are handled in getVideo().\n */\nfunction mapFalStatusToVideoStatus(\n falStatus: FalQueueStatus,\n): VideoStatusResult['status'] {\n switch (falStatus) {\n case 'IN_QUEUE':\n return 'pending'\n case 'IN_PROGRESS':\n return 'processing'\n case 'COMPLETED':\n return 'completed'\n default:\n return 'processing'\n }\n}\n\n/**\n * fal.ai video generation adapter.\n * Supports MiniMax, Luma, Kling, Hunyuan, and other fal.ai video models.\n *\n * Uses fal.ai's comprehensive type system to provide autocomplete\n * and type safety for all supported video models.\n *\n * @experimental Video generation is an experimental feature and may change.\n */\nexport class FalVideoAdapter<TModel extends FalModel> extends BaseVideoAdapter<\n TModel,\n FalVideoProviderOptions<TModel>,\n Record<TModel, FalVideoProviderOptions<TModel>>,\n Record<TModel, FalModelVideoSize<TModel>>,\n Record<TModel, FalVideoPromptModalitiesFor<TModel>>,\n Record<TModel, FalModelVideoDuration<TModel>>\n> {\n override readonly kind = 'video' as const\n readonly name = 'fal' as const\n // Consumes fal storage URLs uploaded via falFiles().\n override readonly supportsFileSources = true\n\n constructor(model: TModel, config?: FalClientConfig) {\n super({}, model)\n configureFalClient(config)\n }\n\n async createVideoJob(\n options: VideoGenerationOptions<\n FalVideoProviderOptions<TModel>,\n FalModelVideoSize<TModel>,\n FalModelVideoDuration<TModel>\n >,\n ): Promise<VideoJobResult> {\n const { size, duration, modelOptions, logger } = options\n\n logger.request(`activity=generateVideo provider=fal model=${this.model}`, {\n provider: 'fal',\n model: this.model,\n })\n\n try {\n const resolved = resolveMediaPrompt(options.prompt)\n const sizeParams = mapVideoSizeToFalFormat(size)\n const inputImageFields = mapImageInputsToFalVideoFields(\n this.model,\n resolved.images,\n )\n const videoFields = mapVideoInputsToFalFields(resolved.videos)\n const audioFields = mapAudioInputsToFalFields(resolved.audios)\n\n const input = {\n ...sizeParams,\n ...inputImageFields,\n ...videoFields,\n ...audioFields,\n // modelOptions applied after derived media fields so explicit user\n // overrides (video_url, reference_video_urls, audio_url, ...) win.\n ...modelOptions,\n // Media-only prompts omit the prompt field rather than sending an\n // empty string (e.g. pure image-to-video endpoints).\n ...(resolved.text ? { prompt: resolved.text } : {}),\n ...(duration !== undefined ? { duration } : {}),\n } as FalModelInput<TModel>\n\n // Submit to queue and get request ID. Request-specific abortSignal only —\n // never via fal.config() (global; would cancel concurrent jobs).\n const { request_id } = await fal.queue.submit(this.model, {\n input,\n ...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),\n })\n\n return {\n jobId: request_id,\n model: this.model,\n }\n } catch (error) {\n logger.errors('fal.createVideoJob fatal', {\n error,\n source: 'fal.createVideoJob',\n })\n throw error\n }\n }\n\n override availableDurations(): DurationOptions<\n FalModelVideoDuration<TModel>\n > {\n return getFalVideoDurationOptions(this.model)\n }\n\n async getVideoStatus(jobId: string): Promise<VideoStatusResult> {\n const statusResponse = (await fal.queue.status(this.model, {\n requestId: jobId,\n logs: true,\n })) as FalStatusResponse\n\n return {\n jobId,\n status: mapFalStatusToVideoStatus(statusResponse.status),\n ...(statusResponse.queue_position != null\n ? {\n progress: Math.max(0, 100 - statusResponse.queue_position * 10),\n }\n : {}),\n }\n }\n\n override async getVideo(jobId: string): Promise<VideoUrlResult> {\n let result\n try {\n result = await fal.queue.result(this.model, {\n requestId: jobId,\n })\n } catch (error: unknown) {\n // fal.ai may report COMPLETED status but throw on result fetch\n // (e.g. 422 validation errors). Extract the detailed error info.\n const err = error as { body?: { detail?: unknown }; message?: string }\n const detail = err.body?.detail\n if (Array.isArray(detail)) {\n const messages = detail.map(\n (d: { msg?: string; loc?: Array<string> }) =>\n d.loc ? `${d.loc.join('.')}: ${d.msg}` : d.msg,\n )\n throw new Error(`Video generation failed: ${messages.join('; ')}`)\n }\n throw new Error(\n `Failed to retrieve video result: ${err.message || String(error)}`,\n )\n }\n\n const data = result.data as FalVideoResultData\n\n // Different models return video URL in different formats\n const url = data.video?.url || data.video_url\n if (!url) {\n throw new Error('Video URL not found in response')\n }\n\n const usage = buildFalUsage(takeBillableUnits(result.requestId))\n\n return {\n jobId,\n url,\n ...(usage ? { usage } : {}),\n }\n }\n\n protected override generateId(): string {\n return utilGenerateId(this.name)\n }\n}\n\n/**\n * Create a fal.ai video adapter with an explicit API key.\n *\n * @experimental Video generation is an experimental feature and may change.\n */\nexport function createFalVideo<TModel extends FalModel>(\n model: TModel,\n config?: FalClientConfig,\n): FalVideoAdapter<TModel> {\n return new FalVideoAdapter(model, config)\n}\n\n/**\n * Create a fal.ai video adapter using config.apiKey or the FAL_KEY environment variable.\n *\n * @experimental Video generation is an experimental feature and may change.\n */\nexport function falVideo<TModel extends FalModel>(\n model: TModel,\n config?: FalClientConfig,\n): FalVideoAdapter<TModel> {\n return createFalVideo(model, config)\n}\n"],"mappings":";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,MAAM,SAAS,IAAI,MAAM;GACzB,IAAI,MAAM,QAAQ,MAAM,GAAG;IACzB,MAAM,WAAW,OAAO,KACrB,MACC,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAC/C;IACA,MAAM,IAAI,MAAM,4BAA4B,SAAS,KAAK,IAAI,GAAG;GACnE;GACA,MAAM,IAAI,MACR,oCAAoC,IAAI,WAAW,OAAO,KAAK,GACjE;EACF;EAEA,MAAM,OAAO,OAAO;EAGpB,MAAM,MAAM,KAAK,OAAO,OAAO,KAAK;EACpC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,iCAAiC;EAGnD,MAAM,QAAQ,cAAc,kBAAkB,OAAO,SAAS,CAAC;EAE/D,OAAO;GACL;GACA;GACA,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EAC3B;CACF;CAEA,aAAwC;EACtC,OAAO,WAAe,KAAK,IAAI;CACjC;AACF;;;;;;AAOA,SAAgB,eACd,OACA,QACyB;CACzB,OAAO,IAAI,gBAAgB,OAAO,MAAM;AAC1C;;;;;;AAOA,SAAgB,SACd,OACA,QACyB;CACzB,OAAO,eAAe,OAAO,MAAM;AACrC"}
1
+ {"version":3,"file":"video.js","names":[],"sources":["../../../src/adapters/video.ts"],"sourcesContent":["import { fal } from '@fal-ai/client'\nimport { resolveMediaPrompt } from '@tanstack/ai'\nimport { BaseVideoAdapter } from '@tanstack/ai/adapters'\nimport {\n configureFalClient,\n generateId as utilGenerateId,\n} from '../utils/client'\nimport { buildFalUsage, takeBillableUnits } from '../utils/billing'\nimport {\n getFalVideoDurationOptions,\n mapVideoSizeToFalFormat,\n} from '../video/video-provider-options'\nimport {\n contentSourceToFalUrl,\n mapImageInputsToFalVideoFields,\n} from '../image/image-inputs'\nimport type { DurationOptions } from '@tanstack/ai/adapters'\nimport type {\n AudioPart,\n MediaInputMetadata,\n VideoGenerationOptions,\n VideoJobResult,\n VideoPart,\n VideoStatusResult,\n VideoUrlResult,\n} from '@tanstack/ai'\nimport type {\n FalModel,\n FalModelInput,\n FalModelVideoDuration,\n FalModelVideoSize,\n FalVideoPromptModalitiesFor,\n FalVideoProviderOptions,\n} from '../model-meta'\nimport type { FalClientConfig } from '../utils/client'\n\n/**\n * Map video conditioning inputs onto fal field names.\n * Video-to-video endpoints on fal almost universally use `video_url`; the\n * occasional model takes `video_urls` (rare). Mirror the image-input logic\n * positionally with a `reference` role escape hatch via `reference_video_urls`.\n */\nfunction mapVideoInputsToFalFields(\n videoInputs?: ReadonlyArray<VideoPart<MediaInputMetadata>>,\n): Record<string, unknown> {\n if (!videoInputs || videoInputs.length === 0) return {}\n const references: Array<string> = []\n const sources: Array<string> = []\n for (const part of videoInputs) {\n const url = videoPartToUrl(part)\n if (\n part.metadata?.role === 'reference' ||\n part.metadata?.role === 'character'\n ) {\n references.push(url)\n } else {\n sources.push(url)\n }\n }\n const out: Record<string, unknown> = {}\n if (references.length > 0) out.reference_video_urls = references\n if (sources.length === 1) {\n out.video_url = sources[0]\n } else if (sources.length > 1) {\n out.video_urls = sources\n }\n return out\n}\n\nfunction mapAudioInputsToFalFields(\n audioInputs?: ReadonlyArray<AudioPart<MediaInputMetadata>>,\n): Record<string, unknown> {\n if (!audioInputs || audioInputs.length === 0) return {}\n const [part, ...rest] = audioInputs\n if (!part || rest.length > 0) {\n throw new Error(\n `fal: exactly one audio prompt part is supported (received ${audioInputs.length}).`,\n )\n }\n return {\n audio_url: contentSourceToFalUrl(part.source),\n }\n}\n\nfunction videoPartToUrl(part: VideoPart<MediaInputMetadata>): string {\n return contentSourceToFalUrl(part.source)\n}\n\ntype FalQueueStatus = 'IN_QUEUE' | 'IN_PROGRESS' | 'COMPLETED'\n\ninterface FalStatusResponse {\n status: FalQueueStatus\n queue_position?: number\n logs?: Array<{ message: string }>\n}\n\ninterface FalVideoResultData {\n video?: { url: string }\n video_url?: string\n}\n\n/**\n * Maps fal.ai queue status to TanStack AI video status.\n *\n * Note: fal.ai does not return a FAILED queue status. Errors surface\n * as exceptions when fetching results from a COMPLETED job (e.g. 422\n * validation errors). Those are handled in getVideo().\n */\nfunction mapFalStatusToVideoStatus(\n falStatus: FalQueueStatus,\n): VideoStatusResult['status'] {\n switch (falStatus) {\n case 'IN_QUEUE':\n return 'pending'\n case 'IN_PROGRESS':\n return 'processing'\n case 'COMPLETED':\n return 'completed'\n default:\n return 'processing'\n }\n}\n\n/**\n * fal.ai video generation adapter.\n * Supports MiniMax, Luma, Kling, Hunyuan, and other fal.ai video models.\n *\n * Uses fal.ai's comprehensive type system to provide autocomplete\n * and type safety for all supported video models.\n */\nexport class FalVideoAdapter<TModel extends FalModel> extends BaseVideoAdapter<\n TModel,\n FalVideoProviderOptions<TModel>,\n Record<TModel, FalVideoProviderOptions<TModel>>,\n Record<TModel, FalModelVideoSize<TModel>>,\n Record<TModel, FalVideoPromptModalitiesFor<TModel>>,\n Record<TModel, FalModelVideoDuration<TModel>>\n> {\n override readonly kind = 'video' as const\n readonly name = 'fal' as const\n // Consumes fal storage URLs uploaded via falFiles().\n override readonly supportsFileSources = true\n\n constructor(model: TModel, config?: FalClientConfig) {\n super({}, model)\n configureFalClient(config)\n }\n\n async createVideoJob(\n options: VideoGenerationOptions<\n FalVideoProviderOptions<TModel>,\n FalModelVideoSize<TModel>,\n FalModelVideoDuration<TModel>\n >,\n ): Promise<VideoJobResult> {\n const { size, duration, modelOptions, logger } = options\n\n logger.request(`activity=generateVideo provider=fal model=${this.model}`, {\n provider: 'fal',\n model: this.model,\n })\n\n try {\n const resolved = resolveMediaPrompt(options.prompt)\n const sizeParams = mapVideoSizeToFalFormat(size)\n const inputImageFields = mapImageInputsToFalVideoFields(\n this.model,\n resolved.images,\n )\n const videoFields = mapVideoInputsToFalFields(resolved.videos)\n const audioFields = mapAudioInputsToFalFields(resolved.audios)\n\n const input = {\n ...sizeParams,\n ...inputImageFields,\n ...videoFields,\n ...audioFields,\n // modelOptions applied after derived media fields so explicit user\n // overrides (video_url, reference_video_urls, audio_url, ...) win.\n ...modelOptions,\n // Media-only prompts omit the prompt field rather than sending an\n // empty string (e.g. pure image-to-video endpoints).\n ...(resolved.text ? { prompt: resolved.text } : {}),\n ...(duration !== undefined ? { duration } : {}),\n } as FalModelInput<TModel>\n\n // Submit to queue and get request ID. Request-specific abortSignal only —\n // never via fal.config() (global; would cancel concurrent jobs).\n const { request_id } = await fal.queue.submit(this.model, {\n input,\n ...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),\n })\n\n return {\n jobId: request_id,\n model: this.model,\n }\n } catch (error) {\n logger.errors('fal.createVideoJob fatal', {\n error,\n source: 'fal.createVideoJob',\n })\n throw error\n }\n }\n\n override availableDurations(): DurationOptions<\n FalModelVideoDuration<TModel>\n > {\n return getFalVideoDurationOptions(this.model)\n }\n\n async getVideoStatus(jobId: string): Promise<VideoStatusResult> {\n const statusResponse = (await fal.queue.status(this.model, {\n requestId: jobId,\n logs: true,\n })) as FalStatusResponse\n\n return {\n jobId,\n status: mapFalStatusToVideoStatus(statusResponse.status),\n ...(statusResponse.queue_position != null\n ? {\n progress: Math.max(0, 100 - statusResponse.queue_position * 10),\n }\n : {}),\n }\n }\n\n override async getVideo(jobId: string): Promise<VideoUrlResult> {\n let result\n try {\n result = await fal.queue.result(this.model, {\n requestId: jobId,\n })\n } catch (error: unknown) {\n // fal.ai may report COMPLETED status but throw on result fetch\n // (e.g. 422 validation errors). Extract the detailed error info.\n const err = error as { body?: { detail?: unknown }; message?: string }\n const detail = err.body?.detail\n if (Array.isArray(detail)) {\n const messages = detail.map(\n (d: { msg?: string; loc?: Array<string> }) =>\n d.loc ? `${d.loc.join('.')}: ${d.msg}` : d.msg,\n )\n throw new Error(`Video generation failed: ${messages.join('; ')}`)\n }\n throw new Error(\n `Failed to retrieve video result: ${err.message || String(error)}`,\n )\n }\n\n const data = result.data as FalVideoResultData\n\n // Different models return video URL in different formats\n const url = data.video?.url || data.video_url\n if (!url) {\n throw new Error('Video URL not found in response')\n }\n\n const usage = buildFalUsage(takeBillableUnits(result.requestId))\n\n return {\n jobId,\n url,\n ...(usage ? { usage } : {}),\n }\n }\n\n protected override generateId(): string {\n return utilGenerateId(this.name)\n }\n}\n\n/**\n * Create a fal.ai video adapter with an explicit API key.\n */\nexport function createFalVideo<TModel extends FalModel>(\n model: TModel,\n config?: FalClientConfig,\n): FalVideoAdapter<TModel> {\n return new FalVideoAdapter(model, config)\n}\n\n/**\n * Create a fal.ai video adapter using config.apiKey or the FAL_KEY environment variable.\n */\nexport function falVideo<TModel extends FalModel>(\n model: TModel,\n config?: FalClientConfig,\n): FalVideoAdapter<TModel> {\n return createFalVideo(model, config)\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,SAAS,0BACP,aACyB;CACzB,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG,OAAO,CAAC;CACtD,MAAM,aAA4B,CAAC;CACnC,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,QAAQ,aAAa;EAC9B,MAAM,MAAM,eAAe,IAAI;EAC/B,IACE,KAAK,UAAU,SAAS,eACxB,KAAK,UAAU,SAAS,aAExB,WAAW,KAAK,GAAG;OAEnB,QAAQ,KAAK,GAAG;CAEpB;CACA,MAAM,MAA+B,CAAC;CACtC,IAAI,WAAW,SAAS,GAAG,IAAI,uBAAuB;CACtD,IAAI,QAAQ,WAAW,GACrB,IAAI,YAAY,QAAQ;MACnB,IAAI,QAAQ,SAAS,GAC1B,IAAI,aAAa;CAEnB,OAAO;AACT;AAEA,SAAS,0BACP,aACyB;CACzB,IAAI,CAAC,eAAe,YAAY,WAAW,GAAG,OAAO,CAAC;CACtD,MAAM,CAAC,MAAM,GAAG,QAAQ;CACxB,IAAI,CAAC,QAAQ,KAAK,SAAS,GACzB,MAAM,IAAI,MACR,6DAA6D,YAAY,OAAO,GAClF;CAEF,OAAO,EACL,WAAW,sBAAsB,KAAK,MAAM,EAC9C;AACF;AAEA,SAAS,eAAe,MAA6C;CACnE,OAAO,sBAAsB,KAAK,MAA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unitsBilled,
75
75
  unit: "units"
76
- },
77
- unitsBilled
76
+ }
78
77
  };
79
78
  }
80
79
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"billing.js","names":[],"sources":["../../../src/utils/billing.ts"],"sourcesContent":["import type { TokenUsage } from '@tanstack/ai'\n\n/**\n * Response header fal sets on a queue *result* fetch carrying the real billed\n * quantity for the generation, denominated in the endpoint's priced unit.\n */\nconst FAL_BILLABLE_UNITS_HEADER = 'x-fal-billable-units'\n\n/**\n * Response header fal sets carrying the request id. The fal client surfaces this\n * same value as `Result.requestId`, so keying captured billable units by it\n * guarantees the adapter's lookup matches the fetch the units came from — no URL\n * parsing or global correlation registry of our own design needed.\n */\nconst FAL_REQUEST_ID_HEADER = 'x-fal-request-id'\n\n/**\n * Upper bound on retained, not-yet-consumed billable-unit entries. Each\n * successful generation reads-and-deletes its entry (see {@link takeBillableUnits}),\n * so this only guards against an unbounded leak when a result fetch records units\n * but the adapter never resolves (e.g. it throws before reading). When the cap is\n * exceeded the oldest entry is evicted (Map preserves insertion order).\n */\nconst MAX_PENDING_ENTRIES = 256\n\nconst billableUnitsByRequestId = new Map<string, number>()\n\n/**\n * Parse the `x-fal-billable-units` header value into a finite number. Returns\n * `undefined` for a missing or non-numeric value so callers can skip attaching\n * usage rather than surfacing `NaN`.\n */\nexport function parseBillableUnits(value: string | null): number | undefined {\n if (value == null || value === '') return undefined\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\n/**\n * Record the billable units carried by a fal result response, keyed by the\n * request id from the same response. Reading headers does not consume the body,\n * so the response can be returned to the fal client untouched.\n */\nexport function recordBillableUnitsFromResponse(response: Response): void {\n const units = parseBillableUnits(\n response.headers.get(FAL_BILLABLE_UNITS_HEADER),\n )\n if (units == null) return\n const requestId = response.headers.get(FAL_REQUEST_ID_HEADER)\n if (!requestId) return\n if (\n billableUnitsByRequestId.size >= MAX_PENDING_ENTRIES &&\n !billableUnitsByRequestId.has(requestId)\n ) {\n const oldest = billableUnitsByRequestId.keys().next().value\n if (oldest !== undefined) billableUnitsByRequestId.delete(oldest)\n }\n billableUnitsByRequestId.set(requestId, units)\n}\n\n/**\n * Read and remove the billable units recorded for a request id. Removing on read\n * keeps the registry from growing across the lifetime of the process.\n */\nexport function takeBillableUnits(\n requestId: string | undefined,\n): number | undefined {\n if (!requestId) return undefined\n const units = billableUnitsByRequestId.get(requestId)\n if (units !== undefined) billableUnitsByRequestId.delete(requestId)\n return units\n}\n\n/**\n * Build a {@link TokenUsage} carrying fal's billed quantity. Media generation has\n * no tokens, so the token fields are zero and the real billing signal rides on\n * `billed`, denominated in `'units'` — fal's priced unit is endpoint-defined\n * (its pricing page maps each endpoint to a unit price), so the count is opaque\n * by design. Returns `undefined` when no units were captured so callers can\n * omit `usage` entirely.\n */\nexport function buildFalUsage(\n unitsBilled: number | undefined,\n): TokenUsage | undefined {\n if (unitsBilled == null) return undefined\n return {\n promptTokens: 0,\n completionTokens: 0,\n totalTokens: 0,\n billed: { quantity: unitsBilled, unit: 'units' },\n unitsBilled,\n }\n}\n\n/**\n * Wrap a fetch so every fal request's response is inspected for the\n * `x-fal-billable-units` header before being returned untouched. Installed as\n * fal's `config.fetch`, which (unlike a global `responseHandler`) is honoured for\n * every request — the fal client forces `resultResponseHandler` per queue\n * operation, clobbering any configured response handler.\n *\n * `baseFetch` is the underlying implementation to delegate to (defaults to the\n * global `fetch`). Injecting it keeps usage capture working when a caller\n * supplies a custom fetch — a proxy, instrumentation, or a test mock — without\n * mutating any global.\n */\nexport function createBillingFetch(\n baseFetch: typeof fetch = globalThis.fetch,\n): typeof fetch {\n return async (input, init) => {\n const response = await baseFetch(input, init)\n try {\n recordBillableUnitsFromResponse(response)\n } catch {\n // Capturing usage must never break the underlying request.\n }\n return response\n }\n}\n"],"mappings":";;;;;AAMA,IAAM,4BAA4B;;;;;;;AAQlC,IAAM,wBAAwB;;;;;;;;AAS9B,IAAM,sBAAsB;AAE5B,IAAM,2CAA2B,IAAI,IAAoB;;;;;;AAOzD,SAAgB,mBAAmB,OAA0C;CAC3E,IAAI,SAAS,QAAQ,UAAU,IAAI,OAAO,KAAA;CAC1C,MAAM,SAAS,OAAO,KAAK;CAC3B,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS,KAAA;AAC5C;;;;;;AAOA,SAAgB,gCAAgC,UAA0B;CACxE,MAAM,QAAQ,mBACZ,SAAS,QAAQ,IAAI,yBAAyB,CAChD;CACA,IAAI,SAAS,MAAM;CACnB,MAAM,YAAY,SAAS,QAAQ,IAAI,qBAAqB;CAC5D,IAAI,CAAC,WAAW;CAChB,IACE,yBAAyB,QAAQ,uBACjC,CAAC,yBAAyB,IAAI,SAAS,GACvC;EACA,MAAM,SAAS,yBAAyB,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;EACtD,IAAI,WAAW,KAAA,GAAW,yBAAyB,OAAO,MAAM;CAClE;CACA,yBAAyB,IAAI,WAAW,KAAK;AAC/C;;;;;AAMA,SAAgB,kBACd,WACoB;CACpB,IAAI,CAAC,WAAW,OAAO,KAAA;CACvB,MAAM,QAAQ,yBAAyB,IAAI,SAAS;CACpD,IAAI,UAAU,KAAA,GAAW,yBAAyB,OAAO,SAAS;CAClE,OAAO;AACT;;;;;;;;;AAUA,SAAgB,cACd,aACwB;CACxB,IAAI,eAAe,MAAM,OAAO,KAAA;CAChC,OAAO;EACL,cAAc;EACd,kBAAkB;EAClB,aAAa;EACb,QAAQ;GAAE,UAAU;GAAa,MAAM;EAAQ;EAC/C;CACF;AACF;;;;;;;;;;;;;AAcA,SAAgB,mBACd,YAA0B,WAAW,OACvB;CACd,OAAO,OAAO,OAAO,SAAS;EAC5B,MAAM,WAAW,MAAM,UAAU,OAAO,IAAI;EAC5C,IAAI;GACF,gCAAgC,QAAQ;EAC1C,QAAQ,CAER;EACA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"billing.js","names":[],"sources":["../../../src/utils/billing.ts"],"sourcesContent":["import type { TokenUsage } from '@tanstack/ai'\n\n/**\n * Response header fal sets on a queue *result* fetch carrying the real billed\n * quantity for the generation, denominated in the endpoint's priced unit.\n */\nconst FAL_BILLABLE_UNITS_HEADER = 'x-fal-billable-units'\n\n/**\n * Response header fal sets carrying the request id. The fal client surfaces this\n * same value as `Result.requestId`, so keying captured billable units by it\n * guarantees the adapter's lookup matches the fetch the units came from — no URL\n * parsing or global correlation registry of our own design needed.\n */\nconst FAL_REQUEST_ID_HEADER = 'x-fal-request-id'\n\n/**\n * Upper bound on retained, not-yet-consumed billable-unit entries. Each\n * successful generation reads-and-deletes its entry (see {@link takeBillableUnits}),\n * so this only guards against an unbounded leak when a result fetch records units\n * but the adapter never resolves (e.g. it throws before reading). When the cap is\n * exceeded the oldest entry is evicted (Map preserves insertion order).\n */\nconst MAX_PENDING_ENTRIES = 256\n\nconst billableUnitsByRequestId = new Map<string, number>()\n\n/**\n * Parse the `x-fal-billable-units` header value into a finite number. Returns\n * `undefined` for a missing or non-numeric value so callers can skip attaching\n * usage rather than surfacing `NaN`.\n */\nexport function parseBillableUnits(value: string | null): number | undefined {\n if (value == null || value === '') return undefined\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\n/**\n * Record the billable units carried by a fal result response, keyed by the\n * request id from the same response. Reading headers does not consume the body,\n * so the response can be returned to the fal client untouched.\n */\nexport function recordBillableUnitsFromResponse(response: Response): void {\n const units = parseBillableUnits(\n response.headers.get(FAL_BILLABLE_UNITS_HEADER),\n )\n if (units == null) return\n const requestId = response.headers.get(FAL_REQUEST_ID_HEADER)\n if (!requestId) return\n if (\n billableUnitsByRequestId.size >= MAX_PENDING_ENTRIES &&\n !billableUnitsByRequestId.has(requestId)\n ) {\n const oldest = billableUnitsByRequestId.keys().next().value\n if (oldest !== undefined) billableUnitsByRequestId.delete(oldest)\n }\n billableUnitsByRequestId.set(requestId, units)\n}\n\n/**\n * Read and remove the billable units recorded for a request id. Removing on read\n * keeps the registry from growing across the lifetime of the process.\n */\nexport function takeBillableUnits(\n requestId: string | undefined,\n): number | undefined {\n if (!requestId) return undefined\n const units = billableUnitsByRequestId.get(requestId)\n if (units !== undefined) billableUnitsByRequestId.delete(requestId)\n return units\n}\n\n/**\n * Build a {@link TokenUsage} carrying fal's billed quantity. Media generation has\n * no tokens, so the token fields are zero and the real billing signal rides on\n * `billed`, denominated in `'units'` — fal's priced unit is endpoint-defined\n * (its pricing page maps each endpoint to a unit price), so the count is opaque\n * by design. Returns `undefined` when no units were captured so callers can\n * omit `usage` entirely.\n */\nexport function buildFalUsage(\n unitsBilled: number | undefined,\n): TokenUsage | undefined {\n if (unitsBilled == null) return undefined\n return {\n promptTokens: 0,\n completionTokens: 0,\n totalTokens: 0,\n billed: { quantity: unitsBilled, unit: 'units' },\n }\n}\n\n/**\n * Wrap a fetch so every fal request's response is inspected for the\n * `x-fal-billable-units` header before being returned untouched. Installed as\n * fal's `config.fetch`, which (unlike a global `responseHandler`) is honoured for\n * every request — the fal client forces `resultResponseHandler` per queue\n * operation, clobbering any configured response handler.\n *\n * `baseFetch` is the underlying implementation to delegate to (defaults to the\n * global `fetch`). Injecting it keeps usage capture working when a caller\n * supplies a custom fetch — a proxy, instrumentation, or a test mock — without\n * mutating any global.\n */\nexport function createBillingFetch(\n baseFetch: typeof fetch = globalThis.fetch,\n): typeof fetch {\n return async (input, init) => {\n const response = await baseFetch(input, init)\n try {\n recordBillableUnitsFromResponse(response)\n } catch {\n // Capturing usage must never break the underlying request.\n }\n return response\n }\n}\n"],"mappings":";;;;;AAMA,IAAM,4BAA4B;;;;;;;AAQlC,IAAM,wBAAwB;;;;;;;;AAS9B,IAAM,sBAAsB;AAE5B,IAAM,2CAA2B,IAAI,IAAoB;;;;;;AAOzD,SAAgB,mBAAmB,OAA0C;CAC3E,IAAI,SAAS,QAAQ,UAAU,IAAI,OAAO,KAAA;CAC1C,MAAM,SAAS,OAAO,KAAK;CAC3B,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS,KAAA;AAC5C;;;;;;AAOA,SAAgB,gCAAgC,UAA0B;CACxE,MAAM,QAAQ,mBACZ,SAAS,QAAQ,IAAI,yBAAyB,CAChD;CACA,IAAI,SAAS,MAAM;CACnB,MAAM,YAAY,SAAS,QAAQ,IAAI,qBAAqB;CAC5D,IAAI,CAAC,WAAW;CAChB,IACE,yBAAyB,QAAQ,uBACjC,CAAC,yBAAyB,IAAI,SAAS,GACvC;EACA,MAAM,SAAS,yBAAyB,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;EACtD,IAAI,WAAW,KAAA,GAAW,yBAAyB,OAAO,MAAM;CAClE;CACA,yBAAyB,IAAI,WAAW,KAAK;AAC/C;;;;;AAMA,SAAgB,kBACd,WACoB;CACpB,IAAI,CAAC,WAAW,OAAO,KAAA;CACvB,MAAM,QAAQ,yBAAyB,IAAI,SAAS;CACpD,IAAI,UAAU,KAAA,GAAW,yBAAyB,OAAO,SAAS;CAClE,OAAO;AACT;;;;;;;;;AAUA,SAAgB,cACd,aACwB;CACxB,IAAI,eAAe,MAAM,OAAO,KAAA;CAChC,OAAO;EACL,cAAc;EACd,kBAAkB;EAClB,aAAa;EACb,QAAQ;GAAE,UAAU;GAAa,MAAM;EAAQ;CACjD;AACF;;;;;;;;;;;;;AAcA,SAAgB,mBACd,YAA0B,WAAW,OACvB;CACd,OAAO,OAAO,OAAO,SAAS;EAC5B,MAAM,WAAW,MAAM,UAAU,OAAO,IAAI;EAC5C,IAAI;GACF,gCAAgC,QAAQ;EAC1C,QAAQ,CAER;EACA,OAAO;CACT;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-fal",
3
- "version": "0.16.6",
3
+ "version": "1.0.1",
4
4
  "description": "fal.ai adapter for TanStack AI image, video, live, audio, speech, and transcription generation.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -54,15 +54,15 @@
54
54
  ],
55
55
  "dependencies": {
56
56
  "@fal-ai/client": "^1.10.1",
57
- "@tanstack/ai-utils": "^0.5.0"
57
+ "@tanstack/ai-utils": "^1.0.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@vitest/coverage-v8": "4.1.10",
61
61
  "vite": "^8.2.1",
62
- "@tanstack/ai": "0.71.0"
62
+ "@tanstack/ai": "1.0.1"
63
63
  },
64
64
  "peerDependencies": {
65
- "@tanstack/ai": "^0.71.0"
65
+ "@tanstack/ai": "^1.0.1"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "vite build",
@@ -127,8 +127,6 @@ function mapFalStatusToVideoStatus(
127
127
  *
128
128
  * Uses fal.ai's comprehensive type system to provide autocomplete
129
129
  * and type safety for all supported video models.
130
- *
131
- * @experimental Video generation is an experimental feature and may change.
132
130
  */
133
131
  export class FalVideoAdapter<TModel extends FalModel> extends BaseVideoAdapter<
134
132
  TModel,
@@ -276,8 +274,6 @@ export class FalVideoAdapter<TModel extends FalModel> extends BaseVideoAdapter<
276
274
 
277
275
  /**
278
276
  * Create a fal.ai video adapter with an explicit API key.
279
- *
280
- * @experimental Video generation is an experimental feature and may change.
281
277
  */
282
278
  export function createFalVideo<TModel extends FalModel>(
283
279
  model: TModel,
@@ -288,8 +284,6 @@ export function createFalVideo<TModel extends FalModel>(
288
284
 
289
285
  /**
290
286
  * Create a fal.ai video adapter using config.apiKey or the FAL_KEY environment variable.
291
- *
292
- * @experimental Video generation is an experimental feature and may change.
293
287
  */
294
288
  export function falVideo<TModel extends FalModel>(
295
289
  model: TModel,
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  export { FalImageAdapter, falImage } from './adapters/image'
6
6
 
7
7
  // ============================================================================
8
- // Video Adapter (Experimental)
8
+ // Video Adapter
9
9
  // ============================================================================
10
10
 
11
11
  export { FalVideoAdapter, falVideo } from './adapters/video'
@@ -88,7 +88,6 @@ export function buildFalUsage(
88
88
  completionTokens: 0,
89
89
  totalTokens: 0,
90
90
  billed: { quantity: unitsBilled, unit: 'units' },
91
- unitsBilled,
92
91
  }
93
92
  }
94
93