Qwen 2.1 - Image to Image
Endpoint
POST /images/generations
Full URL: https://modelfold.ai/v1/images/generations
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
Send model parameters directly in the JSON body. Do not wrap them in input. This request waits for generation to finish and returns data[].url; supported media models also offer async jobs, polling and callbacks. Replace example media URLs with your own publicly accessible files. See API gateway for billing and errors.
Input parameters for the image-to-image generation task.
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。 Example:qwen2-1/image-to-image。 |
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. minItems: 1. maxItems: 10. |
prompt | string | Yes | Prompt required by the ModelFold gateway; at most 2000 characters. 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. minLength: 1. maxLength: 2000. Example:Replace the backpack in the first image with the colour scheme from the second image, and leave everything else unchanged。 |
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. Example:https://example.com/room-mask.png。 |
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。 Example:auto。 |
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。 Example:1K。 |
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。 Example:opaque。 |
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。 Example:png。 |
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。 Example:false。 |
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. Example:20260921。 |
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/images/generations" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen2-1/image-to-image",
"image_urls": [
"https://example.com/reference.png"
],
"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
}'json
{
"model": "qwen2-1/image-to-image",
"image_urls": [
"https://example.com/reference.png"
],
"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
}Response
200 — Generation completed. usage contains actual billing details; result URLs are illustrative.
json
{
"ok": true,
"created": 1792134000,
"data": [
{
"url": "https://modelfold.ai/uploads/outputs/result.png"
}
],
"usage": {}
}