> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magnific.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FLUX.2 Flex - Text To Image API | Magnific API

> Generate professional-grade images from text with FLUX.2 Flex. Fine-grained control over guidance and steps, 256-1920px dimensions and up to 4 input images.

<Card title="Black Forest Labs FLUX.2 [flex]" icon="wand-magic-sparkles">
  Flexible, professional-grade image generation with fine-grained control over guidance, steps, and a wide resolution range for large-format output.
</Card>

FLUX.2 Flex is a text-to-image API that generates professional-grade images with fine-grained control. Developed by Black Forest Labs, it offers adjustable guidance and inference steps plus a wide resolution range from 256 to 1920 pixels per side for large-format output. It also accepts up to 4 optional input images for image-to-image generation and editing, and produces PNG or JPEG output.

### Key capabilities

* **Custom resolution**: Set exact `width` and `height` from 256 to 1920 pixels per side
* **Fine-grained control**: Adjustable guidance scale (1.5-10) and inference steps (1-50) for quality tuning
* **Image-to-image**: Provide up to 4 reference images (`input_image`, `input_image_2`, `input_image_3`, `input_image_4`) for editing and style transfer
* **Prompt upsampling**: Optional automatic prompt enhancement for more creative outputs
* **Safety control**: Adjustable moderation tolerance from 0 (most strict) to 5 (least strict)
* **Seed control**: Optional seed (0 to 4,294,967,295) that influences generation
* **Output formats**: PNG (lossless) or JPEG (compressed)
* **Async processing**: Webhook notifications or polling for task completion

### Use cases

* **Marketing and advertising**: Generate product visuals and campaign imagery from descriptions
* **Large-format output**: Produce high-resolution images for print and display up to 1920px per side
* **Content creation**: Create unique illustrations and graphics for blogs, social media, and websites
* **Image editing**: Refine and restyle existing images using up to 4 reference inputs
* **E-commerce**: Generate product mockups and lifestyle imagery at scale

### Generate images with FLUX.2 Flex

Create images by submitting a request to the API. The service returns a task ID for async polling or webhook notification.

<div className="my-11">
  <Columns cols={2}>
    <Card title="POST /v1/ai/text-to-image/flux-2-flex" icon="wand-magic-sparkles" href="/api-reference/text-to-image/flux-2-flex/generate">
      Create a new image generation task
    </Card>

    <Card title="GET /v1/ai/text-to-image/flux-2-flex" icon="list" href="/api-reference/text-to-image/flux-2-flex/flux-2-flex-tasks">
      List all FLUX.2 Flex tasks with status
    </Card>

    <Card title="GET /v1/ai/text-to-image/flux-2-flex/{task-id}" icon="magnifying-glass" href="/api-reference/text-to-image/flux-2-flex/task-by-id">
      Get task status and results by ID
    </Card>
  </Columns>
</div>

### Parameters

| Parameter           | Type      | Required | Default | Description                                                           |
| ------------------- | --------- | -------- | ------- | --------------------------------------------------------------------- |
| `prompt`            | `string`  | Yes      | -       | Text description of the image to generate                             |
| `width`             | `integer` | No       | `1024`  | Image width in pixels (256-1920)                                      |
| `height`            | `integer` | No       | `768`   | Image height in pixels (256-1920)                                     |
| `seed`              | `integer` | No       | random  | Seed that influences generation (0-4,294,967,295)                     |
| `guidance`          | `number`  | No       | `3.0`   | Guidance scale (1.5-10), higher values follow the prompt more closely |
| `steps`             | `integer` | No       | `50`    | Inference steps (1-50), more steps produce higher quality             |
| `prompt_upsampling` | `boolean` | No       | `false` | Enable automatic prompt enhancement for creative results              |
| `safety_tolerance`  | `integer` | No       | `5`     | Content moderation: 0 (strict) to 5 (lenient)                         |
| `output_format`     | `string`  | No       | -       | Output format: `jpeg` or `png`                                        |
| `input_image`       | `string`  | No       | -       | Base64-encoded reference image for image-to-image generation          |
| `input_image_2`     | `string`  | No       | -       | Second base64-encoded reference image                                 |
| `input_image_3`     | `string`  | No       | -       | Third base64-encoded reference image                                  |
| `input_image_4`     | `string`  | No       | -       | Fourth base64-encoded reference image                                 |
| `webhook_url`       | `string`  | No       | -       | URL for completion notification                                       |

<Note>
  `width` and `height` are floored to the nearest multiple of 16 by the provider. For example, `300x500` is generated as `288x496`. Choose multiples of 16 for exact dimensions.
</Note>

<Warning>
  Generated image URLs are signed and expire quickly (around 10-15 minutes). Download or store the output promptly; do not treat the URL as a permanent link.
</Warning>

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What is FLUX.2 Flex and how does it work?">
    FLUX.2 Flex is a professional-grade text-to-image model by Black Forest Labs with fine-grained control over resolution, guidance, and steps. You submit a text prompt via the API, optionally include up to 4 reference images, receive a task ID immediately, then poll for results or receive a webhook notification when processing completes.
  </Accordion>

  <Accordion title="What resolutions does FLUX.2 Flex support?">
    FLUX.2 Flex uses explicit `width` and `height` parameters, each accepting 256 to 1920 pixels. The default is 1024×768. Common sizes include 1024×1024 (square), 1920×1080 (16:9 landscape), and 1080×1920 (9:16 portrait). Higher total resolution increases generation cost.
  </Accordion>

  <Accordion title="How do reference images work in FLUX.2 Flex?">
    You can provide up to 4 Base64-encoded reference images using `input_image`, `input_image_2`, `input_image_3`, and `input_image_4`. The model uses these for image-to-image generation, editing, and style transfer while still following your text prompt. Supported input formats are JPEG, PNG, and WebP.
  </Accordion>

  <Accordion title="How do guidance and steps affect the output?">
    The `guidance` parameter (1.5-10, default 3.0) controls how closely the model follows your prompt; higher values produce images more faithful to the description. The `steps` parameter (1-50, default 50) controls quality: more steps produce finer detail but take longer to process.
  </Accordion>

  <Accordion title="Does the same seed produce identical images?">
    The `seed` influences generation and helps you steer toward similar results, but identical output for an identical seed is not guaranteed. Setting `prompt_upsampling` to `true` makes runs inherently non-reproducible, since the prompt is rewritten on each call.
  </Accordion>

  <Accordion title="What is the difference between FLUX.2 Flex and FLUX.2 Klein?">
    FLUX.2 Flex offers fine-grained control with custom resolution up to 1920px per side, ideal for large-format and professional output. FLUX.2 Klein is optimized for speed with sub-second generation. Choose FLUX.2 Flex when control and resolution matter; choose FLUX.2 Klein when speed is critical.
  </Accordion>

  <Accordion title="What are the rate limits for FLUX.2 Flex?">
    See [Rate Limits](/ratelimits) for current limits by subscription tier.
  </Accordion>

  <Accordion title="How much does FLUX.2 Flex cost?">
    See [Pricing](/pricing) for detailed rates and subscription options.
  </Accordion>
</AccordionGroup>

## Best practices

* **Prompt writing**: Be specific about subjects, scenes, lighting, atmosphere, and art style for better results
* **Resolution choice**: Set `width` and `height` for your target format; higher resolution increases cost
* **Guidance tuning**: Start with the default guidance (3.0) and increase for more literal prompt adherence
* **Reference images**: Use high-quality inputs when doing image-to-image or style transfer
* **Production integration**: Use webhooks instead of polling for scalable applications
* **Error handling**: Implement retry logic with exponential backoff for 503 errors

## Related APIs

* **[FLUX.2 Klein](/api-reference/text-to-image/flux-2-klein/overview)**: Fastest FLUX.2 model for sub-second generation
* **[FLUX.2 Pro](/api-reference/text-to-image/post-flux-2-pro)**: High-quality generation for premium results
* **[Flux Kontext Max](/api-reference/text-to-image/flux-kontext-max/overview)**: Context-aware image editing with maximum prompt adherence
