GLM-5.2 is live — Z.AI's flagship with a 1M-token lossless contextfrom $0.900 per 1M tokens
rreAPI Docs

flux-kontext

Black Forest Labs FLUX Kontext on reAPI — async prompt-only image editing and text-to-image generation, in Pro and Max tiers, on one standard endpoint.

Black Forest Labs' FLUX Kontext on reAPI — prompt-only image editing (no masks) and text-to-image generation from one endpoint, with strong character consistency across iterative edits. Two tiers: flux-kontext-pro and flux-kontext-max. Submit returns a task id in id; poll until ready. See current pricing on the model page.

Quick example

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux-kontext-pro",
    "prompt": "Replace the background with a rainy Tokyo street at night",
    "image_urls": ["https://example.com/portrait.jpg"],
    "size": "16:9"
  }'
import requests

resp = requests.post(
    "https://reapi.ai/api/v1/images/generations",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "model": "flux-kontext-pro",
        "prompt": "Replace the background with a rainy Tokyo street at night",
        "image_urls": ["https://example.com/portrait.jpg"],
        "size": "16:9",
    },
    timeout=30,
)
print(resp.json())
const resp = await fetch('https://reapi.ai/api/v1/images/generations', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'flux-kontext-pro',
    prompt: 'Replace the background with a rainy Tokyo street at night',
    image_urls: ['https://example.com/portrait.jpg'],
    size: '16:9',
  }),
});

console.log(await resp.json());
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	body := []byte(`{
		"model": "flux-kontext-pro",
		"prompt": "Replace the background with a rainy Tokyo street at night",
		"image_urls": ["https://example.com/portrait.jpg"],
		"size": "16:9"
	}`)

	req, _ := http.NewRequest("POST",
		"https://reapi.ai/api/v1/images/generations", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	out, _ := io.ReadAll(resp.Body)
	fmt.Println(string(out))
}

Submit response

{
  "id": "task_019dfd44b7fd74168541552a3260a623",
  "model": "flux-kontext-pro",
  "status": "processing",
  "created_at": 1785323949
}

Poll GET /api/v1/tasks/{task_id} until status is completed or failed.


Authentication

Every request needs a bearer token:

Authorization: Bearer YOUR_API_KEY

Create a key from your dashboard.


Endpoint

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

Submission is asynchronous — the call returns a task id immediately and the image is retrieved by polling the Tasks API.


Tiers

Model idPositioning
flux-kontext-proFast and production-ready. Best balance of speed and quality; the sensible default for high-volume editing.
flux-kontext-maxHighest output quality, with stronger typography and prompt adherence.

Both tiers accept an identical parameter set — switching is a one-field change.


Modes

The mode is implicit in whether you send reference images. There is no mode field and no second endpoint:

InputMode
prompt onlyText-to-image
prompt + image_urls (1–4)Image editing

Request body

model — string, required

One of flux-kontext-pro, flux-kontext-max.

prompt — string, required

Description of the image to create, or the edit to apply to the reference images.

image_urls — array, optional

Up to 4 public http(s) image URLs. Presence switches the request into editing mode.

Base64 and data: URIs are rejected across the reAPI platform. Host input images at a publicly reachable URL first.

size — string, default 1:1

Output aspect ratio. Supported: 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3, 21:9, 9:21.

A pixel string such as 1300x800 is also accepted, but Kontext snaps it to the nearest supported ratio instead of producing those exact dimensions — so it gives you nothing the ratio list does not. Prefer the ratio.

Every ratio renders at approximately 1 MP, so size changes shape but never resolution or price.

width and height are not accepted by this model and are rejected with a 400. resolution is accepted but has no effect — Kontext always renders at approximately 1 MP — so it is safe to leave in a request ported over from FLUX.2, but it will not change the output.

output_format — string, default png

Encoding of the returned image: png, jpeg, or webp. Omit it to take the model's own default, which is also png.

response_format — string, optional

OpenAI-compatibility field, accepting url or b64_json. It does not change the image encoding — output_format controls that and wins when both are sent. reAPI always returns the image as a URL in output.image_urls.

n — integer, default 1

Images per request. 1 is the only supported value; submit concurrent requests when you need more.

seed — integer, optional

Fix the seed to make a generation reproducible. Omit for a random seed.

prompt_upsampling — boolean, default false

When true, the model rewrites and expands your prompt before generating. Leave it off when your wording is deliberate.

safety_tolerance — integer, default 2

Moderation strictness from 0 (strictest) to 6 (most permissive), applied to both the input and the generated output.

fallback — object, optional

reAPI may serve a request on either of two upstreams and automatically retries on the second one if the first fails to deliver. Send {"enabled": false} to disable that retry and fail fast instead:

{
  "model": "flux-kontext-pro",
  "prompt": "Change the hair color to blue",
  "fallback": { "enabled": false }
}

Your price is unaffected either way — both upstreams bill the same rate for the same request. Turning the retry off trades availability for a faster failure.


Pricing

FLUX Kontext bills a flat rate per generated image, by tier (flux-kontext-pro / flux-kontext-max). Aspect ratio is not a billing dimension — every ratio renders at ~1 MP — and editing costs the same as generating:

credits = ceil(per_image_usd × 1000)

where 1 credit = $0.001 USD. Each request produces one image. Failed and rejected requests are not charged.

The exact per-image credit cost for each tier surfaces on the model page and through the playground estimator before submit.


Response

The poll envelope returns the image URL in output.image_urls:

{
  "id": "task_019dfd44b7fd74168541552a3260a623",
  "model": "flux-kontext-pro",
  "status": "completed",
  "output": {
    "image_urls": [
      "https://cdn.reapi.ai/...png"
    ]
  }
}

Generated URLs expire — mirror them to your own storage if you need long-term retention.


Errors

Failures return the standard reAPI envelope { error: { code, message, request_id } }. Common cases:

  • Invalid input (empty prompt, more than 4 image_urls, a non-http(s) URL, safety_tolerance outside 0–6, or sending width / height) → 400. resolution is not in this list — it is accepted and ignored, as described under size.
  • Insufficient credits → 402.
  • Rate limited → 429.

See the full catalog at /docs/api/errors.


Tips

  • For text replacement, use the explicit grammar the model is tuned for: Replace 'old text' with 'new text'. Capitalisation carries through, so write the replacement exactly as it should appear.
  • State what must not change ("keep the person and their lighting unchanged"). Naming the invariant is the most reliable way to keep an edit surgical.
  • Editing runs iteratively — feed a result back in as image_urls for the next change. Character identity is designed to survive that chain.
  • Pick flux-kontext-pro for volume and latency; reach for flux-kontext-max when in-image typography has to be exactly right.
  • Output is always ~1 MP. If you need larger assets, upscale downstream or use a model that renders at higher resolution natively.

Table of Contents