Skip to main content
POST
Edit or fuse one or more reference images by instruction
Playground usage: enter your API Key in Authorization (format Bearer sk-xxx). Paste the public URL of reference image 1 into input_image; for multi-reference, fill the URLs of additional images into input_image_2input_image_8. Then fill prompt / model and send. The Playground only accepts URLs; for base64 data URL inputs, copy the code samples below and run them locally.
Use this page for “edit or fuse one or more reference images”. FLUX image editing supports two options:
  • Option A (this page’s Playground, recommended): JSON + input_image to /v1/images/generations (shared with text-to-image — sending input_image triggers edit mode). Works for all FLUX models (including Kontext, verified), and supports multi-reference fusion (input_image_2 ~ input_image_8).
  • Option B: the OpenAI-compatible multipart endpoint /v1/images/edits (see the “Option B” section below) — single-image editing, directly compatible with the OpenAI SDK’s client.images.edit().
For pure text-to-image, see the Text-to-Image endpoint.
⚠️ Key differences / notes (Option A)
  • Endpoint path: /v1/images/generations (shared with text-to-image; an OpenAI-compatible single-image /v1/images/edits endpoint also exists — see Option B)
  • Content-Type: application/json (Option B’s /edits endpoint uses multipart/form-data instead)
  • Every reference image field is a string: input_image / input_image_2input_image_8 accept a public URL (recommended) or data:image/...;base64,xxx data URL
  • Reference image cap varies by model: FLUX.2 [pro/max/flex] up to 8, FLUX.2 [klein] up to 4, FLUX.1 Kontext supports 1 natively
  • Each image ≤ 20MB or 20MP, formats png / jpg / webp
  • Input resolution: min 64×64, max 4MP; dimensions must be multiples of 16
  • Result URL is valid for only 10 minutesdata[0].url must be downloaded immediately
  • If aspect_ratio is omitted, output dimensions match the first input image
📎 Multi-reference order mattersThe numbering of input_image / input_image_2 / input_image_3is exactly the index used by “image 1 / image 2 / image 3” in your prompt:
Place the person from image 1 into the scene from image 2, applying the color palette of image 3.
Each value must be a publicly reachable URL (≤ 20MB recommended) or a data:image/png;base64,xxx data URL.

Code Examples

cURL (two-image fusion · URL)

cURL (three-image fusion · URL)

cURL (single-image edit · Kontext)

cURL (local file · base64 data URL)

Python (requests · two-image fusion)

Python (requests · local file as base64)

Python (OpenAI SDK · pass input_image via extra_body)

Node.js (fetch · multi-reference fusion)

Option B: OpenAI-Compatible Edit Endpoint (multipart)

Besides the JSON option above, FLUX image editing also supports the standard OpenAI Images API edit endpoint, directly compatible with client.images.edit() (verified 2026-07-04 with flux-kontext-max, successful generation):
  • Endpoint: POST https://api.apiyi.com/v1/images/edits
  • Content-Type: multipart/form-data (set automatically by SDKs and curl -Fdo not set it manually, or the boundary gets lost and parsing fails)
The FLUX.1 Kontext series accepts a single input image only; for multi-reference fusion use Option A (input_image ~ input_image_8). Option B is currently verified on the Kontext series.

Request Parameters (form fields)

cURL Example

Python (OpenAI SDK) Example

Node.js (fetch + FormData) Example

The response format is identical to Option A (data[0].url, a BFL signed URL valid for 10 minutes — server-side download to your own storage in production).

Which Option Should I Use?

Parameter Reference

Multi-Reference Strategies

Upload multiple shots of the same character as references — the model preserves identity features automatically. Great for ad campaigns, comic panels, fashion editorials.
One content image + one style image, with explicit reference in the prompt:
Combine objects from multiple images into one new scene:
Swap an outfit from one image to another subject:
Iterative editing: download data[0].url, feed it back as input_image in the next call with a new instruction, and refine progressively. Each round bills as one image.

Response Format

⚠️ data[0].url is valid for only 10 minutes
  • URL hosted on delivery-eu.bfl.ai / delivery-us.bfl.ai, signature expires after 10 min
  • CORS is disabled — browser fetch is blocked
  • Production must server-side download to your own OSS / CDN
  • The FLUX edit endpoint does not return b64_json — only url
Edit requests cost the same as text-to-image (per image, not per token). Multi-reference does not charge extra for additional images (unlike OpenAI gpt-image-2 editing).

FAQ

The request reached the /v1/images/edits endpoint (Option B), but the gateway couldn’t find an image in the request body. Common causes:
  1. The multipart form has no image file field, or the field name is wrong (e.g. image[], file)
  2. Content-Type: multipart/form-data was set manually without a boundary (don’t set this header yourself when using an SDK / fetch / curl)
  3. The client’s image conversion failed but the request was sent anyway (check that the image field actually contains more than 0 bytes)
  4. You meant to send an image via JSON but hit /edits — JSON + input_image goes to /v1/images/generations (Option A)

Authorizations

Authorization
string
header
required

API Key from the APIYI Console

Body

application/json
model
enum<string>
default:flux-2-pro
required

FLUX model ID. For multi-reference fusion prefer flux-2-pro / flux-2-max; for single-image edits also flux-kontext-max / flux-kontext-pro.

Available options:
flux-2-pro,
flux-2-max,
flux-2-flex,
flux-2-klein-9b,
flux-2-klein-4b,
flux-kontext-max,
flux-kontext-pro
prompt
string
required

Edit / fusion instruction. In multi-reference scenarios, refer to images by index: 'image 1' / 'image 2' / 'image 3' map to input_image / input_image_2 / input_image_3.

Example:

"Naturally blend these two images"

input_image
string
required

Public URL for reference image 1 (required). Use plain URLs in the Playground; for local code you can also pass a data:image/png;base64,xxx data URL.

Example:

"https://static.apiyi.com/apiyi-logo.png"

input_image_2
string

Public URL for reference image 2 (optional)

input_image_3
string

Public URL for reference image 3 (optional)

input_image_4
string

Public URL for reference image 4 (optional)

input_image_5
string

Public URL for reference image 5 (optional)

input_image_6
string

Public URL for reference image 6 (optional)

input_image_7
string

Public URL for reference image 7 (optional)

input_image_8
string

Public URL for reference image 8 (optional, only FLUX.2 [pro/max/flex] supports up to 8)

aspect_ratio
string

Aspect ratio, e.g. 1:1 / 16:9 / 9:16 / 4:3 / 3:4. Defaults to first input image.

seed
integer

Fix for reproducibility.

safety_tolerance
integer

Moderation level. 0 = strictest, 6 = most permissive. Default 2.

Required range: 0 <= x <= 6
output_format
enum<string>

Output format. Default jpeg.

Available options:
jpeg,
png
prompt_upsampling
boolean

Auto-upsample the prompt. Default false.

steps
integer

Only flux-2-flex. Inference steps. Default 50.

Required range: 1 <= x <= 50
guidance
number

Only flux-2-flex. Guidance scale. Default 4.5.

Required range: 1.5 <= x <= 10

Response

Image generated

created
integer
Example:

1776832476

data
object[]

Result array (single image per call)