Skip to content

Commit 2e6e5d3

Browse files
authored
feat(fal): support kontext model (vercel#6549)
## Background Fal added support for new Flux Kontext models. ## Summary Adds model ids, example, and updates docs. ## Tasks - [ ] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Future Work We might want to add typed provider options here. Currently just pass through the entire provider options into the body.
1 parent 9b09f85 commit 2e6e5d3

4 files changed

Lines changed: 56 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/fal': patch
3+
---
4+
5+
feat (@ai-sdk/fal): support new Flux Kontext models

content/providers/01-ai-sdk-providers/10-fal.mdx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@ console.log(`Image saved to ${filename}`);
9393

9494
Fal offers many models optimized for different use cases. Here are a few popular examples. For a full list of models, see the [Fal AI documentation](https://fal.ai/models).
9595

96-
| Model | Description |
97-
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
98-
| `fal-ai/fast-sdxl` | High-speed SDXL model optimized for quick inference with up to 4x faster speeds |
99-
| `fal-ai/flux-lora` | Super fast endpoint for the FLUX.1 [dev] model with LoRA support, enabling rapid and high-quality image generation using pre-trained LoRA adaptations. |
100-
| `fal-ai/flux-pro/v1.1-ultra` | Professional-grade image generation with up to 2K resolution and enhanced photorealism |
101-
| `fal-ai/ideogram/v2` | Specialized for high-quality posters and logos with exceptional typography handling |
102-
| `fal-ai/recraft-v3` | SOTA in image generation with vector art and brand style capabilities |
103-
| `fal-ai/stable-diffusion-3.5-large` | Advanced MMDiT model with improved typography and complex prompt understanding |
104-
| `fal-ai/hyper-sdxl` | Performance-optimized SDXL variant with enhanced creative capabilities |
96+
| Model | Description |
97+
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
98+
| `fal-ai/fast-sdxl` | High-speed SDXL model optimized for quick inference with up to 4x faster speeds |
99+
| `fal-ai/flux-pro/kontext` | FLUX.1 Kontext [pro] handles both text and reference images as inputs, seamlessly enabling targeted, local edits and complex transformations of entire scenes |
100+
| `fal-ai/flux-pro/kontext/max` | FLUX.1 Kontext [max] with greatly improved prompt adherence and typography generation, meeting premium consistency for editing without compromise on speed |
101+
| `fal-ai/flux-lora` | Super fast endpoint for the FLUX.1 [dev] model with LoRA support, enabling rapid and high-quality image generation using pre-trained LoRA adaptations. |
102+
| `fal-ai/flux-pro/v1.1-ultra` | Professional-grade image generation with up to 2K resolution and enhanced photorealism |
103+
| `fal-ai/ideogram/v2` | Specialized for high-quality posters and logos with exceptional typography handling |
104+
| `fal-ai/recraft-v3` | SOTA in image generation with vector art and brand style capabilities |
105+
| `fal-ai/stable-diffusion-3.5-large` | Advanced MMDiT model with improved typography and complex prompt understanding |
106+
| `fal-ai/hyper-sdxl` | Performance-optimized SDXL variant with enhanced creative capabilities |
105107

106108
Fal models support the following aspect ratios:
107109

@@ -123,6 +125,24 @@ Key features of Fal models include:
123125
- Cost-effective scaling with pay-per-use pricing
124126
- LoRA training capabilities for model personalization
125127

128+
#### Modify Image
129+
130+
Transform existing images using text prompts.
131+
132+
```ts
133+
// Example: Modify existing image
134+
await generateImage({
135+
model: fal.image('fal-ai/flux-pro/kontext'),
136+
prompt: 'Put a donut next to the flour.',
137+
providerOptions: {
138+
fal: {
139+
image_url:
140+
'https://v3.fal.media/files/rabbit/rmgBxhwGYb2d3pl3x9sKf_output.png',
141+
},
142+
},
143+
});
144+
```
145+
126146
### Advanced Features
127147

128148
Fal's platform offers several advanced capabilities:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { fal } from '@ai-sdk/fal';
2+
import { experimental_generateImage as generateImage } from 'ai';
3+
import { presentImages } from '../lib/present-image';
4+
import 'dotenv/config';
5+
6+
async function main() {
7+
const { images } = await generateImage({
8+
model: fal.image('fal-ai/flux-pro/kontext/max'),
9+
prompt: 'Put a donut next to the flour.',
10+
providerOptions: {
11+
fal: {
12+
image_url:
13+
'https://v3.fal.media/files/rabbit/rmgBxhwGYb2d3pl3x9sKf_output.png',
14+
},
15+
},
16+
});
17+
await presentImages(images);
18+
}
19+
20+
main().catch(console.error);

packages/fal/src/fal-image-settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// https://fal.ai/models
22
export type FalImageModelId =
3+
| 'fal-ai/flux-pro/kontext/max'
4+
| 'fal-ai/flux-pro/kontext'
35
| 'fal-ai/aura-flow'
46
| 'fal-ai/aura-sr'
57
| 'fal-ai/bria/eraser'

0 commit comments

Comments
 (0)