# FLUX 3 Image (https://reapi.ai/docs/flux-3-image)

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

**FLUX 3 Image** creates or edits one image from a prompt and optional references.
Use `model: "flux-3-image"` with `POST /api/v1/images/generations`, then poll
`GET /api/v1/tasks/:id` until the task completes or fails. For moving images,
use the separate [FLUX 3 Video reference](/docs/flux-3). See the
[model page for current pricing](/models/flux-3-image#pricing).

## Quickstart

<Tabs items={['cURL', 'Python', 'Node.js', 'Go']}>
  <Tab value="cURL">
    ```bash
    curl https://api.reapi.ai/v1/images/generations \
      -H "Authorization: Bearer $REAPI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "flux-3-image",
        "prompt": "A studio photograph of a small amber glass vase on an ivory ceramic pedestal, soft daylight, no text.",
        "resolution": "768sq",
        "aspect_ratio": "1:1",
        "grounding": false
      }'
    ```
  </Tab>

  <Tab value="Python">
    ```python
    import json
    import os
    import urllib.request

    payload = {
        "model": "flux-3-image",
        "prompt": "A studio photograph of an amber glass vase, soft daylight.",
        "resolution": "768sq",
        "aspect_ratio": "1:1",
        "grounding": False,
    }
    request = urllib.request.Request(
        "https://api.reapi.ai/v1/images/generations",
        data=json.dumps(payload).encode(),
        headers={"Authorization": "Bearer " + os.environ["REAPI_API_KEY"],
                 "Content-Type": "application/json"},
    )
    with urllib.request.urlopen(request, timeout=120) as response:
        task = json.load(response)
    print(task["id"])
    ```
  </Tab>

  <Tab value="Node.js">
    ```javascript
    const response = await fetch('https://api.reapi.ai/v1/images/generations', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.REAPI_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: 'flux-3-image',
        prompt: 'A studio photograph of an amber glass vase, soft daylight.',
        resolution: '768sq',
        aspect_ratio: '1:1',
        grounding: false,
      }),
    });
    const task = await response.json();
    if (!response.ok) throw new Error(JSON.stringify(task.error));
    console.log(task.id);
    ```
  </Tab>

  <Tab value="Go">
    ```go
    package main

    import (
        "bytes"
        "encoding/json"
        "fmt"
        "io"
        "net/http"
        "os"
        "time"
    )

    func main() {
        body, err := json.Marshal(map[string]any{
            "model": "flux-3-image",
            "prompt": "A studio photograph of an amber glass vase, soft daylight.",
            "resolution": "768sq", "aspect_ratio": "1:1", "grounding": false,
        })
        if err != nil { panic(err) }
        req, err := http.NewRequest("POST", "https://api.reapi.ai/v1/images/generations", bytes.NewReader(body))
        if err != nil { panic(err) }
        req.Header.Set("Authorization", "Bearer " + os.Getenv("REAPI_API_KEY"))
        req.Header.Set("Content-Type", "application/json")
        resp, err := (&http.Client{Timeout: 120 * time.Second}).Do(req)
        if err != nil { panic(err) }
        defer resp.Body.Close()
        result, err := io.ReadAll(resp.Body)
        if err != nil { panic(err) }
        if resp.StatusCode >= 400 { panic(string(result)) }
        fmt.Println(string(result))
    }
    ```
  </Tab>
</Tabs>

## Endpoint

`POST https://api.reapi.ai/v1/images/generations`

Send `Authorization: Bearer YOUR_API_KEY` and `Content-Type: application/json`.
The response is JSON.

## Parameters

| Field              | Type      | Required | Default | Accepted values                                                              |
| ------------------ | --------- | -------- | ------- | ---------------------------------------------------------------------------- |
| `model`            | string    | Yes      | —       | `flux-3-image`                                                               |
| `prompt`           | string    | Yes      | —       | Non-empty scene or editing instruction; optional box table inside the string |
| `image_urls`       | string\[] | No       | None    | Up to 10 public HTTP(S) image URLs; order is significant                     |
| `aspect_ratio`     | string    | No       | `auto`  | See the ratio list below; `16x9` notation also accepted                      |
| `size`             | string    | No       | —       | Compatibility alias for `aspect_ratio`, not pixel dimensions                 |
| `resolution`       | string    | No       | `1k`    | `768sq`, `1k`, `1.5k`, `2k`, `4k`; case-insensitive; `768` aliases `768sq`   |
| `safety_tolerance` | integer   | No       | `2`     | `0`–`4`; higher values are more permissive                                   |
| `grounding`        | boolean   | No       | `true`  | Enable web and image search context; `false` disables it                     |
| `n`                | integer   | No       | `1`     | Only `1`                                                                     |

The website playground allows `safety_tolerance` values `0`–`1`, with a
default of `1`. Values `2`–`4` require an API key; API requests keep the
documented default of `2`.

Supported aspect ratios: `auto`, `21:9`, `2:1`, `16:9`, `3:2`, `7:5`, `4:3`,
`5:4`, `1:1`, `4:5`, `3:4`, `5:7`, `2:3`, `9:16`, `1:2`, `9:21`.
With references, `auto` uses the first reference's ratio; without them, it uses
the prompt to infer a ratio and falls back to square.

Prefer either `aspect_ratio` or `size`. When both are supplied, their normalized
values must match. For example, `aspect_ratio: "16:9"` with `size: "16x9"` is
valid; `size: "1024x1024"` is not. Resolution names describe tiers, so do not
assume a fixed width and height for every aspect ratio.

No base64 or data URLs are accepted. This endpoint does not expose `seed`,
`width`, `height`, `steps`, `guidance`, `output_format`, `negative_prompt`,
`prompt_upsampling`, `mask_url`, or `nsfw_check`. Unknown fields are rejected.

## Reference editing

Supply one or more URLs and describe what should change and what should stay.
References are indexed from zero: `ref_image_0` is the first URL,
`ref_image_1` is the second. Keep their order stable, including repeated images.

```json
{
  "model": "flux-3-image",
  "prompt": "Use ref_image_0 as the room. Replace the chair beside the window with the chair from ref_image_1. Keep the window, floor, and camera angle unchanged.",
  "image_urls": ["https://example.com/room.jpg", "https://example.com/chair.jpg"],
  "resolution": "1k",
  "grounding": false
}
```

Replace the illustrative URLs with publicly accessible images you can use.
Inspect the output; preservation of every untouched pixel is not guaranteed.

## Bounding-box prompts

There is no separate `bbox` request field. Add named elements and the JSON
table **inside the prompt string**. Coordinates are normalized
`[top, left, bottom, right]` on a 0–1000 grid, not pixel coordinates. Boxes guide
placement; they are not strict masks.

For text-to-image layout, each entry has `id`, `bbox`, and `desc`:

```text
An ivory product poster with a small amber bottle <bottle> in the lower-right
area and generous empty space on the left.
[{"id":"bottle","bbox":[350,600,900,900],"desc":"small amber glass bottle"}]
```

For editing, entries have `id`, `from`, `src_bbox`, `tgt_bbox`, and `desc`.
`from` identifies a reference, or is `null` for a new element. `src_bbox` is
`null` when `from` is `null`:

```text
Keep the scene from ref_image_0. Add a small amber bottle <bottle> on the right.
[{"id":"bottle","from":null,"src_bbox":null,"tgt_bbox":[350,600,900,900],"desc":"small amber glass bottle"}]
```

These are format illustrations, not guarantees of exact placement. For reference
roles, source-to-target edits, and practical inspection steps, read the
[FLUX 3 Image editing guide](/blog/flux-3-image-editing-guide).

## Polling and output

Submission returns a task ID. Poll that same task; do not submit a second
request just because the first is still processing.

```bash
curl https://api.reapi.ai/v1/tasks/task_your_id \
  -H "Authorization: Bearer $REAPI_API_KEY"
```

A completed task contains one URL in `output.image_urls` and its charge in
`usage.credits`. A failed task contains `error.code` and `error.message`.
Only use output after `status` is `completed`. 4K work can
take several minutes; allow a ten-minute polling window, then check the
existing task again rather than blindly resubmitting. Polling is not billed.

## Pricing

Billing is **per completed image, by resolution**. The five tiers are 768SQ,
1K, 1.5K, 2K, and 4K. Reference-image count, aspect ratio, and grounding do not
add separate charges for this model. The billing shape is:

```text
credits = ceil(current per-image USD rate for the resolution × 1,000)
```

Account pricing or membership discounts may affect the current rate. See the
[live pricing table and playground estimate](/models/flux-3-image#pricing)
for your current quote. Failed generations are refunded. A new submission
creates a new task and can incur a new charge, even if the prompt is identical.

## Errors and troubleshooting

Errors use the shared envelope `{ error: { code, message, request_id } }`.
Check [error codes](/docs/api/errors) for the complete catalog.

| Code            | Meaning                                         |
| --------------- | ----------------------------------------------- |
| `10001`–`10004` | Missing, malformed, invalid, or revoked API key |
| `20002`         | Required parameter missing                      |
| `20003`         | Invalid parameter value, range, or type         |
| `20004`         | Unsupported model on this endpoint              |
| `30001`         | Insufficient credits                            |
| `80001`         | Submission failed                               |
| `80002`         | Task polling deadline reached                   |
| `80003`         | Terminal generation failure                     |
| `80004`         | Completed task has no output URL                |

## Tips

* Validation errors: check model ID, field names, ratio aliases, resolution,
  reference count, and real boolean values rather than quoted strings.
* Unreadable references: use public HTTP(S) URLs that do not need cookies or
  authentication, and confirm that they return an image.
* Moderation or generation failure: inspect the task error; do not repeatedly
  submit the same failing request.
* Slow 4K work: keep polling the same task ID. A client polling timeout alone
  does not establish that the generation failed.

## Related

* [FLUX 3 Image playground](/models/flux-3-image)
* [Reference editing and bounding boxes](/blog/flux-3-image-editing-guide)
* [FLUX.2 Pro](/docs/flux-2-pro)
* [FLUX 3 Video](/docs/flux-3)
