Qwen 2.1 - Image 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/image-to-image. Default:"qwen2-1/image-to-image"。 Allowed values:qwen2-1/image-to-image。 示例:qwen2-1/image-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 image-to-image generation task. |
input.image_urls | array<string> | Yes | Reference images, given as an array of 1 to 10 http(s) URLs. Required. The order of the array is the order the prompt refers to ("the first image", "the second image"). JPEG, PNG and WebP are supported, up to 30MB and 25MP each, and every URL must be directly retrievable with a GET. If an image URL cannot be fetched, the task fails with failCode 400. With more than 10 entries the request is rejected. The more references you supply the less detail each individual one keeps, so stay within 4 when fidelity matters. When combining several people or objects into a single picture, a landscape ratio such as 3:2 or 16:9 usually gives better results. |
input.prompt | string | Yes | The prompt describing the result you want. Required. Any language is supported, up to 5000 characters; if it is longer, the request is rejected. When mask_url is supplied, use it to describe what should be generated inside the white area of the mask. 示例:Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged。 |
input.mask_url | string | No | Inpainting mask that switches the request into local-edit mode. A black and white image where white marks the area to change and black is kept unchanged, with a few pixels of feathering along the boundary. It must be used with exactly one entry in image_urls, otherwise the request is rejected. The mask should have the same aspect ratio as that reference image; a mask of a different size is scaled to it. In local-edit mode the output ratio follows the reference image, so aspect_ratio and enhance_prompt are ignored. It cannot be combined with background: transparent; such a request is rejected. 示例:https://example.com/room-mask.png。 |
input.aspect_ratio | string | No | Output aspect ratio. Defaults to auto, which takes the aspect ratio of the first reference image and snaps it to the nearest supported ratio. The actual pixel size also depends on resolution. Ignored in local-edit mode. Default:"auto"。 Allowed values:auto / 1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21。 示例:auto。 |
input.resolution | string | No | Output resolution tier. 1K is the faster option; 2K produces four times the pixels and takes considerably longer, up to about 3 minutes with reference images. 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 | 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/image-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"image_urls": [
"https://example.com/a.jpg",
"https://example.com/b.jpg"
],
"prompt": "Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged",
"aspect_ratio": "auto",
"resolution": "1K",
"background": "opaque",
"output_format": "png",
"enhance_prompt": true,
"seed": 20260921
}
}'{
"model": "qwen2-1/image-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"image_urls": [
"https://example.com/a.jpg",
"https://example.com/b.jpg"
],
"prompt": "Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged",
"aspect_ratio": "auto",
"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。 |
data | object | 是 | — |
data.taskId | string | 是 | Task ID, can be used with Get Task Details endpoint to query task status |
msg | string | 否 | Response message, error description when failed 示例:success。 |
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_qwen21i2i_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/image-to-image。 |
data.param | string | 否 | Parameters submitted when creating the task, in JSON string format 示例:{"input":"{\"image_urls\":[\"https://example.com/a.jpg\",\"https://example.com/b.jpg\"],\"prompt\":\"Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged\",\"aspect_ratio\":\"auto\",\"resolution\":\"1K\",\"background\":\"opaque\",\"output_format\":\"png\",\"enhance_prompt\":true,\"seed\":20260921}","callBackUrl":"https://your-domain.com/api/callback","model":"qwen2-1/image-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/6a290e5bf56277db2f3c56686e0b51ba.png"]}。 |
data.state | string | 否 | Task status Allowed values:success / fail。 示例:success。 |
data.taskId | string | 否 | Task ID 示例:709bf695b197209c410c980ee55a6ea6。 |
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": "709bf695b197209c410c980ee55a6ea6",
"model": "qwen2-1/image-to-image",
"state": "success",
"param": "{\"input\":\"{\\\"image_urls\\\":[\\\"https://example.com/a.jpg\\\",\\\"https://example.com/b.jpg\\\"],\\\"prompt\\\":\\\"Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged\\\",\\\"aspect_ratio\\\":\\\"auto\\\",\\\"resolution\\\":\\\"1K\\\",\\\"background\\\":\\\"opaque\\\",\\\"output_format\\\":\\\"png\\\",\\\"enhance_prompt\\\":true,\\\"seed\\\":20260921}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"qwen2-1/image-to-image\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/workers/images/6a290e5bf56277db2f3c56686e0b51ba.png\"]}",
"completeTime": 1786435794000,
"createTime": 1786435744000,
"costTime": 50,
"creditsConsumed": 4.8,
"updateTime": 1786435794000
}
}Failure
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "709bf695b197209c410c980ee55a6ea6",
"model": "qwen2-1/image-to-image",
"state": "fail",
"param": "{\"input\":\"{\\\"image_urls\\\":[\\\"https://example.com/a.jpg\\\",\\\"https://example.com/b.jpg\\\"],\\\"prompt\\\":\\\"Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged\\\",\\\"aspect_ratio\\\":\\\"auto\\\",\\\"resolution\\\":\\\"1K\\\",\\\"background\\\":\\\"opaque\\\",\\\"output_format\\\":\\\"png\\\",\\\"enhance_prompt\\\":true,\\\"seed\\\":20260921}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"qwen2-1/image-to-image\"}",
"failCode": "500",
"failMsg": "<error detail>",
"completeTime": 1786435794000,
"createTime": 1786435744000,
"costTime": 50,
"creditsConsumed": 0,
"updateTime": 1786435794000
}
}