FLUX API

FLUX API and playground

Black Forest Labs’ FLUX image models, from FLUX.1 [schnell] drafts to FLUX 2 photorealism and FLUX 2 Edit. Use them in the MegaBrain playground in your browser or through the API, without a Black Forest Labs account, priced per megapixel from a prepaid US-dollar balance.

FLUX models and prices

Prices in US dollars from the MegaBrain catalogue; they update automatically. Each model’s page has examples, every parameter and a playground.

ModelTaskImage
FLUX 2
flux-2
Text to image$0.0144 per megapixel
FLUX 2 Flash
flux-2/flash
Text to image$0.006 per megapixel
FLUX 2 Edit
flux-2/edit
Image editing$0.0144 per megapixel
FLUX.1 [dev]
flux/dev
Text to image$0.03 per megapixel
FLUX.1 [schnell]
flux/schnell
Text to image$0.0036 per megapixel

Which FLUX model to pick

FLUX 2 does photorealism and accurate text in images. FLUX 2 Flash is the fast FLUX 2 for high volume. FLUX.1 [schnell] is the fastest and cheapest, 1–4 steps for drafts and previews, and FLUX.1 [dev] is the earlier high-quality model. FLUX 2 Edit changes an image from a text instruction.

Priced per megapixel

FLUX is priced per megapixel of output: a 1024×768 image is one megapixel. FLUX 2 Edit also counts the megapixels of the input images. A failed generation is not charged.

Prompts that work

Eight tested FLUX 2 prompts with their settings and what each image cost.

FLUX 2 prompting guide

First request

Generation runs through a queue: a POST request submits the job, then the script polls status_url and fetches the result from response_url. Create the key on the API key page after you sign up.

import os, time, requests

BASE = "https://getmegabrain.com/api/gateway/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MEGABRAIN_API_KEY']}"}

job = requests.post(f"{BASE}/queue/flux-2", headers=HEADERS, json={
  "prompt": "wooden matryoshka dolls on a frosty windowsill, soft morning light, photo",
  "image_size": "landscape_4_3"
}).json()

while requests.get(job["status_url"], headers=HEADERS).json()["status"] not in ("COMPLETED", "FAILED"):
    time.sleep(2)

print(requests.get(job["response_url"], headers=HEADERS).json())

Questions and answers

Is there a FLUX API?

Yes. A POST request puts the job in the generation API’s queue, then you check its status and fetch the image link; there is a Python example below. Every parameter of the model is on its page and in the generation API docs.

Do I need a Black Forest Labs account?

No. Sign up on MegaBrain and top up the balance by card: FLUX images are paid from it per megapixel, and nothing is charged for a generation that fails.

How much does one FLUX image cost?

The price per megapixel in the table times the image’s megapixels, counted in whole megapixels: a 1024×768 image is one, a 1024×1024 image is two.

Can I edit my own images?

Yes. FLUX 2 Edit takes your images as links in image_urls and changes them from a text instruction; the input images count toward the megapixels.

Get your API key

Sign-up is open. Create an account, top up the balance by card and create a key: it works for every text, image, video and audio model in the catalogue. Credits never expire.

Questions? Write to team@getmegabrain.com