Skip to content

Commit e79f024

Browse files
authored
WAI new model (#26739)
* push * edit input img size * pricing update
1 parent 626e61a commit e79f024

File tree

4 files changed

+321
-0
lines changed

4 files changed

+321
-0
lines changed
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
---
2+
title: Launching FLUX.2 [dev] on Workers AI
3+
description: Partnering with Black Forest Labs to bring their latest FLUX.2 model to Workers AI
4+
date: 2025-11-25
5+
---
6+
7+
We've partnered with Black Forest Labs (BFL) to bring their latest FLUX.2 [dev] model to Workers AI! This model excels in generating high-fidelity images with physical world grounding, multi-language support, and digital asset creation. You can also create specific super images with granular controls like JSON prompting.
8+
9+
Read the [BFL blog](https://bfl.ai/flux2) to learn more about the model itself. Read our [Cloudflare blog](https://blog.cloudflare.com/flux-2-workers-ai) to see the model in action, or try it out yourself on our [multi modal playground](https://multi-modal.ai.cloudflare.com/).
10+
11+
Pricing documentation is available on the [model page](/workers-ai/models/flux-2-dev/) or [pricing page](/workers-ai/platform/pricing/). Note, we expect to drop pricing in the next few days after iterating on the model performance.
12+
13+
## Workers AI Platform specifics
14+
15+
The model hosted on Workers AI is able to support up to 4 image inputs (512x512 per input image). Note, this image model is one of the most powerful in the catalog and is expected to be slower than the other image models we currently support. One catch to look out for is that this model takes multipart form data inputs, even if you just have a prompt.
16+
17+
With the REST API, the multipart form data input looks like this:
18+
19+
```bash
20+
curl --request POST \
21+
--url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT}/ai/run/@cf/black-forest-labs/flux-2-dev' \
22+
--header 'Authorization: Bearer {TOKEN}' \
23+
--header 'Content-Type: multipart/form-data' \
24+
--form 'prompt=a sunset at the alps' \
25+
--form steps=25
26+
--form width=1024
27+
--form height=1024
28+
```
29+
30+
With the Workers AI binding, you can use it as such:
31+
32+
```javascript
33+
const form = new FormData();
34+
form.append('prompt', 'a sunset at the alps')
35+
form.append('width', 512)
36+
form.append('height', 512)
37+
38+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-dev", {
39+
multipart: {
40+
body: form,
41+
contentType: "multipart/form-data"
42+
}
43+
})
44+
45+
The parameters you can send to the model are detailed here:
46+
47+
<details>
48+
<summary>JSON Schema for Model</summary>
49+
**Required Parameters**
50+
51+
- `prompt` (string) - Text description of the image to generate
52+
53+
**Optional Parameters**
54+
55+
- `input_image_0` (string) - Binary image
56+
- `input_image_1` (string) - Binary image
57+
- `input_image_2` (string) - Binary image
58+
- `input_image_3` (string) - Binary image
59+
- `steps` (integer) - Number of inference steps. Higher values may improve quality but increase generation time
60+
- `guidance` (float) - Guidance scale for generation. Higher values follow the prompt more closely
61+
- `width` (integer) - Width of the image, default `1024` Range: 256-1920
62+
- `height` (integer) - Height of the image, default `768` Range: 256-1920
63+
- `seed` (integer) - Seed for reproducibility
64+
65+
</details>
66+
67+
```
68+
69+
## Multi-Reference Images
70+
71+
The FLUX.2 model is great at generating images based on reference images. You can use this feature to apply the style of one image to another, add a new character to an image, or iterate on past generate images. You would use it with the same multipart form data structure, with the input images in binary.
72+
73+
For the prompt, you can reference the images based on the index, like `take the subject of image 1 and style it like image 0` or even use natural language like `place the dog beside the woman`.
74+
75+
Note: you have to name the input parameter as `input_image_0`, `input_image_1`, `input_image_2` for it to work correctly. All input images must be smaller than 512x512.
76+
77+
```bash
78+
curl --request POST \
79+
--url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT}/ai/run/@cf/black-forest-labs/flux-2-dev' \
80+
--header 'Authorization: Bearer {TOKEN}' \
81+
--header 'Content-Type: multipart/form-data' \
82+
--form 'prompt=take the subject of image 1 and style it like image 0' \
83+
--form input_image_0=@/Users/johndoe/Desktop/icedoutkeanu.png \
84+
--form input_image_1=@/Users/johndoe/Desktop/me.png \
85+
--form steps=25
86+
--form width=1024
87+
--form height=1024
88+
```
89+
Through Workers AI Binding:
90+
91+
```javascript
92+
const image0 = await fetch("http://image-url");
93+
const image1 = await fetch("http://image-url");
94+
const form = new FormData();
95+
96+
const image_blob0 = await streamToBlob(image0.body, "image/png");
97+
const image_blob1 = await streamToBlob(image1.body, "image/png");
98+
form.append('input_image_0', image_blob0)
99+
form.append('input_image_1', image_blob1)
100+
form.append('prompt', 'take the subject of image 1and style it like image 0')
101+
102+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-dev", {
103+
multipart: {
104+
body: form,
105+
contentType: "multipart/form-data"
106+
}
107+
})
108+
109+
```
110+
111+
## JSON Prompting
112+
113+
The model supports prompting in JSON to get more granular control over images. You would pass the JSON as the value of the 'prompt' field in the multipart form data. See the JSON schema below on the base parameters you can pass to the model.
114+
115+
<details>
116+
<summary>JSON Prompting Schema</summary>
117+
118+
```json
119+
{
120+
"type": "object",
121+
"properties": {
122+
"scene": {
123+
"type": "string",
124+
"description": "Overall scene setting or location"
125+
},
126+
"subjects": {
127+
"type": "array",
128+
"items": {
129+
"type": "object",
130+
"properties": {
131+
"type": {
132+
"type": "string",
133+
"description": "Type of subject (e.g., desert nomad, blacksmith, DJ, falcon)"
134+
},
135+
"description": {
136+
"type": "string",
137+
"description": "Physical attributes, clothing, accessories"
138+
},
139+
"pose": {
140+
"type": "string",
141+
"description": "Action or stance"
142+
},
143+
"position": {
144+
"type": "string",
145+
"enum": ["foreground", "midground", "background"],
146+
"description": "Depth placement in scene"
147+
}
148+
},
149+
"required": ["type", "description", "pose", "position"]
150+
}
151+
},
152+
"style": {
153+
"type": "string",
154+
"description": "Artistic rendering style (e.g., digital painting, photorealistic, pixel art, noir sci-fi, lifestyle photo, wabi-sabi photo)"
155+
},
156+
"color_palette": {
157+
"type": "array",
158+
"items": { "type": "string" },
159+
"minItems": 3,
160+
"maxItems": 3,
161+
"description": "Exactly 3 main colors for the scene (e.g., ['navy', 'neon yellow', 'magenta'])"
162+
},
163+
"lighting": {
164+
"type": "string",
165+
"description": "Lighting condition and direction (e.g., fog-filtered sun, moonlight with star glints, dappled sunlight)"
166+
},
167+
"mood": {
168+
"type": "string",
169+
"description": "Emotional atmosphere (e.g., harsh and determined, playful and modern, peaceful and dreamy)"
170+
},
171+
"background": {
172+
"type": "string",
173+
"description": "Background environment details"
174+
},
175+
"composition": {
176+
"type": "string",
177+
"enum": [
178+
"rule of thirds",
179+
"circular arrangement",
180+
"framed by foreground",
181+
"minimalist negative space",
182+
"S-curve",
183+
"vanishing point center",
184+
"dynamic off-center",
185+
"leading leads",
186+
"golden spiral",
187+
"diagonal energy",
188+
"strong verticals",
189+
"triangular arrangement"
190+
],
191+
"description": "Compositional technique"
192+
},
193+
"camera": {
194+
"type": "object",
195+
"properties": {
196+
"angle": {
197+
"type": "string",
198+
"enum": ["eye level", "low angle", "slightly low", "bird's-eye", "worm's-eye", "over-the-shoulder", "isometric"],
199+
"description": "Camera perspective"
200+
},
201+
"distance": {
202+
"type": "string",
203+
"enum": ["close-up", "medium close-up", "medium shot", "medium wide", "wide shot", "extreme wide"],
204+
"description": "Framing distance"
205+
},
206+
"focus": {
207+
"type": "string",
208+
"enum": ["deep focus", "macro focus", "selective focus", "sharp on subject", "soft background"],
209+
"description": "Focus type"
210+
},
211+
"lens": {
212+
"type": "string",
213+
"enum": ["14mm", "24mm", "35mm", "50mm", "70mm", "85mm"],
214+
"description": "Focal length (wide to telephoto)"
215+
},
216+
"f-number": {
217+
"type": "string",
218+
"description": "Aperture (e.g., f/2.8, the smaller the number the more blurry the background)"
219+
},
220+
"ISO": {
221+
"type": "number",
222+
"description": "Light sensitivity value (comfortable range between 100 & 6400, lower = less sensitivity)"
223+
}
224+
}
225+
},
226+
"effects": {
227+
"type": "array",
228+
"items": { "type": "string" },
229+
"description": "Post-processing effects (e.g., 'lens flare small', 'subtle film grain', 'soft bloom', 'god rays', 'chromatic aberration mild')"
230+
}
231+
},
232+
"required": ["scene", "subjects"]
233+
}
234+
```
235+
</details>
236+
237+
## Other features to try
238+
239+
- The model also supports the most common latin and non-latin character languages
240+
- You can prompt the model with specific hex codes like `#2ECC71`
241+
- Try creating digital assets like landing pages, comic strips, infographics too!
242+
243+

src/content/docs/workers-ai/platform/pricing.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The Price in Tokens column is equivalent to the Price in Neurons column - the di
7878
| @cf/black-forest-labs/flux-1-schnell | $0.0000528 per 512x512 tile <br/> $0.0001056 per step | 4.80 neurons per 512x512 tile <br/> 9.60 neurons per step |
7979
| @cf/leonardo/lucid-origin | $0.006996 per 512x512 tile <br/> $0.000132 per step | 636.00 neurons per 512x512 tile <br/> 12.00 neurons per step |
8080
| @cf/leonardo/phoenix-1.0 | $0.005830 per 512x512 tile <br/> $0.000110 per step | 530.00 neurons per 512x512 tile <br/> 10.00 neurons per step |
81+
| @cf/black-forest-labs/flux-2-dev | $0.00021 per input 512x512 tile, per step <br/> $0.00041 per output 512x512 tile, per step | 18.75 neurons per input 512x512 tile, per step <br/> 37.50 neurons per output 512x512 tile, per step |
8182

8283
## Audio model pricing
8384

src/content/release-notes/workers-ai.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ link: "/workers-ai/changelog/"
33
productName: Workers AI
44
productLink: "/workers-ai/"
55
entries:
6+
- publish_date: "2025-11-25"
7+
title: Black Forest Labs FLUX.2 dev now available
8+
description: |-
9+
- [`@cf/black-forest-labs/flux-2-dev`](/workers-ai/models/flux-2-dev/) now available on Workers AI! Read [changelog](/changelog/2025-11-25-flux-2-dev-workers-ai/) to get started
610
- publish_date: "2025-11-13"
711
title: Qwen3 LLM and Embeddings available on Workers AI
812
description: |-
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"id": "3ae8936e-593e-4fb2-85ee-95dd8a057588",
3+
"source": 1,
4+
"name": "@cf/black-forest-labs/flux-2-dev",
5+
"description": "FLUX.2 [dev] is an image model from Black Forest Labs where you can generate highly realistic and detailed images, with multi-reference support.",
6+
"task": {
7+
"id": "3d6e1f35-341b-4915-a6c8-9a7142a9033a",
8+
"name": "Text-to-Image",
9+
"description": "Generates images from input text. These models can be used to generate and modify images based on text prompts."
10+
},
11+
"created_at": "2025-11-24 15:44:06.050",
12+
"tags": [],
13+
"properties": [
14+
{
15+
"property_id": "terms",
16+
"value": "https://bfl.ai/legal/terms-of-service"
17+
},
18+
{
19+
"property_id": "partner",
20+
"value": "true"
21+
},
22+
{
23+
"property_id": "price",
24+
"value": [
25+
{
26+
"unit": "per input 512x512 tile, per step",
27+
"price": 0.00021,
28+
"currency": "USD"
29+
},
30+
{
31+
"unit": "per output 512x512 tile, per step",
32+
"price": 0.00041,
33+
"currency": "USD"
34+
}
35+
]
36+
}
37+
],
38+
"schema":
39+
{
40+
"input": {
41+
"type": "object",
42+
"properties": {
43+
"multipart": {
44+
"type": "object",
45+
"properties": {
46+
"body": {
47+
"type": "object"
48+
},
49+
"contentType": {
50+
"type": "string"
51+
}
52+
},
53+
"required": [
54+
"body",
55+
"contentType"
56+
]
57+
},
58+
"required": [
59+
"multipart"
60+
]
61+
}
62+
},
63+
"output": {
64+
"type": "object",
65+
"properties": {
66+
"image": {
67+
"type": "string",
68+
"description": "Generated image as Base64 string."
69+
}
70+
}
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)