Qwen 2.1 - 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.
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 | The model name used for generation. This endpoint must use qwen2-1/text-to-image. Default:"qwen2-1/text-to-image"。 Allowed values:qwen2-1/text-to-image。 示例:qwen2-1/text-to-image。 |
callBackUrl | string | No | Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent. To verify callbacks, see Webhook Verification Guide. 示例:https://your-domain.com/api/callback。 |
input | object | Yes | Input parameters for the text-to-image generation task. |
input.prompt | string | Yes | The prompt that describes the image content, style and composition you want to generate. Required. Any language is supported, up to 5000 characters; if it is longer, the request is rejected. 示例:A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field。 |
input.aspect_ratio | string | No | The output aspect ratio. Default 1:1. The actual pixel size also depends on resolution. Default:"1:1"。 Allowed values:1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21。 示例:1:1。 |
input.resolution | string | No | The output resolution tier. 1K is the faster option; 2K produces four times the pixels and takes longer. Only 1K and 2K are accepted — with any other value, including 4K, the request is rejected. Default:"1K"。 Allowed values:1K / 2K。 示例:1K。 |
input.background | string | No | Background type. transparent outputs a PNG or WebP with a real alpha channel and cannot be used with JPEG. When using transparent, describe only the subject — prompts that mention a background, scene, surface, etc. may produce a non-transparent result. Default:"opaque"。 Allowed values:opaque / transparent。 示例:opaque。 |
input.output_format | string | No | The output image format. png (default) and webp both carry an alpha channel and can be used with background: transparent. jpeg has no alpha channel and cannot be combined with a transparent background. Default:"png"。 Allowed values:png / webp / jpeg。 示例:png。 |
input.enhance_prompt | boolean | No | Rewrites the prompt into a fuller scene description before generating, which noticeably improves quality. Enabled by default (also when the parameter is omitted); pass false to turn it off. Default:true。 示例:false。 |
input.seed | integer | No | The random seed. Omit it to generate with a random seed. Passing the same seed together with the same prompt and parameters reproduces the same image within the same service version. 示例:20260921。 |
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": "qwen2-1/text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "1K",
"background": "opaque",
"output_format": "png",
"enhance_prompt": true,
"seed": 20260921
}
}'{
"model": "qwen2-1/text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field",
"aspect_ratio": "16:9",
"resolution": "1K",
"background": "opaque",
"output_format": "png",
"enhance_prompt": true,
"seed": 20260921
}
}Response
200 — Request successful
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying). 可选值:200 / 401 / 402 / 404 / 422 / 429 / 433 / 455 / 500 / 501 / 505。 示例:200。 |
msg | string | 否 | Response message, error description upon failure 示例:success。 |
data | object | 是 | — |
data.taskId | string | 是 | The task ID can be used with the "Get Task Details" endpoint to query the task status. 示例:dc1928bfcbc77cb6c85f3359a9c718b3。 |
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_qwen21_1769000000000"
}
}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 示例:1786435794000。 |
data.costTime | integer | 否 | Processing time in seconds. Present on both success and failure callbacks. 示例:50。 |
data.createTime | integer | 否 | Task creation time, represented as a Unix timestamp in milliseconds 示例:1786435744000。 |
data.creditsConsumed | number | 否 | Credits consumed by the task; 0 for failed tasks. 示例:4.8。 |
data.model | string | 否 | Image generation model used for the task 示例:qwen2-1/text-to-image。 |
data.param | string | 否 | Parameters submitted when creating the task, in JSON string format 示例:{"input":"{\"prompt\":\"A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field\",\"aspect_ratio\":\"16:9\",\"resolution\":\"1K\",\"background\":\"opaque\",\"output_format\":\"png\",\"enhance_prompt\":true,\"seed\":20260921}","callBackUrl":"https://your-domain.com/api/callback","model":"qwen2-1/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/workers/images/40a762429ca2e4b0bd55ed2c30458bec.png"]}。 |
data.state | string | 否 | Task status Allowed values:success / fail。 示例:success。 |
data.taskId | string | 否 | Task ID 示例:aceeb8dc2576eeb47a1cef80b9490885。 |
data.updateTime | integer | 否 | Use completeTime as the completion time; updateTime may equal createTime. 示例:1786435794000。 |
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": "aceeb8dc2576eeb47a1cef80b9490885",
"model": "qwen2-1/text-to-image",
"state": "success",
"param": "{\"input\":\"{\\\"prompt\\\":\\\"A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field\\\",\\\"aspect_ratio\\\":\\\"16:9\\\",\\\"resolution\\\":\\\"1K\\\",\\\"background\\\":\\\"opaque\\\",\\\"output_format\\\":\\\"png\\\",\\\"enhance_prompt\\\":true,\\\"seed\\\":20260921}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"qwen2-1/text-to-image\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/workers/images/40a762429ca2e4b0bd55ed2c30458bec.png\"]}",
"completeTime": 1786435794000,
"createTime": 1786435744000,
"costTime": 50,
"creditsConsumed": 4.8,
"updateTime": 1786435794000
}
}Failure
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "aceeb8dc2576eeb47a1cef80b9490885",
"model": "qwen2-1/text-to-image",
"state": "fail",
"param": "{\"input\":\"{\\\"prompt\\\":\\\"A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field\\\",\\\"aspect_ratio\\\":\\\"16:9\\\",\\\"resolution\\\":\\\"1K\\\",\\\"background\\\":\\\"opaque\\\",\\\"output_format\\\":\\\"png\\\",\\\"enhance_prompt\\\":true,\\\"seed\\\":20260921}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"qwen2-1/text-to-image\"}",
"failCode": "500",
"failMsg": "<error detail>",
"completeTime": 1786435794000,
"createTime": 1786435744000,
"costTime": 50,
"creditsConsumed": 0,
"updateTime": 1786435794000
}
}