Skip to content

Commit 701f03b

Browse files
shridharathishridhar-cfmchencokodster28
authored
flux klein 9b docs (#27912)
* flux klein 9b docs * Update FLUX.2 klein 9B release date to Jan 28 and fix description - Rename changelog file from 2026-01-23 to 2026-01-28 - Update publish_date in workers-ai.yaml to 2026-01-28 - Update changelog link to reflect new date - Fix description to remove incorrect 'faster generation' claim - 9B offers enhanced quality vs 4B but is not faster * Simplify Workers AI binding example code Remove unnecessary formRequest, formStream, and formContentType variables. Pass FormData directly to multipart body, which is the correct and simpler approach. * Revert smart-turn-v2 and flux-2-dev to production versions Restore these model files to match what's currently on main/production branch * Update .gitignore --------- Co-authored-by: shridharathi <shridhar@cloudflare.com> Co-authored-by: mchen <mchen@cloudflare.com> Co-authored-by: Kody Jackson <kody@cloudflare.com>
1 parent 4a42895 commit 701f03b

File tree

9 files changed

+221
-4
lines changed

9 files changed

+221
-4
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: Launching FLUX.2 [klein] 9B on Workers AI
3+
description: New ultra-fast FLUX.2 [klein] 9B model on Workers AI
4+
date: 2026-01-28
5+
---
6+
7+
We have partnered with Black Forest Labs (BFL) again to bring their optimized FLUX.2 [klein] 9B model to Workers AI. This distilled model offers enhanced quality compared to the 4B variant, while maintaining cost-effective pricing. With a fixed 4-step inference process, Klein 9B is ideal for rapid prototyping and real-time applications where both speed and quality matter.
8+
9+
Read the [BFL blog](https://bfl.ai/blog) to learn more about the model itself, 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-klein-9b/) or [pricing page](/workers-ai/platform/pricing/).
12+
13+
## Workers AI platform specifics
14+
15+
The model hosted on Workers AI is optimized for speed with a **fixed 4-step inference process** and supports up to 4 image inputs. Since this is a distilled model, the `steps` parameter is fixed at 4 and cannot be adjusted. Like FLUX.2 [dev] and FLUX.2 [klein] 4B, this image model uses 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-klein-9b' \
22+
--header 'Authorization: Bearer {TOKEN}' \
23+
--header 'Content-Type: multipart/form-data' \
24+
--form 'prompt=a sunset at the alps' \
25+
--form width=1024 \
26+
--form height=1024
27+
```
28+
29+
With the Workers AI binding, you can use it as such:
30+
31+
```javascript
32+
const form = new FormData();
33+
form.append("prompt", "a sunset with a dog");
34+
form.append("width", "1024");
35+
form.append("height", "1024");
36+
37+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-klein-9b", {
38+
multipart: {
39+
body: form,
40+
contentType: "multipart/form-data",
41+
},
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+
- `guidance` (float) - Guidance scale for generation. Higher values follow the prompt more closely
60+
- `width` (integer) - Width of the image, default `1024` Range: 256-1920
61+
- `height` (integer) - Height of the image, default `768` Range: 256-1920
62+
- `seed` (integer) - Seed for reproducibility
63+
64+
**Note:** Since this is a distilled model, the `steps` parameter is fixed at 4 and cannot be adjusted.
65+
66+
</details>
67+
68+
## Multi-reference images
69+
70+
The FLUX.2 klein-9b model supports generating images based on reference images, just like FLUX.2 [dev] and FLUX.2 [klein] 4B. 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 generated images. You would use it with the same multipart form data structure, with the input images in binary. The model supports up to 4 input images.
71+
72+
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`.
73+
74+
You must name the input parameter as `input_image_0`, `input_image_1`, `input_image_2`, `input_image_3` for it to work correctly. All input images must be smaller than 512x512.
75+
76+
```bash
77+
curl --request POST \
78+
--url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT}/ai/run/@cf/black-forest-labs/flux-2-klein-9b' \
79+
--header 'Authorization: Bearer {TOKEN}' \
80+
--header 'Content-Type: multipart/form-data' \
81+
--form 'prompt=take the subject of image 1 and style it like image 0' \
82+
--form input_image_0=@/Users/johndoe/Desktop/icedoutkeanu.png \
83+
--form input_image_1=@/Users/johndoe/Desktop/me.png \
84+
--form width=1024 \
85+
--form height=1024
86+
```
87+
88+
Through Workers AI Binding:
89+
90+
```javascript
91+
//helper function to convert ReadableStream to Blob
92+
async function streamToBlob(stream: ReadableStream, contentType: string): Promise<Blob> {
93+
const reader = stream.getReader();
94+
const chunks = [];
95+
96+
while (true) {
97+
const { done, value } = await reader.read();
98+
if (done) break;
99+
chunks.push(value);
100+
}
101+
102+
return new Blob(chunks, { type: contentType });
103+
}
104+
105+
const image0 = await fetch("http://image-url");
106+
const image1 = await fetch("http://image-url");
107+
const form = new FormData();
108+
109+
const image_blob0 = await streamToBlob(image0.body, "image/png");
110+
const image_blob1 = await streamToBlob(image1.body, "image/png");
111+
form.append('input_image_0', image_blob0)
112+
form.append('input_image_1', image_blob1)
113+
form.append('prompt', 'take the subject of image 1 and style it like image 0')
114+
115+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-klein-9b", {
116+
multipart: {
117+
body: form,
118+
contentType: "multipart/form-data"
119+
}
120+
})
121+
```

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The Price in Tokens column is equivalent to the Price in Neurons column - the di
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 |
8181
| @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 |
8282
| @cf/black-forest-labs/flux-2-klein-4b | $0.000059 per input 512x512 tile <br/> $0.000287 per output 512x512 tile | 5.37 neurons per input 512x512 tile <br/> 26.05 neurons per output 512x512 tile |
83+
| @cf/black-forest-labs/flux-2-klein-9b | $0.015 per first MP (1024x1024) <br/> $0.002 per subsequent MP <br/> $0.002 per input image MP | 1363.64 neurons per first MP (1024x1024) <br/> 181.82 neurons per subsequent MP <br/> 181.82 neurons per input image MP |
8384

8485
## Audio model pricing
8586

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: "2026-01-28"
7+
title: Black Forest Labs FLUX.2 [klein] 9B now available
8+
description: |-
9+
- [`@cf/black-forest-labs/flux-2-klein-9b`](/workers-ai/models/flux-2-klein-9b/) now available on Workers AI! Read [changelog](/changelog/2026-01-28-flux-2-klein-9b-workers-ai/) to get started
610
- publish_date: "2026-01-15"
711
title: Black Forest Labs FLUX.2 [klein] 4b now available
812
description: |-

src/content/workers-ai-models/bge-base-en-v1.5.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"property_id": "async_queue",
1616
"value": "true"
1717
},
18+
{
19+
"property_id": "context_window",
20+
"value": "153600"
21+
},
1822
{
1923
"property_id": "price",
2024
"value": [

src/content/workers-ai-models/bge-m3.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"contentType": "application/json",
182182
"oneOf": [
183183
{
184-
"title": "Ouput Query",
184+
"title": "Output Query",
185185
"properties": {
186186
"response": {
187187
"type": "array",
@@ -230,7 +230,7 @@
230230
}
231231
},
232232
{
233-
"title": "Ouput Embedding",
233+
"title": "Output Embedding",
234234
"properties": {
235235
"shape": {
236236
"type": "array",
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"id": "flux-2-klein-9b-uuid",
3+
"source": 1,
4+
"name": "@cf/black-forest-labs/flux-2-klein-9b",
5+
"description": "FLUX.2 [klein] 9B is an ultra-fast, distilled image model with enhanced quality. It unifies image generation and editing in a single model, delivering state-of-the-art quality enabling interactive workflows, real-time previews, and latency-critical applications.",
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": "2026-01-23 12:00:00.000",
12+
"tags": [],
13+
"properties": [
14+
{
15+
"property_id": "partner",
16+
"value": "true"
17+
},
18+
{
19+
"property_id": "terms",
20+
"value": "https://bfl.ai/legal/terms-of-service"
21+
},
22+
{
23+
"property_id": "price",
24+
"value": [
25+
{
26+
"unit": "per first MP (1024x1024)",
27+
"price": 0.015,
28+
"currency": "USD"
29+
},
30+
{
31+
"unit": "per subsequent MP",
32+
"price": 0.002,
33+
"currency": "USD"
34+
},
35+
{
36+
"unit": "per input image MP",
37+
"price": 0.002,
38+
"currency": "USD"
39+
}
40+
]
41+
}
42+
],
43+
"schema": {
44+
"input": {
45+
"type": "object",
46+
"properties": {
47+
"multipart": {
48+
"type": "object",
49+
"properties": {
50+
"body": {
51+
"type": "object"
52+
},
53+
"contentType": {
54+
"type": "string"
55+
}
56+
}
57+
}
58+
},
59+
"required": [
60+
"multipart"
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+
}

src/content/workers-ai-models/llama-guard-3-8b.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"description": "Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks."
1010
},
1111
"created_at": "2025-01-22 23:26:23.495",
12-
"tags": [],
12+
"tags": [
13+
"moderation",
14+
"safety",
15+
"content-filtering",
16+
"guardrails"
17+
],
1318
"properties": [
1419
{
1520
"property_id": "context_window",

src/content/workers-ai-models/llamaguard-7b-awq.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"description": "Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks."
1010
},
1111
"created_at": "2024-02-06 18:13:59.060",
12-
"tags": [],
12+
"tags": [
13+
"moderation",
14+
"safety",
15+
"content-filtering",
16+
"guardrails"
17+
],
1318
"properties": [
1419
{
1520
"property_id": "beta",

src/pages/workers-ai/models/[name].astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ if (model.name === "@cf/black-forest-labs/flux-2-klein-4b") {
105105
CodeExamples = Flux2;
106106
}
107107
108+
if (model.name === "@cf/black-forest-labs/flux-2-klein-9b") {
109+
CodeExamples = Flux2;
110+
}
111+
108112
if (model.name === "@cf/openai/whisper-large-v3-turbo") {
109113
CodeExamples = WhisperBase64Code;
110114
}

0 commit comments

Comments
 (0)