Skip to content

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.

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesThe 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。
callBackUrlstringNoCallback 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。
inputobjectYesInput parameters for the text-to-image generation task.
  input.promptstringYesThe 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_ratiostringNoThe 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.resolutionstringNoThe 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.backgroundstringNoBackground 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_formatstringNoThe 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_promptbooleanNoRewrites 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.seedintegerNoThe 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_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://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
  }
}'
json
{
  "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 ​

参数类型必填说明
codeinteger否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。
msgstring否Response message, error description upon failure 示例:success。
dataobject是—
  data.taskIdstring是The task ID can be used with the "Get Task Details" endpoint to query the task status. 示例:dc1928bfcbc77cb6c85f3359a9c718b3。
json
{
  "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

参数类型必填说明
codeinteger否200: success. 501: failure; see data.failCode and data.failMsg. Allowed values:200 / 501。 示例:200。
msgstring否Status message 示例:Playground task completed successfully.。
dataobject否—
  data.completeTimeinteger否Task completion time, represented as a Unix timestamp in milliseconds 示例:1786435794000。
  data.costTimeinteger否Processing time in seconds. Present on both success and failure callbacks. 示例:50。
  data.createTimeinteger否Task creation time, represented as a Unix timestamp in milliseconds 示例:1786435744000。
  data.creditsConsumednumber否Credits consumed by the task; 0 for failed tasks. 示例:4.8。
  data.modelstring否Image generation model used for the task 示例:qwen2-1/text-to-image。
  data.paramstring否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.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/workers/images/40a762429ca2e4b0bd55ed2c30458bec.png"]}。
  data.statestring否Task status Allowed values:success / fail。 示例:success。
  data.taskIdstring否Task ID 示例:aceeb8dc2576eeb47a1cef80b9490885。
  data.updateTimeinteger否Use completeTime as the completion time; updateTime may equal createTime. 示例:1786435794000。
  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": "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

json
{
  "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
  }
}

ModelFold — one API for all the best AI models.