Flux-2 - Text to Image
This page is generated from the upstream official OpenAPI documentation. Endpoints, parameters and examples match the official docs; brand and API domain are replaced with ModelFold.
Endpoint
POST /jobs/createTask
Full URL: https://ai.modelfold.online/v1/jobs/createTask
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
High-quality photorealistic image generation powered by Flux-2's advanced AI model
The output format is not fixed: results may be PNG or JPEG.
Query Task Status
After submitting a task, use the unified query endpoint to check progress and retrieve results:
- Get Task Details — Learn how to query task status and retrieve generation results
TIP
For production use, we recommend using the callBackUrl parameter to receive automatic notifications when generation completes, rather than polling the status endpoint.
Related Resources
- Market Overview — Explore all available models
- Common API — Check credits and account usage
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name for the generation task. Required field. - This endpoint must use the flux-2/flex-text-to-image model Default:"flux-2/flex-text-to-image"。 Allowed values:flux-2/flex-text-to-image。 示例:flux-2/flex-text-to-image。 |
callBackUrl | string | No | Callback URL to receive notifications when the generation task is completed. Optional configuration, recommended for production environments. - After the task is generated, the system will POST task status and results to this URL - The callback content includes the generated resource URL and task-related information - Your callback endpoint needs to support receiving POST requests with JSON payloads - Alternatively, you can call the task details endpoint to actively poll task status - To ensure callback security, see Webhook Verification Guide for signature verification implementation 示例: https://your-domain.com/api/callback。 |
input | object | No | Input parameters for the generation task |
input.prompt | string | Yes | Generation prompt, length must be between 3-5000 characters. (Maximum length: 5000 characters) 示例:A humanoid figure with a vintage television set for a head, featuring a green-tinted screen displaying a Hello FLUX.2 writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting。 |
input.aspect_ratio | string | Yes | Required. Aspect ratio of the generated image. Allowed values:1:1 / 4:3 / 3:4 / 16:9 / 9:16 / 3:2 / 2:3。 示例:1:1。 |
input.resolution | string | Yes | Required. Output image resolution. Allowed values:1K / 2K。 示例:1K。 |
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
curl -X POST "https://ai.modelfold.online/v1/jobs/createTask" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2/flex-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A humanoid figure with a vintage television set for a head, featuring a green-tinted screen displaying a `Hello FLUX.2` writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting",
"aspect_ratio": "1:1",
"resolution": "1K",
"nsfw_checker": false
}
}'{
"model": "flux-2/flex-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A humanoid figure with a vintage television set for a head, featuring a green-tinted screen displaying a `Hello FLUX.2` writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting",
"aspect_ratio": "1:1",
"resolution": "1K",
"nsfw_checker": false
}
}Response
200 — Request successful
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_flux-2_1765175490366"
}
}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。 示例:200。 |
msg | string | 否 | Status message 示例:Playground task completed successfully.。 |
data | object | 否 | — |
data.completeTime | integer | 否 | Task completion time, represented as a Unix timestamp in milliseconds 示例:1786430877000。 |
data.costTime | integer | 否 | Processing time in seconds. Present on both success and failure callbacks. 示例:38。 |
data.createTime | integer | 否 | Task creation time, represented as a Unix timestamp in milliseconds 示例:1786430837000。 |
data.creditsConsumed | number | 否 | Credits consumed by the task; 0 for failed tasks. 示例:14。 |
data.model | string | 否 | Image generation model used for the task 示例:flux-2/flex-text-to-image。 |
data.param | string | 否 | Parameters submitted when creating the task, in JSON string format 示例:{"input":"{\"aspect_ratio\":\"1:1\",\"prompt\":\"A humanoid figure with a vintage television set for a head,featuring a green-tinted screen displaying a Hello FLUX.2 writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting\",\"resolution\":\"1K\",\"nsfw_checker\":false}","callBackUrl":"https://your-domain.com/api/callback","model":"flux-2/flex-text-to-image"}。 |
data.resultJson | string | 否 | 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/h/97d494e87bb500bbfd9ae018b9df5e50_1786430874.png"]}。 |
data.state | string | 否 | Task status Allowed values:success / fail。 示例:success。 |
data.taskId | string | 否 | Task ID 示例:97d494e87bb500bbfd9ae018b9df5e50。 |
data.updateTime | integer | 否 | Use completeTime as the completion time; updateTime may equal createTime. 示例:1786430877000。 |
data.failCode | string | 否 | Failure code, a numeric string such as "400" or "500". Present only when state is fail. 示例:500。 |
data.failMsg | string | 否 | Failure reason. Present only when state is fail. 示例:<error detail>。 |
Success
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "97d494e87bb500bbfd9ae018b9df5e50",
"model": "flux-2/flex-text-to-image",
"state": "success",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"1:1\\\",\\\"prompt\\\":\\\"A humanoid figure with a vintage television set for a head,featuring a green-tinted screen displaying a `Hello FLUX.2` writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting\\\",\\\"resolution\\\":\\\"1K\\\",\\\"nsfw_checker\\\":false}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"flux-2/flex-text-to-image\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/h/97d494e87bb500bbfd9ae018b9df5e50_1786430874.png\"]}",
"completeTime": 1786430877000,
"createTime": 1786430837000,
"costTime": 38,
"creditsConsumed": 14,
"updateTime": 1786430877000
}
}Failure
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "97d494e87bb500bbfd9ae018b9df5e50",
"model": "flux-2/flex-text-to-image",
"state": "fail",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"1:1\\\",\\\"prompt\\\":\\\"A humanoid figure with a vintage television set for a head,featuring a green-tinted screen displaying a `Hello FLUX.2` writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting\\\",\\\"resolution\\\":\\\"1K\\\",\\\"nsfw_checker\\\":false}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"flux-2/flex-text-to-image\"}",
"failCode": "500",
"failMsg": "<error detail>",
"completeTime": 1786430877000,
"createTime": 1786430837000,
"costTime": 38,
"creditsConsumed": 0,
"updateTime": 1786430877000
}
}