@tanstack/ai-fal 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/adapters/audio.d.ts +1 -0
- package/dist/esm/adapters/audio.js +6 -7
- package/dist/esm/adapters/audio.js.map +1 -1
- package/dist/esm/adapters/files.d.ts +1 -0
- package/dist/esm/adapters/files.js +5 -6
- package/dist/esm/adapters/files.js.map +1 -1
- package/dist/esm/adapters/image.d.ts +1 -0
- package/dist/esm/adapters/image.js +6 -7
- package/dist/esm/adapters/image.js.map +1 -1
- package/dist/esm/adapters/live.js +1 -2
- package/dist/esm/adapters/model3d.d.ts +98 -0
- package/dist/esm/adapters/model3d.js +170 -0
- package/dist/esm/adapters/model3d.js.map +1 -0
- package/dist/esm/adapters/motion.d.ts +58 -0
- package/dist/esm/adapters/motion.js +150 -0
- package/dist/esm/adapters/motion.js.map +1 -0
- package/dist/esm/adapters/speech.d.ts +1 -0
- package/dist/esm/adapters/speech.js +6 -7
- package/dist/esm/adapters/speech.js.map +1 -1
- package/dist/esm/adapters/transcription.d.ts +1 -0
- package/dist/esm/adapters/transcription.js +6 -7
- package/dist/esm/adapters/transcription.js.map +1 -1
- package/dist/esm/adapters/video.d.ts +2 -1
- package/dist/esm/adapters/video.js +13 -18
- package/dist/esm/adapters/video.js.map +1 -1
- package/dist/esm/byok.js +1 -2
- package/dist/esm/client/index.d.ts +65 -0
- package/dist/esm/client/index.js +306 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/image/generated/image-field-overrides.d.ts +459 -294
- package/dist/esm/image/generated/image-field-overrides.js +312 -190
- package/dist/esm/image/generated/image-field-overrides.js.map +1 -1
- package/dist/esm/image/image-inputs.js +7 -4
- package/dist/esm/image/image-inputs.js.map +1 -1
- package/dist/esm/image/image-provider-options.js +1 -2
- package/dist/esm/image/legacy-image-field-overrides.d.ts +13 -0
- package/dist/esm/image/legacy-image-field-overrides.js +91 -0
- package/dist/esm/image/legacy-image-field-overrides.js.map +1 -0
- package/dist/esm/index.d.ts +6 -2
- package/dist/esm/index.js +5 -2
- package/dist/esm/model-meta.d.ts +49 -0
- package/dist/esm/model3d/generated/mesh-field-overrides.d.ts +20 -0
- package/dist/esm/model3d/generated/mesh-field-overrides.js +20 -0
- package/dist/esm/model3d/generated/mesh-field-overrides.js.map +1 -0
- package/dist/esm/model3d/model3d-inputs.d.ts +39 -0
- package/dist/esm/model3d/model3d-inputs.js +206 -0
- package/dist/esm/model3d/model3d-inputs.js.map +1 -0
- package/dist/esm/model3d/model3d-output.d.ts +25 -0
- package/dist/esm/model3d/model3d-output.js +181 -0
- package/dist/esm/model3d/model3d-output.js.map +1 -0
- package/dist/esm/utils/billing.js +1 -2
- package/dist/esm/utils/client.d.ts +16 -1
- package/dist/esm/utils/client.js +31 -9
- package/dist/esm/utils/client.js.map +1 -1
- package/dist/esm/utils/configure.d.ts +12 -0
- package/dist/esm/utils/configure.js +19 -0
- package/dist/esm/utils/configure.js.map +1 -0
- package/dist/esm/utils/index.d.ts +2 -1
- package/dist/esm/video/video-provider-options.js +20 -31
- package/dist/esm/video/video-provider-options.js.map +1 -1
- package/package.json +8 -7
- package/src/adapters/audio.ts +7 -6
- package/src/adapters/files.ts +5 -4
- package/src/adapters/image.ts +8 -7
- package/src/adapters/model3d.ts +219 -0
- package/src/adapters/motion.ts +237 -0
- package/src/adapters/speech.ts +7 -6
- package/src/adapters/transcription.ts +8 -7
- package/src/adapters/video.ts +16 -18
- package/src/client/index.ts +456 -0
- package/src/image/generated/image-field-overrides.ts +159 -110
- package/src/image/image-inputs.ts +9 -4
- package/src/image/legacy-image-field-overrides.ts +94 -0
- package/src/index.ts +20 -1
- package/src/model-meta.ts +106 -0
- package/src/model3d/generated/mesh-field-overrides.ts +46 -0
- package/src/model3d/model3d-inputs.ts +232 -0
- package/src/model3d/model3d-output.ts +216 -0
- package/src/utils/client.ts +37 -4
- package/src/utils/configure.ts +17 -0
- package/src/utils/index.ts +2 -1
- package/src/video/video-provider-options.ts +9 -27
|
@@ -10,7 +10,22 @@ export interface FalClientConfig {
|
|
|
10
10
|
fetch?: typeof fetch;
|
|
11
11
|
}
|
|
12
12
|
export declare function getFalApiKeyFromEnv(): string;
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function toFalClientOptions(config?: FalClientConfig): {
|
|
14
|
+
proxyUrl?: string | undefined;
|
|
15
|
+
credentials: string;
|
|
16
|
+
fetch: typeof fetch;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Create the fal client for one adapter. Each adapter has its own client, so
|
|
20
|
+
* two adapters with different API keys do not change each other.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createAdapterFalClient(config?: FalClientConfig): import('../client/index.js').FalClient;
|
|
23
|
+
/**
|
|
24
|
+
* fal can report a request COMPLETED and then answer the result fetch with a
|
|
25
|
+
* 422. Returns its `detail` text, or joins a detail list as `field: message`
|
|
26
|
+
* pairs. Returns undefined when the error has no detail.
|
|
27
|
+
*/
|
|
28
|
+
export declare function falValidationMessage(error: unknown): string | undefined;
|
|
14
29
|
export declare function generateId(prefix: string): string;
|
|
15
30
|
/**
|
|
16
31
|
* Extract a safe file extension from a URL. Strips query strings, URL
|
package/dist/esm/utils/client.js
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
|
+
import { createFalClient } from "../client/index.js";
|
|
1
2
|
import { createBillingFetch } from "./billing.js";
|
|
2
|
-
import { fal } from "@fal-ai/client";
|
|
3
3
|
import { generateId, getApiKeyFromEnv } from "@tanstack/ai-utils";
|
|
4
|
-
|
|
4
|
+
// src/utils/client.ts
|
|
5
5
|
function getFalApiKeyFromEnv() {
|
|
6
6
|
return getApiKeyFromEnv("FAL_KEY");
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
credentials: apiKey,
|
|
8
|
+
function toFalClientOptions(config) {
|
|
9
|
+
return {
|
|
10
|
+
credentials: config?.apiKey ?? getFalApiKeyFromEnv(),
|
|
12
11
|
fetch: createBillingFetch(config?.fetch),
|
|
13
12
|
...config?.proxyUrl ? { proxyUrl: config.proxyUrl } : {}
|
|
14
|
-
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create the fal client for one adapter. Each adapter has its own client, so
|
|
17
|
+
* two adapters with different API keys do not change each other.
|
|
18
|
+
*/
|
|
19
|
+
function createAdapterFalClient(config) {
|
|
20
|
+
return createFalClient(toFalClientOptions(config));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* fal can report a request COMPLETED and then answer the result fetch with a
|
|
24
|
+
* 422. Returns its `detail` text, or joins a detail list as `field: message`
|
|
25
|
+
* pairs. Returns undefined when the error has no detail.
|
|
26
|
+
*/
|
|
27
|
+
function falValidationMessage(error) {
|
|
28
|
+
if (typeof error !== "object" || error === null || !("body" in error)) return;
|
|
29
|
+
const body = error.body;
|
|
30
|
+
if (typeof body !== "object" || body === null || !("detail" in body)) return;
|
|
31
|
+
const detail = body.detail;
|
|
32
|
+
if (typeof detail === "string") return detail || void 0;
|
|
33
|
+
if (!Array.isArray(detail)) return void 0;
|
|
34
|
+
return detail.map((d) => {
|
|
35
|
+
const msg = d.msg ?? "invalid value";
|
|
36
|
+
return d.loc ? `${d.loc.join(".")}: ${msg}` : msg;
|
|
37
|
+
}).join("; ") || void 0;
|
|
15
38
|
}
|
|
16
39
|
function generateId$1(prefix) {
|
|
17
40
|
return generateId(prefix);
|
|
@@ -98,7 +121,6 @@ function arrayBufferToBase64(bytes) {
|
|
|
98
121
|
for (const byte of view) binary += String.fromCharCode(byte);
|
|
99
122
|
return btoa(binary);
|
|
100
123
|
}
|
|
101
|
-
|
|
102
|
-
export { arrayBufferToBase64, configureFalClient, dataUrlToBlob, deriveAudioContentType, extractUrlExtension, generateId$1 as generateId, getFalApiKeyFromEnv };
|
|
124
|
+
export { arrayBufferToBase64, createAdapterFalClient, dataUrlToBlob, deriveAudioContentType, extractUrlExtension, falValidationMessage, generateId$1 as generateId, getFalApiKeyFromEnv, toFalClientOptions };
|
|
103
125
|
|
|
104
126
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../../src/utils/client.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"client.js","names":["generateId","_generateId"],"sources":["../../../src/utils/client.ts"],"sourcesContent":["import { generateId as _generateId, getApiKeyFromEnv } from '@tanstack/ai-utils'\nimport { createFalClient } from '../client/index'\nimport { createBillingFetch } from './billing'\n\nexport interface FalClientConfig {\n apiKey: string\n proxyUrl?: string\n /**\n * Override the underlying fetch used for fal requests. The adapter wraps it to\n * read the `x-fal-billable-units` header (see ./billing.ts), so usage capture\n * still works. Defaults to the global `fetch`. Useful for proxying,\n * instrumentation, or pointing requests at a mock in tests.\n */\n fetch?: typeof fetch\n}\n\nexport function getFalApiKeyFromEnv(): string {\n return getApiKeyFromEnv('FAL_KEY')\n}\n\nexport function toFalClientOptions(config?: FalClientConfig) {\n const apiKey = config?.apiKey ?? getFalApiKeyFromEnv()\n return {\n credentials: apiKey,\n // Wrap the (optionally overridden) fetch to read fal's\n // `x-fal-billable-units` header off every response so adapters can surface\n // the billed quantity as `result.usage`. See ./billing.ts.\n fetch: createBillingFetch(config?.fetch),\n ...(config?.proxyUrl ? { proxyUrl: config.proxyUrl } : {}),\n }\n}\n\n/**\n * Create the fal client for one adapter. Each adapter has its own client, so\n * two adapters with different API keys do not change each other.\n */\nexport function createAdapterFalClient(config?: FalClientConfig) {\n return createFalClient(toFalClientOptions(config))\n}\n\n/**\n * fal can report a request COMPLETED and then answer the result fetch with a\n * 422. Returns its `detail` text, or joins a detail list as `field: message`\n * pairs. Returns undefined when the error has no detail.\n */\nexport function falValidationMessage(error: unknown): string | undefined {\n if (typeof error !== 'object' || error === null || !('body' in error)) {\n return undefined\n }\n const body = error.body\n if (typeof body !== 'object' || body === null || !('detail' in body)) {\n return undefined\n }\n const detail = body.detail\n if (typeof detail === 'string') return detail || undefined\n if (!Array.isArray(detail)) return undefined\n const message = detail\n .map((d: { msg?: string; loc?: Array<string> }) => {\n const msg = d.msg ?? 'invalid value'\n return d.loc ? `${d.loc.join('.')}: ${msg}` : msg\n })\n .join('; ')\n return message || undefined\n}\n\nexport function generateId(prefix: string): string {\n return _generateId(prefix)\n}\n\n/**\n * Extract a safe file extension from a URL. Strips query strings, URL\n * fragments, and any trailing slashes, and only returns the extension when\n * it looks like a real one (2-5 alphanumeric chars). Returns undefined\n * otherwise so callers can fall back to a default.\n */\nexport function extractUrlExtension(url: string): string | undefined {\n // Parse via URL when possible so we only look at the pathname and never\n // mistake a TLD (e.g. the `.com` in `https://x.com/`) for a file extension.\n let pathname: string\n try {\n const parsed = new URL(url)\n pathname = parsed.pathname\n } catch {\n // Fall back to treating the input as a raw path when URL parsing fails\n // (e.g. the caller passed a bare path). Still strip ?query and #fragment.\n pathname = url.split('?')[0]?.split('#')[0] ?? url\n }\n // Drop trailing slashes so `/path/audio.mp3/` still yields `mp3`.\n const normalized = pathname.replace(/\\/+$/, '')\n // Require at least one `/` — otherwise we're looking at an empty pathname\n // (bare-host URLs like `https://x.com/` land here after stripping the\n // trailing slash).\n if (!normalized.includes('/')) return undefined\n const lastSegment = normalized.split('/').pop()\n if (!lastSegment) return undefined\n const extension = lastSegment.split('.').pop()\n if (!extension || extension === lastSegment) return undefined\n return /^[a-z0-9]{2,5}$/i.test(extension) ? extension : undefined\n}\n\n/**\n * Derive a reasonable audio content-type. Prefers the explicit MIME (stripped\n * of parameters), then an extension-based lookup for common audio formats,\n * otherwise falls back to audio/mpeg — fal URLs virtually always serve mp3.\n */\nexport function deriveAudioContentType(\n explicitContentType: string | undefined,\n url: string,\n): string {\n const stripped = explicitContentType?.split(';')[0]?.trim()\n if (stripped) return stripped\n\n const ext = extractUrlExtension(url)?.toLowerCase()\n switch (ext) {\n case 'mp3':\n return 'audio/mpeg'\n case 'wav':\n return 'audio/wav'\n case 'ogg':\n case 'oga':\n return 'audio/ogg'\n case 'flac':\n return 'audio/flac'\n case 'aac':\n return 'audio/aac'\n case 'm4a':\n case 'mp4':\n return 'audio/mp4'\n case 'webm':\n return 'audio/webm'\n case undefined:\n default:\n return 'audio/mpeg'\n }\n}\n\n/**\n * Decode a `data:` URL into a Blob so fal-client can auto-upload it via\n * `fal.storage.upload`. fal's inference API rejects data URLs with a 422\n * \"Unsupported data URL\", so we convert them before handing them off.\n *\n * Supports both base64 and URL-encoded data URLs. Returns `undefined` for\n * anything that isn't a data URL, so callers can fall through to other\n * handling (http URLs are passed to fal as-is).\n */\nexport function dataUrlToBlob(value: string): Blob | undefined {\n if (!value.startsWith('data:')) return undefined\n const commaIndex = value.indexOf(',')\n if (commaIndex === -1) return undefined\n\n const header = value.slice(5, commaIndex)\n const payload = value.slice(commaIndex + 1)\n const isBase64 = /;base64$/i.test(header)\n const mimeType = header.split(';')[0] || 'application/octet-stream'\n\n if (isBase64) {\n const binary = atob(payload)\n const bytes = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i += 1) {\n bytes[i] = binary.charCodeAt(i)\n }\n return new Blob([bytes], { type: mimeType })\n }\n\n return new Blob([decodeURIComponent(payload)], { type: mimeType })\n}\n\n/**\n * Convert an ArrayBuffer to base64 in a cross-runtime way.\n *\n * The naive `btoa(String.fromCharCode(...bytes))` form blows up V8's argument\n * limit (~65k) on realistic audio payloads, so we either use `Buffer` (Node /\n * Bun) or walk the byte array in a single loop (browser).\n */\nexport function arrayBufferToBase64(bytes: ArrayBuffer): string {\n if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') {\n return Buffer.from(bytes).toString('base64')\n }\n const view = new Uint8Array(bytes)\n let binary = ''\n for (const byte of view) {\n binary += String.fromCharCode(byte)\n }\n return btoa(binary)\n}\n"],"mappings":";;;;AAgBA,SAAgB,sBAA8B;CAC5C,OAAO,iBAAiB,SAAS;AACnC;AAEA,SAAgB,mBAAmB,QAA0B;CAE3D,OA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B;CAC9D,IAAI,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,YAC1D,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;CAE7C,MAAM,OAAO,IAAI,WAAW,KAAK;CACjC,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,MACjB,UAAU,OAAO,aAAa,IAAI;CAEpC,OAAO,KAAK,MAAM;AACpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FalClientConfig } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configure the global `fal` client of `@fal-ai/client` with this config, for
|
|
4
|
+
* apps that call `fal` themselves. The adapters do not use the global client.
|
|
5
|
+
*
|
|
6
|
+
* ponytail: this file is the only static import of `@fal-ai/client`. It is a
|
|
7
|
+
* separate module, so a bundle that does not import this function drops it.
|
|
8
|
+
*
|
|
9
|
+
* @param config the API key (or `FAL_KEY` from the environment), an optional
|
|
10
|
+
* proxy URL, and an optional `fetch`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function configureFalClient(config?: FalClientConfig): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { toFalClientOptions } from "./client.js";
|
|
2
|
+
import { fal } from "@fal-ai/client";
|
|
3
|
+
// src/utils/configure.ts
|
|
4
|
+
/**
|
|
5
|
+
* Configure the global `fal` client of `@fal-ai/client` with this config, for
|
|
6
|
+
* apps that call `fal` themselves. The adapters do not use the global client.
|
|
7
|
+
*
|
|
8
|
+
* ponytail: this file is the only static import of `@fal-ai/client`. It is a
|
|
9
|
+
* separate module, so a bundle that does not import this function drops it.
|
|
10
|
+
*
|
|
11
|
+
* @param config the API key (or `FAL_KEY` from the environment), an optional
|
|
12
|
+
* proxy URL, and an optional `fetch`.
|
|
13
|
+
*/
|
|
14
|
+
function configureFalClient(config) {
|
|
15
|
+
fal.config(toFalClientOptions(config));
|
|
16
|
+
}
|
|
17
|
+
export { configureFalClient };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.js","names":[],"sources":["../../../src/utils/configure.ts"],"sourcesContent":["import { fal } from '@fal-ai/client'\nimport { toFalClientOptions } from './client'\nimport type { FalClientConfig } from './client'\n\n/**\n * Configure the global `fal` client of `@fal-ai/client` with this config, for\n * apps that call `fal` themselves. The adapters do not use the global client.\n *\n * ponytail: this file is the only static import of `@fal-ai/client`. It is a\n * separate module, so a bundle that does not import this function drops it.\n *\n * @param config the API key (or `FAL_KEY` from the environment), an optional\n * proxy URL, and an optional `fetch`.\n */\nexport function configureFalClient(config?: FalClientConfig): void {\n fal.config(toFalClientOptions(config))\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,mBAAmB,QAAgC;CACjE,IAAI,OAAO,mBAAmB,MAAM,CAAC;AACvC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { getFalApiKeyFromEnv,
|
|
1
|
+
export { getFalApiKeyFromEnv, generateId, arrayBufferToBase64, dataUrlToBlob, extractUrlExtension, deriveAudioContentType, type FalClientConfig, } from './client.js';
|
|
2
2
|
export { takeBillableUnits, buildFalUsage } from './billing.js';
|
|
3
|
+
export { configureFalClient } from './configure.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/video/video-provider-options.ts
|
|
2
2
|
function mapVideoSizeToFalFormat(size) {
|
|
3
3
|
if (!size) return {};
|
|
4
4
|
if (size.includes("_")) {
|
|
@@ -33,9 +33,22 @@ var VEO_4_6_8 = {
|
|
|
33
33
|
var LTX_6_8_10 = {
|
|
34
34
|
kind: "discrete",
|
|
35
35
|
values: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
6,
|
|
37
|
+
8,
|
|
38
|
+
10
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
var LTX_FAST_6_20 = {
|
|
42
|
+
kind: "discrete",
|
|
43
|
+
values: [
|
|
44
|
+
6,
|
|
45
|
+
8,
|
|
46
|
+
10,
|
|
47
|
+
12,
|
|
48
|
+
14,
|
|
49
|
+
16,
|
|
50
|
+
18,
|
|
51
|
+
20
|
|
39
52
|
]
|
|
40
53
|
};
|
|
41
54
|
var KLING_3_15 = {
|
|
@@ -73,11 +86,6 @@ var FAL_VIDEO_DURATIONS = durationMap({
|
|
|
73
86
|
"fal-ai/kling-video/v2.6/pro/image-to-video": KLING_5_10,
|
|
74
87
|
"fal-ai/kling-video/v3/pro/text-to-video": KLING_3_15,
|
|
75
88
|
"fal-ai/kling-video/v3/pro/image-to-video": KLING_3_15,
|
|
76
|
-
"fal-ai/pika/v2.2/text-to-video": KLING_5_10,
|
|
77
|
-
"fal-ai/luma-dream-machine/ray-2": {
|
|
78
|
-
kind: "discrete",
|
|
79
|
-
values: ["5s", "9s"]
|
|
80
|
-
},
|
|
81
89
|
"fal-ai/veo3": VEO_4_6_8,
|
|
82
90
|
"fal-ai/veo3/image-to-video": VEO_4_6_8,
|
|
83
91
|
"fal-ai/veo3.1": VEO_4_6_8,
|
|
@@ -85,35 +93,16 @@ var FAL_VIDEO_DURATIONS = durationMap({
|
|
|
85
93
|
"fal-ai/veo3.1/fast": VEO_4_6_8,
|
|
86
94
|
"fal-ai/veo3.1/fast/image-to-video": VEO_4_6_8,
|
|
87
95
|
"fal-ai/ltx-2.3/text-to-video": LTX_6_8_10,
|
|
88
|
-
"fal-ai/ltx-2.3/text-to-video/fast":
|
|
96
|
+
"fal-ai/ltx-2.3/text-to-video/fast": LTX_FAST_6_20,
|
|
89
97
|
"fal-ai/ltx-2.3/image-to-video": LTX_6_8_10,
|
|
90
|
-
"fal-ai/ltx-2.3/image-to-video/fast":
|
|
91
|
-
"fal-ai/wan-25-preview/text-to-video":
|
|
92
|
-
kind: "discrete",
|
|
93
|
-
values: [
|
|
94
|
-
"2",
|
|
95
|
-
"3",
|
|
96
|
-
"4",
|
|
97
|
-
"5",
|
|
98
|
-
"6",
|
|
99
|
-
"7",
|
|
100
|
-
"8",
|
|
101
|
-
"9",
|
|
102
|
-
"10",
|
|
103
|
-
"11",
|
|
104
|
-
"12",
|
|
105
|
-
"13",
|
|
106
|
-
"14",
|
|
107
|
-
"15"
|
|
108
|
-
]
|
|
109
|
-
},
|
|
98
|
+
"fal-ai/ltx-2.3/image-to-video/fast": LTX_FAST_6_20,
|
|
99
|
+
"fal-ai/wan-25-preview/text-to-video": KLING_5_10,
|
|
110
100
|
"fal-ai/minimax/video-01": { kind: "none" },
|
|
111
101
|
"fal-ai/hunyuan-video-v1.5/text-to-video": { kind: "none" }
|
|
112
102
|
});
|
|
113
103
|
function getFalVideoDurationOptions(model) {
|
|
114
104
|
return FAL_VIDEO_DURATIONS[model] ?? { kind: "none" };
|
|
115
105
|
}
|
|
116
|
-
//#endregion
|
|
117
106
|
export { getFalVideoDurationOptions, mapVideoSizeToFalFormat };
|
|
118
107
|
|
|
119
108
|
//# sourceMappingURL=video-provider-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-provider-options.js","names":[],"sources":["../../../src/video/video-provider-options.ts"],"sourcesContent":["import type { DurationOptions } from '@tanstack/ai/adapters'\nimport type {\n FalModelVideoDuration,\n FalModelVideoSize,\n FalModelVideoSizeInput,\n} from '../model-meta'\n\nexport function mapVideoSizeToFalFormat<TModel extends string>(\n size?: FalModelVideoSize<TModel>,\n): FalModelVideoSizeInput<TModel> {\n if (!size) {\n return {} as FalModelVideoSizeInput<TModel>\n }\n\n if (size.includes('_')) {\n const [aspectRatio, resolution] = size.split('_')\n return {\n aspect_ratio: aspectRatio,\n resolution,\n } as FalModelVideoSizeInput<TModel>\n }\n\n if (size.includes(':')) {\n return { aspect_ratio: size } as FalModelVideoSizeInput<TModel>\n }\n\n return { resolution: size } as FalModelVideoSizeInput<TModel>\n}\n\n/**\n * Identity helper that checks each entry against the SDK's `duration` union\n * for its own key, so a typo'd endpoint id or a stale union fails to compile.\n */\nfunction durationMap<\n const T extends {\n [K in keyof T & string]: DurationOptions<FalModelVideoDuration<K>>\n },\n>(map: T): T {\n return map\n}\n\nconst KLING_5_10 = { kind: 'discrete', values: ['5', '10'] } as const\nconst VEO_4_6_8 = { kind: 'discrete', values: ['4s', '6s', '8s'] } as const\nconst LTX_6_8_10 = { kind: 'discrete', values: [
|
|
1
|
+
{"version":3,"file":"video-provider-options.js","names":[],"sources":["../../../src/video/video-provider-options.ts"],"sourcesContent":["import type { DurationOptions } from '@tanstack/ai/adapters'\nimport type {\n FalModelVideoDuration,\n FalModelVideoSize,\n FalModelVideoSizeInput,\n} from '../model-meta'\n\nexport function mapVideoSizeToFalFormat<TModel extends string>(\n size?: FalModelVideoSize<TModel>,\n): FalModelVideoSizeInput<TModel> {\n if (!size) {\n return {} as FalModelVideoSizeInput<TModel>\n }\n\n if (size.includes('_')) {\n const [aspectRatio, resolution] = size.split('_')\n return {\n aspect_ratio: aspectRatio,\n resolution,\n } as FalModelVideoSizeInput<TModel>\n }\n\n if (size.includes(':')) {\n return { aspect_ratio: size } as FalModelVideoSizeInput<TModel>\n }\n\n return { resolution: size } as FalModelVideoSizeInput<TModel>\n}\n\n/**\n * Identity helper that checks each entry against the SDK's `duration` union\n * for its own key, so a typo'd endpoint id or a stale union fails to compile.\n */\nfunction durationMap<\n const T extends {\n [K in keyof T & string]: DurationOptions<FalModelVideoDuration<K>>\n },\n>(map: T): T {\n return map\n}\n\nconst KLING_5_10 = { kind: 'discrete', values: ['5', '10'] } as const\nconst VEO_4_6_8 = { kind: 'discrete', values: ['4s', '6s', '8s'] } as const\nconst LTX_6_8_10 = { kind: 'discrete', values: [6, 8, 10] } as const\n// Durations over 10 seconds need 25 FPS and 1080p.\nconst LTX_FAST_6_20 = {\n kind: 'discrete',\n values: [6, 8, 10, 12, 14, 16, 18, 20],\n} as const\nconst KLING_3_15 = {\n kind: 'discrete',\n values: [\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n '10',\n '11',\n '12',\n '13',\n '14',\n '15',\n ],\n} as const\n\n/**\n * Curated map of per-model duration options for popular fal.ai video models.\n * Values are checked at compile time against `@fal-ai/client`'s\n * `EndpointTypeMap` input types via `durationMap`.\n *\n * Models not listed here fall back to `{ kind: 'none' }` — honest \"we don't\n * know\" rather than guessing. The type-level `FalModelVideoDuration<TModel>`\n * still derives from the SDK types, so autocomplete works for SDK-known\n * models that aren't curated here.\n */\nconst FAL_VIDEO_DURATIONS = durationMap({\n 'fal-ai/kling-video/v1.6/standard/text-to-video': KLING_5_10,\n 'fal-ai/kling-video/v1.6/pro/text-to-video': KLING_5_10,\n 'fal-ai/kling-video/v2.6/pro/text-to-video': KLING_5_10,\n 'fal-ai/kling-video/v2.6/pro/image-to-video': KLING_5_10,\n 'fal-ai/kling-video/v3/pro/text-to-video': KLING_3_15,\n 'fal-ai/kling-video/v3/pro/image-to-video': KLING_3_15,\n 'fal-ai/veo3': VEO_4_6_8,\n 'fal-ai/veo3/image-to-video': VEO_4_6_8,\n 'fal-ai/veo3.1': VEO_4_6_8,\n 'fal-ai/veo3.1/image-to-video': VEO_4_6_8,\n 'fal-ai/veo3.1/fast': VEO_4_6_8,\n 'fal-ai/veo3.1/fast/image-to-video': VEO_4_6_8,\n 'fal-ai/ltx-2.3/text-to-video': LTX_6_8_10,\n 'fal-ai/ltx-2.3/text-to-video/fast': LTX_FAST_6_20,\n 'fal-ai/ltx-2.3/image-to-video': LTX_6_8_10,\n 'fal-ai/ltx-2.3/image-to-video/fast': LTX_FAST_6_20,\n 'fal-ai/wan-25-preview/text-to-video': KLING_5_10,\n 'fal-ai/minimax/video-01': { kind: 'none' },\n 'fal-ai/hunyuan-video-v1.5/text-to-video': { kind: 'none' },\n})\n\nexport function getFalVideoDurationOptions<TModel extends string>(\n model: TModel,\n): DurationOptions<FalModelVideoDuration<TModel>> {\n const entry = (FAL_VIDEO_DURATIONS as Record<string, unknown>)[model]\n // The map is keyed by literal ids but the adapter's TModel is an open string;\n // the lookup result can't be correlated by TS, hence the one cast here.\n return (entry ?? { kind: 'none'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AAE,MAAM,OAAO;AAGlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-fal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"import": "./dist/esm/byok.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
+
"sideEffects": false,
|
|
33
34
|
"files": [
|
|
34
35
|
"dist",
|
|
35
36
|
"src"
|
|
@@ -53,16 +54,16 @@
|
|
|
53
54
|
"media-generation"
|
|
54
55
|
],
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@fal-ai/client": "^1.
|
|
57
|
-
"@tanstack/ai-utils": "^1.0
|
|
57
|
+
"@fal-ai/client": "^1.11.0",
|
|
58
|
+
"@tanstack/ai-utils": "^1.1.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@vitest/coverage-v8": "4.1.
|
|
61
|
-
"vite": "^8.
|
|
62
|
-
"@tanstack/ai": "1.
|
|
61
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
62
|
+
"vite": "^8.3.8",
|
|
63
|
+
"@tanstack/ai": "1.7.0"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@tanstack/ai": "^1.
|
|
66
|
+
"@tanstack/ai": "^1.7.0"
|
|
66
67
|
},
|
|
67
68
|
"scripts": {
|
|
68
69
|
"build": "vite build",
|
package/src/adapters/audio.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { fal } from '@fal-ai/client'
|
|
2
1
|
import { BaseAudioAdapter } from '@tanstack/ai/adapters'
|
|
3
2
|
import {
|
|
4
|
-
|
|
3
|
+
createAdapterFalClient,
|
|
5
4
|
deriveAudioContentType,
|
|
6
5
|
generateId as utilGenerateId,
|
|
7
6
|
} from '../utils/client'
|
|
@@ -12,6 +11,7 @@ import type {
|
|
|
12
11
|
AudioGenerationResult,
|
|
13
12
|
} from '@tanstack/ai'
|
|
14
13
|
import type { FalClientConfig } from '../utils/client'
|
|
14
|
+
import type { FalClient } from '../client/index'
|
|
15
15
|
import type { FalModel, FalModelInput } from '../model-meta'
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -68,10 +68,11 @@ export class FalAudioAdapter<TModel extends FalModel> extends BaseAudioAdapter<
|
|
|
68
68
|
FalAudioProviderOptions<TModel>
|
|
69
69
|
> {
|
|
70
70
|
readonly name = 'fal' as const
|
|
71
|
+
private readonly client: FalClient
|
|
71
72
|
|
|
72
73
|
constructor(model: TModel, config?: FalClientConfig) {
|
|
73
74
|
super(model, {})
|
|
74
|
-
|
|
75
|
+
this.client = createAdapterFalClient(config)
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
async generateAudio(
|
|
@@ -85,8 +86,8 @@ export class FalAudioAdapter<TModel extends FalModel> extends BaseAudioAdapter<
|
|
|
85
86
|
let requestId: string | undefined
|
|
86
87
|
try {
|
|
87
88
|
const input = this.buildInput(options)
|
|
88
|
-
//
|
|
89
|
-
const result = await
|
|
89
|
+
// Pass the abortSignal per request, not in the client config.
|
|
90
|
+
const result = await this.client.subscribe(this.model, {
|
|
90
91
|
input,
|
|
91
92
|
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
92
93
|
onEnqueue: (id) => {
|
|
@@ -98,7 +99,7 @@ export class FalAudioAdapter<TModel extends FalModel> extends BaseAudioAdapter<
|
|
|
98
99
|
// The SDK stops waiting on abort but leaves the queued job running.
|
|
99
100
|
// Cancel it so it stops billing.
|
|
100
101
|
if (requestId && options.abortSignal?.aborted) {
|
|
101
|
-
|
|
102
|
+
this.client.queue.cancel(this.model, { requestId }).catch(() => {})
|
|
102
103
|
}
|
|
103
104
|
logger.errors('fal.generateAudio fatal', {
|
|
104
105
|
error,
|
package/src/adapters/files.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { fal } from '@fal-ai/client'
|
|
2
1
|
import {
|
|
3
2
|
BaseFilesAdapter,
|
|
4
3
|
normalizeFileUploadInput,
|
|
5
4
|
} from '@tanstack/ai/adapters'
|
|
6
|
-
import {
|
|
5
|
+
import { createAdapterFalClient } from '../utils/client'
|
|
7
6
|
import type { StorageSettings } from '@fal-ai/client'
|
|
8
7
|
import type { FileHandle, FileUploadInput } from '@tanstack/ai/adapters'
|
|
9
8
|
import type { FalClientConfig } from '../utils/client'
|
|
9
|
+
import type { FalClient } from '../client/index'
|
|
10
10
|
|
|
11
11
|
export interface FalFilesConfig extends FalClientConfig {
|
|
12
12
|
/**
|
|
@@ -25,17 +25,18 @@ export interface FalFilesConfig extends FalClientConfig {
|
|
|
25
25
|
*/
|
|
26
26
|
export class FalFilesAdapter extends BaseFilesAdapter<'fal'> {
|
|
27
27
|
readonly name = 'fal' as const
|
|
28
|
+
private readonly client: FalClient
|
|
28
29
|
private readonly expiresIn?: StorageSettings['expiresIn']
|
|
29
30
|
|
|
30
31
|
constructor(config?: FalFilesConfig) {
|
|
31
32
|
super()
|
|
32
|
-
|
|
33
|
+
this.client = createAdapterFalClient(config)
|
|
33
34
|
this.expiresIn = config?.expiresIn
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
async upload(input: FileUploadInput): Promise<FileHandle<'fal'>> {
|
|
37
38
|
const { blob, mimeType } = normalizeFileUploadInput(input)
|
|
38
|
-
const url = await
|
|
39
|
+
const url = await this.client.storage.upload(
|
|
39
40
|
blob,
|
|
40
41
|
this.expiresIn !== undefined
|
|
41
42
|
? { lifecycle: { expiresIn: this.expiresIn } }
|
package/src/adapters/image.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { fal } from '@fal-ai/client'
|
|
2
1
|
import { resolveMediaPrompt } from '@tanstack/ai'
|
|
3
2
|
import { BaseImageAdapter } from '@tanstack/ai/adapters'
|
|
4
3
|
import {
|
|
5
|
-
|
|
4
|
+
createAdapterFalClient,
|
|
6
5
|
generateId as utilGenerateId,
|
|
7
6
|
} from '../utils/client'
|
|
8
7
|
import { buildFalUsage, takeBillableUnits } from '../utils/billing'
|
|
@@ -10,6 +9,7 @@ import { mapSizeToFalFormat } from '../image/image-provider-options'
|
|
|
10
9
|
import { mapImageInputsToFalFields } from '../image/image-inputs'
|
|
11
10
|
import type { OutputType, Result } from '@fal-ai/client'
|
|
12
11
|
import type { FalClientConfig } from '../utils/client'
|
|
12
|
+
import type { FalClient } from '../client/index'
|
|
13
13
|
import type {
|
|
14
14
|
GeneratedImage,
|
|
15
15
|
ImageGenerationOptions,
|
|
@@ -53,12 +53,13 @@ export class FalImageAdapter<TModel extends FalModel> extends BaseImageAdapter<
|
|
|
53
53
|
> {
|
|
54
54
|
override readonly kind = 'image' as const
|
|
55
55
|
readonly name = 'fal' as const
|
|
56
|
+
private readonly client: FalClient
|
|
56
57
|
// Consumes fal storage URLs uploaded via falFiles().
|
|
57
58
|
override readonly supportsFileSources = true
|
|
58
59
|
|
|
59
60
|
constructor(model: TModel, config?: FalClientConfig) {
|
|
60
61
|
super(model, {})
|
|
61
|
-
|
|
62
|
+
this.client = createAdapterFalClient(config)
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
async generateImages(
|
|
@@ -90,9 +91,9 @@ export class FalImageAdapter<TModel extends FalModel> extends BaseImageAdapter<
|
|
|
90
91
|
let requestId: string | undefined
|
|
91
92
|
try {
|
|
92
93
|
const input = this.buildInput(options, resolved)
|
|
93
|
-
// Pass
|
|
94
|
-
//
|
|
95
|
-
const result = await
|
|
94
|
+
// Pass the abortSignal per request, not in the client config, so it
|
|
95
|
+
// cannot cancel other generations.
|
|
96
|
+
const result = await this.client.subscribe(this.model, {
|
|
96
97
|
input,
|
|
97
98
|
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
98
99
|
onEnqueue: (id) => {
|
|
@@ -104,7 +105,7 @@ export class FalImageAdapter<TModel extends FalModel> extends BaseImageAdapter<
|
|
|
104
105
|
// The SDK stops waiting on abort but leaves the queued job running.
|
|
105
106
|
// Cancel it so it stops billing.
|
|
106
107
|
if (requestId && options.abortSignal?.aborted) {
|
|
107
|
-
|
|
108
|
+
this.client.queue.cancel(this.model, { requestId }).catch(() => {})
|
|
108
109
|
}
|
|
109
110
|
logger.errors('fal.generateImage fatal', {
|
|
110
111
|
error,
|