Skip to content

Commit 9efe78f

Browse files
authored
Model (#27646)
* changes are in * match replicate pricing
1 parent 926b55d commit 9efe78f

6 files changed

Lines changed: 255 additions & 42 deletions

File tree

src/components/models/code/Flux-2-Dev.astro renamed to src/components/models/code/Flux-2.astro

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ export default {
2323
form.append('width', '1024');
2424
form.append('height', '1024');
2525
26-
const formRequest = new Request('http://dummy', {
27-
method: 'POST',
28-
body: form
29-
});
30-
const formStream = formRequest.body;
31-
const formContentType = formRequest.headers.get('content-type') || 'multipart/form-data';
32-
3326
const resp = await env.AI.run("${name}", {
3427
multipart: {
3528
body: formStream,
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Launching FLUX.2 [klein] 4B on Workers AI
3+
description: New ultra-fast FLUX.2 [klein] 4B model on Workers AI
4+
date: 2025-01-15
5+
---
6+
7+
We've partnered with Black Forest Labs (BFL) again to bring their optimized FLUX.2 [klein] 4B model to Workers AI! This distilled model offers faster generation and cost-effective pricing, while maintaining great output quality. With a fixed 4-step inference process, Klein 4B is ideal for rapid prototyping and real-time applications where speed matters.
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-4b/) 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], 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-4b' \
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 formRequest = new Request("http://dummy", {
38+
method: "POST",
39+
body: form,
40+
});
41+
const formStream = formRequest.body;
42+
const formContentType =
43+
formRequest.headers.get("content-type") || "multipart/form-data";
44+
45+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-klein-4b", {
46+
multipart: {
47+
body: formStream,
48+
contentType: formContentType,
49+
},
50+
});
51+
const formStream = formRequest.body;
52+
const formContentType =
53+
formRequest.headers.get("content-type") || "multipart/form-data";
54+
55+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-klein-4b", {
56+
multipart: {
57+
body: formStream,
58+
contentType: formContentType,
59+
},
60+
});
61+
```
62+
63+
The parameters you can send to the model are detailed here:
64+
65+
<details>
66+
<summary>JSON Schema for Model</summary>
67+
**Required Parameters**
68+
69+
- `prompt` (string) - Text description of the image to generate
70+
71+
**Optional Parameters**
72+
73+
- `input_image_0` (string) - Binary image
74+
- `input_image_1` (string) - Binary image
75+
- `input_image_2` (string) - Binary image
76+
- `input_image_3` (string) - Binary image
77+
- `guidance` (float) - Guidance scale for generation. Higher values follow the prompt more closely
78+
- `width` (integer) - Width of the image, default `1024` Range: 256-1920
79+
- `height` (integer) - Height of the image, default `768` Range: 256-1920
80+
- `seed` (integer) - Seed for reproducibility
81+
82+
**Note:** Since this is a distilled model, the `steps` parameter is fixed at 4 and cannot be adjusted.
83+
84+
</details>
85+
86+
````
87+
88+
## Multi-Reference Images
89+
90+
The FLUX.2 klein-4b model supports generating images based on reference images, just like FLUX.2 [dev]. 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.
91+
92+
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`.
93+
94+
Note: you have to 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.
95+
96+
```bash
97+
curl --request POST \
98+
--url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT}/ai/run/@cf/black-forest-labs/flux-2-klein-4b' \
99+
--header 'Authorization: Bearer {TOKEN}' \
100+
--header 'Content-Type: multipart/form-data' \
101+
--form 'prompt=take the subject of image 1 and style it like image 0' \
102+
--form input_image_0=@/Users/johndoe/Desktop/icedoutkeanu.png \
103+
--form input_image_1=@/Users/johndoe/Desktop/me.png \
104+
--form width=1024 \
105+
--form height=1024
106+
````
107+
108+
Through Workers AI Binding:
109+
110+
```javascript
111+
112+
//helper function to convert ReadableStream to Blob
113+
async function streamToBlob(stream: ReadableStream, contentType: string): Promise<Blob> {
114+
const reader = stream.getReader();
115+
const chunks = [];
116+
117+
while (true) {
118+
const { done, value } = await reader.read();
119+
if (done) break;
120+
chunks.push(value);
121+
}
122+
123+
return new Blob(chunks, { type: contentType });
124+
}
125+
126+
const image0 = await fetch("http://image-url");
127+
const image1 = await fetch("http://image-url");
128+
const form = new FormData();
129+
130+
const image_blob0 = await streamToBlob(image0.body, "image/png");
131+
const image_blob1 = await streamToBlob(image1.body, "image/png");
132+
form.append('input_image_0', image_blob0)
133+
form.append('input_image_1', image_blob1)
134+
form.append('prompt', 'take the subject of image 1 and style it like image 0')
135+
136+
const resp = await env.AI.run("@cf/black-forest-labs/flux-2-klein-4b", {
137+
multipart: {
138+
body: form,
139+
contentType: "multipart/form-data"
140+
}
141+
})
142+
143+
```

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,47 @@ The Price in Tokens column is equivalent to the Price in Neurons column - the di
5454
| @cf/google/gemma-3-12b-it | $0.345 per M input tokens <br/> $0.556 per M output tokens | 31371 neurons per M input tokens <br/> 50560 neurons per M output tokens |
5555
| @cf/qwen/qwq-32b | $0.660 per M input tokens <br/> $1.000 per M output tokens | 60000 neurons per M input tokens <br/> 90909 neurons per M output tokens |
5656
| @cf/qwen/qwen2.5-coder-32b-instruct | $0.660 per M input tokens <br/> $1.000 per M output tokens | 60000 neurons per M input tokens <br/> 90909 neurons per M output tokens |
57-
| @cf/qwen/qwen3-30b-a3b-fp8 | $0.051 per M input tokens <br/> $0.335 per M output tokens | 4625 neurons per M input tokens <br/> 30475 neurons per M output tokens |
58-
| @cf/openai/gpt-oss-120b | $0.350 per M input tokens <br/> $0.750 per M output tokens | 31818 neurons per M input tokens <br/> 68182 neurons per M output tokens |
59-
| @cf/openai/gpt-oss-20b | $0.200 per M input tokens <br/> $0.300 per M output tokens | 18182 neurons per M input tokens <br/> 27273 neurons per M output tokens |
60-
| @cf/aisingapore/gemma-sea-lion-v4-27b-it | $0.351 per M input tokens <br/> $0.555 per M output tokens | 31876 neurons per M input tokens <br/> 50488 neurons per M output tokens |
61-
| @cf/ibm-granite/granite-4.0-h-micro | $0.017 per M input tokens <br/> $0.112 per M output tokens | 1542 neurons per M input tokens <br/> 10158 neurons per M output tokens |
57+
| @cf/qwen/qwen3-30b-a3b-fp8 | $0.051 per M input tokens <br/> $0.335 per M output tokens | 4625 neurons per M input tokens <br/> 30475 neurons per M output tokens |
58+
| @cf/openai/gpt-oss-120b | $0.350 per M input tokens <br/> $0.750 per M output tokens | 31818 neurons per M input tokens <br/> 68182 neurons per M output tokens |
59+
| @cf/openai/gpt-oss-20b | $0.200 per M input tokens <br/> $0.300 per M output tokens | 18182 neurons per M input tokens <br/> 27273 neurons per M output tokens |
60+
| @cf/aisingapore/gemma-sea-lion-v4-27b-it | $0.351 per M input tokens <br/> $0.555 per M output tokens | 31876 neurons per M input tokens <br/> 50488 neurons per M output tokens |
61+
| @cf/ibm-granite/granite-4.0-h-micro | $0.017 per M input tokens <br/> $0.112 per M output tokens | 1542 neurons per M input tokens <br/> 10158 neurons per M output tokens |
6262

6363
## Embeddings model pricing
6464

65-
| Model | Price in Tokens | Price in Neurons |
66-
| -------------------------- | ------------------------- | -------------------------------- |
67-
| @cf/baai/bge-small-en-v1.5 | $0.020 per M input tokens | 1841 neurons per M input tokens |
68-
| @cf/baai/bge-base-en-v1.5 | $0.067 per M input tokens | 6058 neurons per M input tokens |
69-
| @cf/baai/bge-large-en-v1.5 | $0.204 per M input tokens | 18582 neurons per M input tokens |
70-
| @cf/baai/bge-m3 | $0.012 per M input tokens | 1075 neurons per M input tokens |
71-
| @cf/pfnet/plamo-embedding-1b | $0.019 per M input tokens | 1689 neurons per M input tokens |
72-
| @cf/qwen/qwen3-embedding-0.6b | $0.012 per M input tokens | 1075 neurons per M input tokens |
65+
| Model | Price in Tokens | Price in Neurons |
66+
| ----------------------------- | ------------------------- | -------------------------------- |
67+
| @cf/baai/bge-small-en-v1.5 | $0.020 per M input tokens | 1841 neurons per M input tokens |
68+
| @cf/baai/bge-base-en-v1.5 | $0.067 per M input tokens | 6058 neurons per M input tokens |
69+
| @cf/baai/bge-large-en-v1.5 | $0.204 per M input tokens | 18582 neurons per M input tokens |
70+
| @cf/baai/bge-m3 | $0.012 per M input tokens | 1075 neurons per M input tokens |
71+
| @cf/pfnet/plamo-embedding-1b | $0.019 per M input tokens | 1689 neurons per M input tokens |
72+
| @cf/qwen/qwen3-embedding-0.6b | $0.012 per M input tokens | 1075 neurons per M input tokens |
7373

7474
## Image model pricing
7575

76-
| Model | Price in Tokens | Price in Neurons |
77-
| ------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------ |
78-
| @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 |
79-
| @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 |
80-
| @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 |
76+
| Model | Price in Tokens | Price in Neurons |
77+
| ------------------------------------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
78+
| @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 |
79+
| @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 |
80+
| @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 |
82+
| @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 |
8283

8384
## Audio model pricing
8485

85-
| Model | Price in Tokens | Price in Neurons |
86-
| ------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------ |
87-
| @cf/openai/whisper | $0.0005 per audio minute | 41.14 neurons per audio minute |
88-
| @cf/openai/whisper-large-v3-turbo | $0.0005 per audio minute | 46.63 neurons per audio minute |
89-
| @cf/myshell-ai/melotts | $0.0002 per audio minute | 18.63 neurons per audio minute |
90-
| @cf/deepgram/aura-1 | $0.015 per 1k characters input <br/> | 1,363.64 neurons per 1k characters input <br/> |
91-
| @cf/deepgram/nova-3 | $0.0052 per audio minute input <br/> | 472.73 neurons per audio minute input <br/> |
92-
| @cf/deepgram/nova-3 (WebSocket)| $0.0092 per audio minute input <br/> | 836.36 neurons per audio minute input <br/> |
93-
| @cf/pipecat-ai/smart-turn-v2 | $0.00033795 per audio minute input <br/> | 0.51 neurons per audio minute input <br/> |
94-
| @cf/deepgram/aura-2-en | $0.030 per 1k characters input <br/> | 2727.27 neurons per 1k characters input <br/> |
95-
| @cf/deepgram/aura-2-es | $0.030 per 1k characters input <br/> | 2727.27 neurons per 1k characters input <br/> |
96-
| @cf/deepgram/flux (WebSocket)| $0.0077 per audio minute <br/> | 700.00 neurons per audio minute <br/> |
86+
| Model | Price in Tokens | Price in Neurons |
87+
| --------------------------------- | ---------------------------------------- | ---------------------------------------------- |
88+
| @cf/openai/whisper | $0.0005 per audio minute | 41.14 neurons per audio minute |
89+
| @cf/openai/whisper-large-v3-turbo | $0.0005 per audio minute | 46.63 neurons per audio minute |
90+
| @cf/myshell-ai/melotts | $0.0002 per audio minute | 18.63 neurons per audio minute |
91+
| @cf/deepgram/aura-1 | $0.015 per 1k characters input <br/> | 1,363.64 neurons per 1k characters input <br/> |
92+
| @cf/deepgram/nova-3 | $0.0052 per audio minute input <br/> | 472.73 neurons per audio minute input <br/> |
93+
| @cf/deepgram/nova-3 (WebSocket) | $0.0092 per audio minute input <br/> | 836.36 neurons per audio minute input <br/> |
94+
| @cf/pipecat-ai/smart-turn-v2 | $0.00033795 per audio minute input <br/> | 0.51 neurons per audio minute input <br/> |
95+
| @cf/deepgram/aura-2-en | $0.030 per 1k characters input <br/> | 2727.27 neurons per 1k characters input <br/> |
96+
| @cf/deepgram/aura-2-es | $0.030 per 1k characters input <br/> | 2727.27 neurons per 1k characters input <br/> |
97+
| @cf/deepgram/flux (WebSocket) | $0.0077 per audio minute <br/> | 700.00 neurons per audio minute <br/> |
9798

9899
## Other model pricing
99100

@@ -102,5 +103,5 @@ The Price in Tokens column is equivalent to the Price in Neurons column - the di
102103
| @cf/huggingface/distilbert-sst-2-int8 | $0.026 per M input tokens | 2394 neurons per M input tokens |
103104
| @cf/baai/bge-reranker-base | $0.003 per M input tokens | 283 neurons per M input tokens |
104105
| @cf/meta/m2m100-1.2b | $0.342 per M input tokens <br/> $0.342 per M output tokens | 31050 neurons per M input tokens <br/> 31050 neurons per M output tokens |
105-
| @cf/microsoft/resnet-50 | $2.51 per M images | 228055 neurons per M images |
106-
| @cf/ai4bharat/indictrans2-en-indic-1B | $0.342 per M input tokens <br/> $0.342 per M output tokens | 31050 neurons per M input tokens <br/> 31050 neurons per M output tokens |
106+
| @cf/microsoft/resnet-50 | $2.51 per M images | 228055 neurons per M images |
107+
| @cf/ai4bharat/indictrans2-en-indic-1B | $0.342 per M input tokens <br/> $0.342 per M output tokens | 31050 neurons per M input tokens <br/> 31050 neurons per M output tokens |

‎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-01-15"
7+
title: Black Forest Labs FLUX.2 [klein] 4b now available
8+
description: |-
9+
- [`@cf/black-forest-labs/flux-2-klein-4b`](/workers-ai/models/flux-2-klein-4b/) now available on Workers AI! Read [changelog](/changelog/2025-01-15-flux-2-klein-4b-workers-ai/) to get started
610
- publish_date: "2025-12-03"
711
title: Deepgram Flux promotional period over on Dec 8, 2025 - now has pricing
812
description: |-

0 commit comments

Comments
 (0)