Flux1 AIDevelopers
Flux1 AI API docs

Generations

Create a generation, poll it, list your history. One request shape for every model.

A generation is one request to one model. Its id (prefixed gen_) is also returned as the x-request-id response header and is what you quote to support.

Create a generation

POST /v1/generations

Returns 202 Accepted and a generation object. Check its status, credits and credits_refunded; a replay can return a completed generation, and a submission that was immediately refunded can already be failed.

FieldTypeRequiredNotes
modelstringyesOne of the ids from Models.
promptstringyes1–3,000 characters for Seedream 5.0 Lite; 1–5,000 for Nano Banana models.
imagesstring[]noReference images for editing, up to the model's max_images. Seedream accepts HTTPS URLs; Nano Banana also accepts data:image/…;base64, URIs.
aspect_ratiostringnoModel dependent, e.g. 1:1, 16:9, auto. Defaults to the model's default.
resolutionstringno1K, 2K or 4K where the model supports it; changes the price.
qualitystringnoSeedream 5.0 Lite: basic (2K, default), high (3K), ultra (4K).
output_formatstringnoSeedream 5.0 Lite: png (default) or jpeg.

All request fields are top-level, alongside model. Seedream 5.0 Lite rejects unknown fields; Nano Banana models ignore them. See each model reference for its exact contract. Validation failures return 400 invalid_request with an issues array naming each field.

Image editing with a reference image
curl https://flux1.ai/api/v1/generations \
  -H "Authorization: Bearer $FLUX1_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: portrait-edit-6ee93274-535c-47da-af94-395ac1b92327" \
  -d '{
    "model": "nano-banana-pro",
    "prompt": "replace the background with a quiet forest, keep the person unchanged",
    "images": ["https://example.com/portrait.jpg"],
    "aspect_ratio": "4:5",
    "resolution": "2K"
  }'

Retry safely with Idempotency-Key

Send an Idempotency-Key header when creating a generation. Generate one unique value per intended generation and keep that value and the JSON body unchanged across retries. A UUID works well. The header is optional; requests without it are independent and may each generate an image and spend credits.

  • Keys contain 1–128 printable ASCII characters without spaces. Each API key has its own namespace; changing your API key starts a separate namespace.
  • The first reserved request owns the key. Repeated requests return the original generation ID and its current state, without another debit or provider submission. x-request-id is also the original ID. Concurrent retries can initially see queued with credits: 0 while the first request is preparing its debit.
  • Reusing a key with a different JSON body returns 409 idempotency_conflict. Object property order does not matter; array order, prompt whitespace, omitted versus explicit defaults, and otherwise ignored fields do matter. The fingerprint covers the full input, including inline images and prompt text omitted from the usage log.
  • A recorded pre-debit rejection, such as insufficient credits, keeps its original error and request ID on retry. After fixing that condition, use a new key for a new attempt. Validation failures or concurrency rejection before a reservation do not claim the key.
  • Keys are retained with request records for at least 180 days. After a terminal record is removed, its key can be treated as new. Pending requests and unresolved recovery records remain protected from cleanup.
  • Replays still require an active API key and current whitelist access, and count toward request rate limits. They do not use an additional concurrent generation slot.

On a timeout or 500 / 502 / 503, retry with the same key and body, or query the generation ID if you received one. Do not switch to a new key merely because a response was lost. If provider acceptance cannot be confirmed, the original request remains under review; retries do not resend it to the provider.

Get a generation

GET /v1/generations/{id}

Returns the current state. The body has the same shape at every stage. credits records the actual debit and stays at that amount after a refund; credits_refunded records whether the refund completed.

statusMeaningWhat to do
queuedSubmission, generation, persistence recovery, or a refund is still pending.Poll again in 2–3 s.
succeededDone. output.images[] holds stable URLs on r2.flux1.ai.Download or display.
failedGeneration failed, submission was refunded, or an unresolved submission needs review.Read error.message and credits_refunded. Contact support for unresolved submissions before starting another generation.
rejectedThe request never became a job (validation, credits, limits). Nothing was charged.Fix the request; see error.code.
Failed generation
{
  "id": "gen_5Qa9…",
  "status": "failed",
  "credits": 10,
  "credits_refunded": true,
  "output": null,
  "error": { "code": "generation_failed", "message": "model error" },

}

completed_at is recorded when we observe the result, so it is accurate to within your polling interval.

List generations

GET /v1/generations

Your account's requests, newest first, including rejected ones. Cursor-paginated.

QueryNotes
limit1–100, default 20.
cursorOpaque next_cursor from the previous page.
statusComma-separated: queued,succeeded,failed,rejected.
modelFilter by model id.
curl "https://flux1.ai/api/v1/generations?limit=20&status=failed" \
  -H "Authorization: Bearer $FLUX1_API_KEY"
Response
{
  "data": [ { "id": "gen_…", "status": "failed",  } ],
  "next_cursor": "eyJ0IjoiMjAyNi0wOS0wNlQwMjo1ODowMS4wMDBaIiwiaWQiOiJnZW5f…"
}

next_cursor is null on the last page.