Skip to content
Cloudflare Docs
Black Forest Labs logo

flux-2-dev

Text-to-ImageBlack Forest Labs
@cf/black-forest-labs/flux-2-dev

FLUX.2 [dev] is an image model from Black Forest Labs where you can generate highly realistic and detailed images, with multi-reference support.

Model Info
Terms and Licenselink
PartnerYes
Unit Pricing$0.00021 per input 512x512 tile, per step, $0.00041 per output 512x512 tile, per step

Usage

Workers - TypeScript

TypeScript
export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
const inputs = {
prompt: "cyberpunk cat",
};
const response = await env.AI.run(
"@cf/black-forest-labs/flux-2-dev",
inputs
);
return new Response(response, {
headers: {
"content-type": "image/jpg",
},
});
},
} satisfies ExportedHandler<Env>;

curl

Terminal window
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/black-forest-labs/flux-2-dev \
-X POST \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{ "prompt": "cyberpunk cat" }'

Parameters

* indicates a required field

Input

  • multipart object

    • body object required

    • contentType string required

Output

  • image string

    Generated image as Base64 string.

API Schemas

The following schemas are based on JSON Schema

{
"type": "object",
"properties": {
"multipart": {
"type": "object",
"properties": {
"body": {
"type": "object"
},
"contentType": {
"type": "string"
}
},
"required": [
"body",
"contentType"
]
},
"required": [
"multipart"
]
}
}