@tanstack/ai-fal 0.14.4 → 0.14.6

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.
Files changed (2) hide show
  1. package/README.md +163 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ <div align="center">
2
+ <picture>
3
+ <source
4
+ media="(prefers-color-scheme: dark)"
5
+ srcset="https://tanstack.com/api/readme/ai.png?theme=dark"
6
+ />
7
+ <source
8
+ media="(prefers-color-scheme: light)"
9
+ srcset="https://tanstack.com/api/readme/ai.png"
10
+ />
11
+ <img
12
+ src="https://tanstack.com/api/readme/ai.png"
13
+ alt="TanStack AI"
14
+ width="900"
15
+ />
16
+ </picture>
17
+ </div>
18
+
19
+ <br />
20
+
21
+ # @tanstack/ai-fal
22
+
23
+ fal.ai adapter for TanStack AI image, video, live, audio, speech, and transcription generation
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @tanstack/ai-fal
29
+ # or
30
+ pnpm add @tanstack/ai-fal
31
+ # or
32
+ yarn add @tanstack/ai-fal
33
+ ```
34
+
35
+ ## Setup
36
+
37
+ Create an API key at [fal.ai](https://fal.ai) and set it as an environment variable:
38
+
39
+ ```bash
40
+ export FAL_KEY="your-fal-api-key"
41
+ ```
42
+
43
+ Or pass it explicitly to any adapter factory: `falImage('fal-ai/flux/dev', { apiKey })`.
44
+
45
+ ## Usage
46
+
47
+ ### Image generation
48
+
49
+ ```typescript
50
+ import { generateImage } from '@tanstack/ai'
51
+ import { falImage } from '@tanstack/ai-fal'
52
+
53
+ const result = await generateImage({
54
+ adapter: falImage('fal-ai/flux/dev'),
55
+ prompt: 'A futuristic cityscape at sunset',
56
+ numberOfImages: 1,
57
+ })
58
+
59
+ console.log(result.images)
60
+ ```
61
+
62
+ Model ids are string literals with full type safety, so `size` and `modelOptions` are checked against the model you picked.
63
+
64
+ ### Video generation (experimental)
65
+
66
+ Video runs as a job: submit, then poll.
67
+
68
+ ```typescript
69
+ import { generateVideo, getVideoJobStatus } from '@tanstack/ai'
70
+ import { falVideo } from '@tanstack/ai-fal'
71
+
72
+ const adapter = falVideo('fal-ai/kling-video/v2.6/pro/text-to-video')
73
+
74
+ const job = await generateVideo({
75
+ adapter,
76
+ prompt: 'A timelapse of a flower blooming',
77
+ size: '16:9',
78
+ duration: '5',
79
+ })
80
+
81
+ const status = await getVideoJobStatus({ adapter, jobId: job.jobId })
82
+ console.log(status.status) // "pending" | "processing" | "completed"
83
+ ```
84
+
85
+ ### Text-to-speech
86
+
87
+ The adapter fetches the generated audio from fal's CDN and returns it base64-encoded, matching the `TTSResult` contract.
88
+
89
+ ```typescript
90
+ import { generateSpeech } from '@tanstack/ai'
91
+ import { falSpeech } from '@tanstack/ai-fal'
92
+
93
+ const result = await generateSpeech({
94
+ adapter: falSpeech('fal-ai/kokoro/american-english'),
95
+ text: 'Hello from fal!',
96
+ voice: 'af_heart',
97
+ speed: 1.0,
98
+ })
99
+
100
+ console.log(result.format) // e.g. "wav"
101
+ ```
102
+
103
+ ### Transcription
104
+
105
+ `audio` accepts a URL string, `Blob`, `File`, or `ArrayBuffer`.
106
+
107
+ ```typescript
108
+ import { generateTranscription } from '@tanstack/ai'
109
+ import { falTranscription } from '@tanstack/ai-fal'
110
+
111
+ const result = await generateTranscription({
112
+ adapter: falTranscription('fal-ai/whisper'),
113
+ audio: 'https://example.com/recording.mp3',
114
+ language: 'en',
115
+ })
116
+
117
+ console.log(result.text)
118
+ ```
119
+
120
+ ### Music and sound effects
121
+
122
+ Unlike TTS, `generateAudio()` returns a URL in `result.audio.url`.
123
+
124
+ ```typescript
125
+ import { generateAudio } from '@tanstack/ai'
126
+ import { falAudio } from '@tanstack/ai-fal'
127
+
128
+ const music = await generateAudio({
129
+ adapter: falAudio('fal-ai/minimax-music/v2.6'),
130
+ prompt: 'City Pop, 80s retro, groovy synth bass, warm female vocal, 104 BPM',
131
+ })
132
+
133
+ console.log(music.audio.url)
134
+ ```
135
+
136
+ ### Live video
137
+
138
+ `falLiveVideo('minimax/h3-max/director')` with `generateLiveVideo()` starts an H3 Max Director session; the browser then connects through a server proxy that attaches `FAL_KEY`. See [Live Generation](https://tanstack.com/ai/latest/docs/media/live-generation) for the connect step.
139
+
140
+ ## Adapters
141
+
142
+ | Factory | Activity |
143
+ | -------------------- | ------------------------- |
144
+ | `falImage()` | `generateImage()` |
145
+ | `falVideo()` | `generateVideo()` |
146
+ | `falLiveVideo()` | `generateLiveVideo()` |
147
+ | `falSpeech()` | `generateSpeech()` |
148
+ | `falTranscription()` | `generateTranscription()` |
149
+ | `falAudio()` | `generateAudio()` |
150
+
151
+ ## Limitations
152
+
153
+ - 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
+
156
+ ## Documentation
157
+
158
+ - [fal.ai adapter](https://tanstack.com/ai/latest/docs/adapters/fal): every option, the popular models per activity, and the full API reference
159
+ - [Live Generation](https://tanstack.com/ai/latest/docs/media/live-generation)
160
+
161
+ ## License
162
+
163
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-fal",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
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",
@@ -59,10 +59,10 @@
59
59
  "devDependencies": {
60
60
  "@vitest/coverage-v8": "4.1.10",
61
61
  "vite": "^8.2.1",
62
- "@tanstack/ai": "0.58.0"
62
+ "@tanstack/ai": "0.59.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "@tanstack/ai": "^0.58.0"
65
+ "@tanstack/ai": "^0.59.0"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "vite build",