FLUX 3 Klein Text to 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
- Market Overview — View all available models
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name used for generation. This endpoint must use flux-3/klein-text-to-image. Default:"flux-3/klein-text-to-image"。 Allowed values:flux-3/klein-text-to-image。 Example:flux-3/klein-text-to-image。 |
callBackUrl | string | No | 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. Example: https://your-domain.com/api/callback。 |
input | object | Yes | Input parameters for the generation task |
input.prompt | string | Yes | A text description of the image you want to generate (Max length: 5000 characters) minLength: 1. maxLength: 5000. |
input.aspect_ratio | string | No | Aspect ratio of the generated image Options: 1:1; 4:3; 3:4; 3:2; 2:3; 16:9; 9:16; 21:9; 9:21 Default: "1:1"。 Allowed values:1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21。 Example:1:1。 |
input.resolution | string | No | Resolution of the generated image Options: 1K; 2K; 4K Default: "1K"。 Allowed values:1K / 2K / 4K。 Example:1K。 |
input.width | integer | No | Image width. Both width and height must be passed at the same time. Aspect ratio must be between 1:2.5 and 2.5:1. Once passed, aspect_ratio and resolution are ignored. minimum: 256. maximum: 4096. |
input.height | integer | No | Image height. Both width and height must be passed at the same time. Aspect ratio must be between 1:2.5 and 2.5:1. Once passed, aspect_ratio and resolution are ignored. minimum: 256. maximum: 4096. |
input.output_format | string | No | Format of the output image Options: png; jpeg; webp Default: "png"。 Allowed values:png / jpeg / webp。 Example:png。 |
input.num_images | integer | No | Number of images to generate Default:1。 minimum: 1. maximum: 4. Example:1。 |
input.seed | integer | No | Random seed minimum: 0. maximum: 2147483647. |
input.enhance_prompt | boolean | No | 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. Default:true。 Allowed values:true / false。 Example:true。 |
input.nsfw_checker | boolean | No | Defaults 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-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "1K",
"output_format": "png",
"num_images": 1,
"enhance_prompt": true
}
}'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-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "1K",
"output_format": "png",
"num_images": 1,
"enhance_prompt": True,
},
},
)
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-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "1K",
"output_format": "png",
"num_images": 1,
"enhance_prompt": true
}
}),
});
console.log(await resp.json());go
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"model":"flux-3/klein-text-to-image","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field","aspect_ratio":"16:9","resolution":"1K","output_format":"png","num_images":1,"enhance_prompt":true}}`)
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-text-to-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field\",\"aspect_ratio\":\"16:9\",\"resolution\":\"1K\",\"output_format\":\"png\",\"num_images\":1,\"enhance_prompt\":true}}";
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-text-to-image","callBackUrl":"https://your-domain.com/api/callback","input":{"prompt":"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field","aspect_ratio":"16:9","resolution":"1K","output_format":"png","num_images":1,"enhance_prompt":true}}',
]);
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-text-to-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field\",\"aspect_ratio\":\"16:9\",\"resolution\":\"1K\",\"output_format\":\"png\",\"num_images\":1,\"enhance_prompt\":true}}", Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());json
{
"model": "flux-3/klein-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "1K",
"output_format": "png",
"num_images": 1,
"enhance_prompt": true
}
}Response
200 — Request Successful
json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_flux-3_klein-text-to-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
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | 200: success. 501: failure; see data.failCode and data.failMsg. Allowed values:200 / 501。 Example:200。 |
msg | string | 否 | Status message Example:Playground task completed successfully.。 |
data | object | 否 | — |
data.completeTime | integer | 否 | Task completion time, represented as a Unix timestamp in milliseconds Example:1786430358000。 |
data.costTime | integer | 否 | Processing time in seconds. Present on both success and failure callbacks. Example:8。 |
data.createTime | integer | 否 | Task creation time, represented as a Unix timestamp in milliseconds Example:1786430330000。 |
data.model | string | 否 | Image generation model used for the task Example:flux-3/klein-text-to-image。 |
data.param | string | 否 | Parameters submitted when creating the task, in JSON string format Example:{"model": "flux-3/klein-text-to-image", "callBackUrl": "https://your-domain.com/api/callback", "input": "{\"prompt\": \"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field\", \"aspect_ratio\": \"16:9\", \"resolution\": \"1K\", \"output_format\": \"png\", \"num_images\": 1, \"enhance_prompt\": true}"}。 |
data.resultJson | string | 否 | 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.state | string | 否 | Task status Allowed values:success / fail。 Example:success。 |
data.taskId | string | 否 | Task ID Example:e0af60383dfdb1d6bfb6bd40d9e6f891。 |
data.updateTime | integer | 否 | Use completeTime as the completion time; updateTime may equal createTime. Example:1786430358000。 |
data.failCode | string | 否 | Failure code, a numeric string such as "400" or "500". Present only when state is fail. Example:500。 |
data.failMsg | string | 否 | Failure reason. Present only when state is fail. Example:<error detail>。 |
Success
json
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "e0af60383dfdb1d6bfb6bd40d9e6f891",
"model": "flux-3/klein-text-to-image",
"state": "success",
"param": "{\"model\": \"flux-3/klein-text-to-image\", \"callBackUrl\": \"https://your-domain.com/api/callback\", \"input\": \"{\\\"prompt\\\": \\\"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field\\\", \\\"aspect_ratio\\\": \\\"16:9\\\", \\\"resolution\\\": \\\"1K\\\", \\\"output_format\\\": \\\"png\\\", \\\"num_images\\\": 1, \\\"enhance_prompt\\\": true}\"}",
"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-text-to-image",
"state": "fail",
"param": "{\"model\": \"flux-3/klein-text-to-image\", \"callBackUrl\": \"https://your-domain.com/api/callback\", \"input\": \"{\\\"prompt\\\": \\\"A corgi wearing a yellow rain hat sitting on wet stone steps after the rain, shallow depth of field\\\", \\\"aspect_ratio\\\": \\\"16:9\\\", \\\"resolution\\\": \\\"1K\\\", \\\"output_format\\\": \\\"png\\\", \\\"num_images\\\": 1, \\\"enhance_prompt\\\": true}\"}",
"failCode": "500",
"failMsg": "<error detail>",
"completeTime": 1786430358000,
"createTime": 1786430330000,
"costTime": 8,
"updateTime": 1786430358000
}
}