Skip to content
Black Forest Labs logo

FLUX.2 [flex]

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 [flex] is Black Forest Labs' fine-grained control variant of FLUX.2 — exposes tunable inference steps, guidance, and prompt upsampling for typography-heavy and production workflows.

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

Usage

const response = await env.AI.run(
  'black-forest-labs/flux-2-flex',
  {
    prompt:
      "Samsung Galaxy S25 Ultra product advertisement, 'Ultra-strong titanium' headline, close-up of phone edge showing titanium frame, dark gradient background, clean minimalist tech aesthetic",
  },
)
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-flex",
  "input": {
    "prompt": "Samsung Galaxy S25 Ultra product advertisement, '\''Ultra-strong titanium'\'' headline, close-up of phone edge showing titanium frame, dark gradient background, clean minimalist tech aesthetic"
  }
}'
Typography & Design
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-flex/typography-design.jpeg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

Examples

High Detail Generation — Crank steps and guidance for maximum detail when latency is not the priority
const response = await env.AI.run(
  'black-forest-labs/flux-2-flex',
  {
    prompt: 'A detailed oil painting portrait of a Renaissance nobleman with intricate lace collar',
    guidance: 7.5,
    steps: 50,
  },
)
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-flex",
  "input": {
    "prompt": "A detailed oil painting portrait of a Renaissance nobleman with intricate lace collar",
    "guidance": 7.5,
    "steps": 50
  }
}'
High Detail Generation
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-flex/high-detail-generation.jpeg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}
Fast Draft — Fast draft with prompt upsampling disabled — preserves the literal prompt
const response = await env.AI.run(
  'black-forest-labs/flux-2-flex',
  { prompt: 'A simple line sketch of a mountain landscape', prompt_upsampling: false, steps: 10 },
)
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-flex",
  "input": {
    "prompt": "A simple line sketch of a mountain landscape",
    "prompt_upsampling": false,
    "steps": 10
  }
}'
Fast Draft
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-flex/fast-draft.jpeg"
  },
  "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.
prompt_upsampling
booleanWhether BFL should expand short prompts before generation. Defaults to true on flex.
guidance
numberminimum: 1.5maximum: 10Classifier-free guidance scale (1.5–10). Higher values follow the prompt more strictly at the cost of realism.
steps
integerminimum: 1maximum: 50Number of denoising steps (1–50). Higher steps yield more detail at the cost of latency.
image
stringformat: uriURL to the generated image

API Schemas (Raw)

Input
Output

Was this helpful?