Skip to content

FLUX 3 Klein Edit Image ​

接口 ​

POST /jobs/createTask

完整 URL: https://modelfold.ai/v1/jobs/createTask

鉴权:所有请求都需要 Authorization: Bearer <API_KEY> 请求头。

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

请求参数 ​

请求体 (application/json) ​

参数类型必填说明
modelstring是The model name used for generation. This endpoint must use flux-3/klein-edit-image. 默认值:"flux-3/klein-edit-image"。 可选值:flux-3/klein-edit-image。 示例:flux-3/klein-edit-image。
callBackUrlstring否The 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. 示例:https://your-domain.com/api/callback。
inputobject是Input parameters for the generation task
  input.promptstring是An instruction describing how to edit the image (Max length: 5000 characters) minLength: 1. maxLength: 5000.
  input.image_urlsarray&lt;string&gt;是Input 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_ratiostring否Aspect 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 默认值:"auto"。 可选值:1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21 / auto。 示例:auto。
  input.resolutionstring否Resolution of the generated image
Options: 1K; 2K; 4K 默认值:"1K"。 可选值:1K / 2K / 4K。 示例:1K。
  input.widthinteger否Width 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.heightinteger否Height 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_formatstring否Format of the output image
Options: png; jpeg; webp 默认值:"png"。 可选值:png / jpeg / webp。 示例:png。
  input.num_imagesinteger否Number of images to generate 默认值:1。 minimum: 1. maximum: 4. 示例:1。
  input.seedinteger否Random seed minimum: 0. maximum: 2147483647.
  input.enhance_promptboolean否Rewrites 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. 默认值:true。 可选值:true / false。 示例:true。
  input.nsfw_checkerboolean否Defaults to false. When false, no additional content filtering is applied and results are returned directly by the model.

请求示例 ​

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
  }
}

响应 ​

200 — Request Successful ​

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

回调 ​

onImageGenerated ​

回调地址:{$request.body#/callBackUrl}(即请求体里的 callBackUrl)。

Sent when the task succeeds or fails.

回调体参数

参数类型必填说明
codeinteger否200: success. 501: failure; see data.failCode and data.failMsg. 可选值:200 / 501。 示例:200。
msgstring否Status message 示例:Playground task completed successfully.。
dataobject否—
  data.completeTimeinteger否Task completion time, represented as a Unix timestamp in milliseconds 示例:1786430358000。
  data.costTimeinteger否Processing time in seconds. Present on both success and failure callbacks. 示例:8。
  data.createTimeinteger否Task creation time, represented as a Unix timestamp in milliseconds 示例:1786430330000。
  data.modelstring否Image generation model used for the task 示例:flux-3/klein-edit-image。
  data.paramstring否Parameters submitted when creating the task, in JSON string format 示例:{"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. 示例:{"resultUrls": ["https://tempfile.aiquickdraw.com/js/p6/3f2a9c1d0b7e.png"]}。
  data.statestring否Task status 可选值:success / fail。 示例:success。
  data.taskIdstring否Task ID 示例:e0af60383dfdb1d6bfb6bd40d9e6f891。
  data.updateTimeinteger否Use completeTime as the completion time; updateTime may equal createTime. 示例:1786430358000。
  data.failCodestring否Failure code, a numeric string such as "400" or "500". Present only when state is fail. 示例:500。
  data.failMsgstring否Failure reason. Present only when state is fail. 示例:&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 — 一个 API,接入所有主流 AI 模型。