Skip to content

FLUX 3 Klein Edit Image ​

Endpoint ​

POST /jobs/createTask

Full URL: https://modelfold.ai/v1/jobs/createTask

Authentication: every request must include the Authorization: Bearer <API_KEY> header.

Query Task Status ​

After submitting the task, you can check the progress of the task and obtain the generated results through the unified query endpoint:

  • Get Task Details — Learn how to check the task status and obtain the generated results

TIP

In the production environment, it is recommended to use the "callBackUrl" parameter to receive the automatic notification upon completion of the generation, rather than polling the status endpoint.

Related resources

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesThe model name used for generation. This endpoint must use flux-3/klein-edit-image. Default:"flux-3/klein-edit-image"。 Allowed values:flux-3/klein-edit-image。 Example:flux-3/klein-edit-image。
callBackUrlstringNoThe URL to receive generation task completion updates. Optional but recommended for production use. The system POSTs the task status and results to this URL when generation completes.
To ensure callback security, see Webhook Verification Guide. Example:https://your-domain.com/api/callback。
inputobjectYesInput parameters for the generation task
  input.promptstringYesAn instruction describing how to edit the image (Max length: 5000 characters) minLength: 1. maxLength: 5000.
  input.image_urlsarray&lt;string&gt;YesInput images to transform or use as reference (supports up to 10 images) (File URL after upload, not file content; Accepted types: image/jpeg, image/png, image/webp; Max size: 30.0MB) minItems: 1. maxItems: 10.
  input.aspect_ratiostringNoAspect ratio of the generated image. Select auto to match the first input image ratio.
Options: 1:1; 4:3; 3:4; 3:2; 2:3; 16:9; 9:16; 21:9; 9:21; auto Default:"auto"。 Allowed values:1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21 / auto。 Example:auto。
  input.resolutionstringNoResolution of the generated image
Options: 1K; 2K; 4K Default:"1K"。 Allowed values:1K / 2K / 4K。 Example:1K。
  input.widthintegerNoWidth of the generated image. Both width and height must be passed at the same time. Must be an integer between 256 and 4096. The aspect ratio (width:height) must be between 1:2.5 and 2.5:1. Once passed, aspect_ratio and resolution are ignored. minimum: 256. maximum: 4096.
  input.heightintegerNoHeight of the generated image. Both width and height must be passed at the same time. Must be an integer between 256 and 4096. The aspect ratio (width:height) must be between 1:2.5 and 2.5:1. Once passed, aspect_ratio and resolution are ignored. minimum: 256. maximum: 4096.
  input.output_formatstringNoFormat of the output image
Options: png; jpeg; webp Default:"png"。 Allowed values:png / jpeg / webp。 Example:png。
  input.num_imagesintegerNoNumber of images to generate Default:1。 minimum: 1. maximum: 4. Example:1。
  input.seedintegerNoRandom seed minimum: 0. maximum: 2147483647.
  input.enhance_promptbooleanNoRewrites the prompt into a fuller description before generating, which noticeably improves quality. Enabled by default (also when the parameter is omitted); pass false to turn it off. Applies to both text-to-image and image editing; in editing, the rewrite preserves the intent of the original instruction. Default:true。 Allowed values:true / false。 Example:true。
  input.nsfw_checkerbooleanNoDefaults to false. When false, no additional content filtering is applied and results are returned directly by the model.

Request Example ​

bash
curl -X POST "https://modelfold.ai/v1/jobs/createTask" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "flux-3/klein-edit-image",
  "callBackUrl": "https://your-domain.com/api/callback",
  "input": {
    "prompt": "Change the backpack to dark green and keep everything else unchanged",
    "image_urls": [
      "https://example.com/input.jpg"
    ],
    "aspect_ratio": "auto",
    "resolution": "1K",
    "output_format": "png",
    "num_images": 1,
    "enhance_prompt": false
  }
}'
python
import os
import requests

resp = requests.post(
    "https://modelfold.ai/v1/jobs/createTask",
    headers={
        "Authorization": "Bearer " + os.environ["MODELFOLD_API_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "flux-3/klein-edit-image",
        "callBackUrl": "https://your-domain.com/api/callback",
        "input": {
            "prompt": "Change the backpack to dark green and keep everything else unchanged",
            "image_urls": [
                "https://example.com/input.jpg",
            ],
            "aspect_ratio": "auto",
            "resolution": "1K",
            "output_format": "png",
            "num_images": 1,
            "enhance_prompt": False,
        },
    },
)
print(resp.json())
javascript
const resp = await fetch("https://modelfold.ai/v1/jobs/createTask", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.MODELFOLD_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "flux-3/klein-edit-image",
    "callBackUrl": "https://your-domain.com/api/callback",
    "input": {
      "prompt": "Change the backpack to dark green and keep everything else unchanged",
      "image_urls": [
        "https://example.com/input.jpg"
      ],
      "aspect_ratio": "auto",
      "resolution": "1K",
      "output_format": "png",
      "num_images": 1,
      "enhance_prompt": false
    }
  }),
});
console.log(await resp.json());
go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{"model":"flux-3/klein-edit-image","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"Change the backpack to dark green and keep everything else unchanged","image_urls":["https://example.com/input.jpg"],"aspect_ratio":"auto","resolution":"1K","output_format":"png","num_images":1,"enhance_prompt":false}}`)
	req, _ := http.NewRequest("POST", "https://modelfold.ai/v1/jobs/createTask", body)
	req.Header.Set("Authorization", "Bearer " + os.Getenv("MODELFOLD_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))
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String body = "{\"model\":\"flux-3/klein-edit-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Change the backpack to dark green and keep everything else unchanged\",\"image_urls\":[\"https://example.com/input.jpg\"],\"aspect_ratio\":\"auto\",\"resolution\":\"1K\",\"output_format\":\"png\",\"num_images\":1,\"enhance_prompt\":false}}";
        HttpRequest req = HttpRequest.newBuilder()
            .uri(URI.create("https://modelfold.ai/v1/jobs/createTask"))
            .header("Authorization", "Bearer " + System.getenv("MODELFOLD_API_KEY"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .build();
        HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println(resp.body());
    }
}
php
<?php
$ch = curl_init('https://modelfold.ai/v1/jobs/createTask');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv("MODELFOLD_API_KEY"),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{"model":"flux-3/klein-edit-image","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"Change the backpack to dark green and keep everything else unchanged","image_urls":["https://example.com/input.jpg"],"aspect_ratio":"auto","resolution":"1K","output_format":"png","num_images":1,"enhance_prompt":false}}',
]);
echo curl_exec($ch);
curl_close($ch);
csharp
using System;
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://modelfold.ai/v1/jobs/createTask");
req.Headers.TryAddWithoutValidation("Authorization", "Bearer " + Environment.GetEnvironmentVariable("MODELFOLD_API_KEY"));
req.Content = new StringContent("{\"model\":\"flux-3/klein-edit-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Change the backpack to dark green and keep everything else unchanged\",\"image_urls\":[\"https://example.com/input.jpg\"],\"aspect_ratio\":\"auto\",\"resolution\":\"1K\",\"output_format\":\"png\",\"num_images\":1,\"enhance_prompt\":false}}", Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());
json
{
  "model": "flux-3/klein-edit-image",
  "callBackUrl": "https://your-domain.com/api/callback",
  "input": {
    "prompt": "Change the backpack to dark green and keep everything else unchanged",
    "image_urls": [
      "https://example.com/input.jpg"
    ],
    "aspect_ratio": "auto",
    "resolution": "1K",
    "output_format": "png",
    "num_images": 1,
    "enhance_prompt": false
  }
}

Response ​

200 — Request Successful ​

json
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_flux-3_klein-edit-image_1765175072483"
  }
}

Callback ​

onImageGenerated ​

Callback URL: {$request.body#/callBackUrl} (the callBackUrl in the request body).

Sent when the task succeeds or fails.

Callback body parameters

参数类型必填说明
codeinteger否200: success. 501: failure; see data.failCode and data.failMsg. Allowed values:200 / 501。 Example:200。
msgstring否Status message Example:Playground task completed successfully.。
dataobject否—
  data.completeTimeinteger否Task completion time, represented as a Unix timestamp in milliseconds Example:1786430358000。
  data.costTimeinteger否Processing time in seconds. Present on both success and failure callbacks. Example:8。
  data.createTimeinteger否Task creation time, represented as a Unix timestamp in milliseconds Example:1786430330000。
  data.modelstring否Image generation model used for the task Example:flux-3/klein-edit-image。
  data.paramstring否Parameters submitted when creating the task, in JSON string format Example:{"model": "flux-3/klein-edit-image", "callBackUrl": "https://your-domain.com/api/callback", "input": "{\"prompt\": \"Change the backpack to dark green and keep everything else unchanged\", \"image_urls\": [\"https://example.com/input.jpg\"], \"aspect_ratio\": \"auto\", \"resolution\": \"1K\", \"output_format\": \"png\", \"num_images\": 1, \"enhance_prompt\": false}"}。
  data.resultJsonstring否Image generation result in JSON string format. resultUrls contains the list of generated image URLs. Present only when state is success. Example:{"resultUrls": ["https://tempfile.aiquickdraw.com/js/p6/3f2a9c1d0b7e.png"]}。
  data.statestring否Task status Allowed values:success / fail。 Example:success。
  data.taskIdstring否Task ID Example:e0af60383dfdb1d6bfb6bd40d9e6f891。
  data.updateTimeinteger否Use completeTime as the completion time; updateTime may equal createTime. Example:1786430358000。
  data.failCodestring否Failure code, a numeric string such as "400" or "500". Present only when state is fail. Example:500。
  data.failMsgstring否Failure reason. Present only when state is fail. Example:&lt;error detail&gt;。

Success

json
{
  "code": 200,
  "msg": "Playground task completed successfully.",
  "data": {
    "taskId": "e0af60383dfdb1d6bfb6bd40d9e6f891",
    "model": "flux-3/klein-edit-image",
    "state": "success",
    "param": "{\"model\": \"flux-3/klein-edit-image\", \"callBackUrl\": \"https://your-domain.com/api/callback\", \"input\": \"{\\\"prompt\\\": \\\"Change the backpack to dark green and keep everything else unchanged\\\", \\\"image_urls\\\": [\\\"https://example.com/input.jpg\\\"], \\\"aspect_ratio\\\": \\\"auto\\\", \\\"resolution\\\": \\\"1K\\\", \\\"output_format\\\": \\\"png\\\", \\\"num_images\\\": 1, \\\"enhance_prompt\\\": false}\"}",
    "resultJson": "{\"resultUrls\": [\"https://tempfile.aiquickdraw.com/js/p6/3f2a9c1d0b7e.png\"]}",
    "completeTime": 1786430358000,
    "createTime": 1786430330000,
    "costTime": 8,
    "updateTime": 1786430358000
  }
}

Failure

json
{
  "code": 501,
  "msg": "Playground task failed.",
  "data": {
    "taskId": "e0af60383dfdb1d6bfb6bd40d9e6f891",
    "model": "flux-3/klein-edit-image",
    "state": "fail",
    "param": "{\"model\": \"flux-3/klein-edit-image\", \"callBackUrl\": \"https://your-domain.com/api/callback\", \"input\": \"{\\\"prompt\\\": \\\"Change the backpack to dark green and keep everything else unchanged\\\", \\\"image_urls\\\": [\\\"https://example.com/input.jpg\\\"], \\\"aspect_ratio\\\": \\\"auto\\\", \\\"resolution\\\": \\\"1K\\\", \\\"output_format\\\": \\\"png\\\", \\\"num_images\\\": 1, \\\"enhance_prompt\\\": false}\"}",
    "failCode": "500",
    "failMsg": "<error detail>",
    "completeTime": 1786430358000,
    "createTime": 1786430330000,
    "costTime": 8,
    "updateTime": 1786430358000
  }
}

ModelFold — one API for all the best AI models.