Skip to content
Black Forest Labs logo

FLUX.2 [pro]

Text-to-Image • Black Forest Labs

View as MarkdownAgent setup

Model ID

Use with the Workers AI binding, the AI Gateway REST API, or the Unified API.

Calling the provider directly? Use the provider's model name instead, including with provider-native endpoints or the provider's own SDK. For example, Anthropic's name for anthropic/claude-opus-4.8 is claude-opus-4-8.

  • Third-party

FLUX.2 [pro] Preview is Black Forest Labs' recommended default for production image generation and editing — tracks the latest [pro] weights with strong multi-reference support.

Model Info
Terms and Licenselink ↗
More informationlink ↗
Pricing
  • First output megapixel$0.03
  • Per additional output megapixel$0.015
  • Per input megapixel$0.015

Usage

const response = await env.AI.run(
  'black-forest-labs/flux-2-pro-preview',
  {
    prompt:
      'A serene mountain landscape at golden hour, soft diffused light filtering through clouds',
    height: 1024,
    width: 1024,
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "black-forest-labs/flux-2-pro-preview",
  "input": {
    "prompt": "A serene mountain landscape at golden hour, soft diffused light filtering through clouds",
    "height": 1024,
    "width": 1024
  }
}'
Simple Prompt
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-pro-preview/simple-prompt.jpeg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

Examples

Multi-Reference Editing — Multi-reference editing — combine two reference images in a single composition
const response = await env.AI.run(
  'black-forest-labs/flux-2-pro-preview',
  {
    prompt: 'Combine the subjects of these images into a single editorial fashion scene',
    input_images: [
      'https://replicate.delivery/xezq/jCypj4MeXYUiRyq7nfgm8z1OvFZF81wh4FznutDsZOuJz0YWA/tmp1iukn307.jpg',
      'https://replicate.delivery/xezq/0lxxNQSg3NabCZrDiQVAPGVmjP1Q2dd7TgYCOTfI9LpyZaMLA/tmp89gopylq.jpg',
    ],
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "black-forest-labs/flux-2-pro-preview",
  "input": {
    "prompt": "Combine the subjects of these images into a single editorial fashion scene",
    "input_images": [
      "https://replicate.delivery/xezq/jCypj4MeXYUiRyq7nfgm8z1OvFZF81wh4FznutDsZOuJz0YWA/tmp1iukn307.jpg",
      "https://replicate.delivery/xezq/0lxxNQSg3NabCZrDiQVAPGVmjP1Q2dd7TgYCOTfI9LpyZaMLA/tmp89gopylq.jpg"
    ]
  }
}'
Multi-Reference Editing
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-pro-preview/multi-reference-editing.jpeg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}
Reproducible PNG Output — Seeded generation with PNG output for downstream editing pipelines
const response = await env.AI.run(
  'black-forest-labs/flux-2-pro-preview',
  { prompt: 'A pastel watercolor of a koi pond at sunrise', output_format: 'png', seed: 1337 },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "black-forest-labs/flux-2-pro-preview",
  "input": {
    "prompt": "A pastel watercolor of a koi pond at sunrise",
    "output_format": "png",
    "seed": 1337
  }
}'
Reproducible PNG Output
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-pro-preview/reproducible-png-output.png"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

Parameters

prompt
stringrequiredText prompt for image generation or editing.
seed
integerminimum: -9007199254740991maximum: 9007199254740991Optional seed for reproducible generation.
width
integerminimum: 64maximum: 9007199254740991Width of the generated image in pixels (minimum 64). Omit to let BFL pick.
height
integerminimum: 64maximum: 9007199254740991Height of the generated image in pixels (minimum 64). Omit to let BFL pick.
safety_tolerance
integerminimum: 0maximum: 5Tolerance for input/output moderation. 0 is the strictest, 5 the most permissive. Defaults to 2.
output_format
stringenum: jpeg, png, webpOutput image format. Defaults to jpeg.
image
stringformat: uriURL to the generated image

API Schemas (Raw)

Input
Output

Was this helpful?