All Products
Search
Document Center

Alibaba Cloud Model Studio:General image editing-Wanx 2.1

Last Updated:Nov 24, 2026

The Wanx general image editing model supports text instruction input to perform various image editing tasks such as image expansion, watermark removal, style transfer, instruction-based editing, local repainting, and image restoration.

ImportantThis document applies only to the China (Beijing) region. To use the model, you must use an API Key from the China (Beijing) region.

Model overview

Example results

image

Original image

image

Change her hair to red

35779519-bfc3-4b0a-a594-d764fe9a46d83005601501

Put a pair of sunglasses on her

image

Convert to French picture book style

For more examples, see Key capabilities.

Models and pricing

Beijing region

ImportantThe Beijing region offers no free quota. Calls will incur charges. Confirm before you proceed.

Model

Billing unit price

Rate limits (shared by the primary account and RAM sub-accounts)

RPS limit of the node submission API

Number of nodes being processed at the same time

wanx2.1-imageedit

$0.020070/image

2

2

QuickStart

Prerequisites

Before you make a call, please get and configure an API Key, and then configure the API Key in environment variables. If you call the model through the DashScope SDK, you must also install the SDK.

Sample Code

This section demonstrates how to call the general image editing API to complete a "local repainting" node.

The SDK encapsulates the asynchronous processing logic at the underlying layer, so the upper-layer interface behaves as a synchronous call (that is, a single request that waits until the final result is returned). The curl example, by contrast, corresponds to two separate asynchronous API endpoints: one for submitting a node and the other for querying the result.

Python

This example supports three image input methods: Public URL, Base64 encoding, and local file path.

Sample Request

import base64
import os
import mimetypes
import dashscope
from dashscope import DashScopeError

"""
Requirements:
    dashscope Python SDK >= 2.0.1
Install/upgrade the SDK:
    pip install -U dashscope
"""

# The following is the configuration for the China (Beijing) region. Replace {WorkspaceId} with your actual workspace ID when calling. The region value varies by region.
client = dashscope.Client(
    # If you have not configured the environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
    # API keys differ by region. To get an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

# --- Helper function: Base64 encoding ---
# Format: data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
    mime_type, _ = mimetypes.guess_type(file_path)
    if not mime_type or not mime_type.startswith("image/"):
        raise ValueError("不支持或无法识别的图像格式")
    with open(file_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
    return f"data:{mime_type};base64,{encoded_string}"

"""
Image input methods:
The following three methods are provided; choose one of them:

1. Public URL - for images that are already publicly accessible
2. Local file - for local development and testing
3. Base64 encoding - for private images or scenarios that require encrypted transmission
"""

# [Method 1] Use a public image URL
mask_image_url = "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_3_mask.png"
base_image_url = "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_3.jpeg"

# [Method 2] Use a local file (both absolute and relative paths are supported)
# Format: file:// + file path
# Example (absolute path):
# mask_image_url = "file://" + "/path/to/your/mask_image.png"     # Linux/macOS
# base_image_url = "file://" + "C:/path/to/your/base_image.jpeg"  # Windows
# Example (relative path):
# mask_image_url = "file://" + "./mask_image.png"                 # Use the actual path
# base_image_url = "file://" + "./base_image.jpeg"                # Use the actual path

# [Method 3] Use a Base64-encoded image
# mask_image_url = encode_file("./mask_image.png")               # Use the actual path
# base_image_url = encode_file("./base_image.jpeg")              # Use the actual path

def sample_sync_call_imageedit():
    print('please wait...')
    try:
        # generate is a one-step call ("submit + wait") that returns a completed Job object.
        job = client.images.generate(
            model="wanx2.1-imageedit",
            function="description_edit_with_mask",
            prompt="陶瓷兔子拿着陶瓷小花",
            # mask_image_url/base_image_url are edit-specific input fields, passed through extra_input to the request input section.
            extra_input={
                "mask_image_url": mask_image_url,
                "base_image_url": base_image_url,
            },
            n=1,
        )
        print('response: %s' % job)
        for url in job.image_urls:
            print("---------------------------")
            print(url)
    except DashScopeError as e:
        print(f"HTTP status code: {e.status_code}")
        print(f"Error code: {e.code}")
        print(f"Error message: {e.message}")
        print("See the documentation: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_sync_call_imageedit()

Sample Response

The url is valid for 24 hours. Download the image in a timely manner.

{
    "status_code": 200,
    "request_id": "dc41682c-4e4a-9010-bc6f-xxxxxx",
    "code": null,
    "message": "",
    "output": {
        "task_id": "6e319d88-a07a-420c-9493-xxxxxx",
        "task_status": "SUCCEEDED",
        "results": [
            {
                "url": "https://dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com/xxx.png?xxxxxx"
            }
        ],
        "submit_time": "2025-05-26 14:58:27.320",
        "scheduled_time": "2025-05-26 14:58:27.339",
        "end_time": "2025-05-26 14:58:39.170",
        "task_metrics": {
            "TOTAL": 1,
            "SUCCEEDED": 1,
            "FAILED": 0
        }
    },
    "usage": {
        "image_count": 1
    }
}

Java

This example supports three image input methods: Public URL, Base64 encoding, and local file path.

Sample Request

// Copyright (c) Alibaba, Inc. and its affiliates.

import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

/**
 * Environment requirements
 *      dashscope java SDK >=2.20.9
 * Update Maven dependencies:
 *      https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java
 */

public class ImageEditSync {
    static {Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";}

    // If you have not configured the environment variable, replace the following line with your Model Studio API key: apiKey="sk-xxx"
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    /**
     * Image input methods: Choose one of the following three.
     *
     * 1. Use a public URL - suitable for publicly accessible images.
     * 2. Local file: Suitable for local development and testing.
     * 3. Base64 encoding: Best for private images or when data must be securely transmitted.
     */

    //[Method 1] Public URL
    static String maskImageUrl = "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_3_mask.png";
    static String baseImageUrl = "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_3.jpeg";

    //[Method 2] Local file path (file://+absolute path or file:///+absolute path)
    // static String maskImageUrl = "file://" + "/your/path/to/mask_image.png";    // Linux/macOS
    // static String baseImageUrl = "file:///" + "C:/your/path/to/base_image.png";  // Windows

    //[Method 3] Base64 encoding
    // static String maskImageUrl = encodeFile("/your/path/to/mask_image.png");
    // static String baseImageUrl = encodeFile("/your/path/to/base_image.png");

    public static void syncCall() {
        // Set the parameters
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("prompt_extend", true);

        ImageSynthesisParam param =
                ImageSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model("wanx2.1-imageedit")
                        .function(ImageSynthesis.ImageEditFunction.DESCRIPTION_EDIT_WITH_MASK)
                        .prompt("陶瓷兔子拿着陶瓷小花")
                        .maskImageUrl(maskImageUrl)
                        .baseImageUrl(baseImageUrl)
                        .n(1)
                        .size("1024*1024")
                        .parameters(parameters)
                        .build();

        ImageSynthesis imageSynthesis = new ImageSynthesis();
        ImageSynthesisResult result = null;
        try {
            System.out.println("---sync call, please wait a moment----");
            result = imageSynthesis.call(param);
        } catch (ApiException | NoApiKeyException e){
            throw new RuntimeException(e.getMessage());
        }
        System.out.println(JsonUtils.toJson(result));
    }

    /**
     * Encodes a file into a Base64 string.
     * @param filePath The file path.
     * @return A Base64 string in the format data:{MIME_type};base64,{base64_data}.
     */
    public static String encodeFile(String filePath) {
        Path path = Paths.get(filePath);
        if (!Files.exists(path)) {
            throw new IllegalArgumentException("文件不存在: " + filePath);
        }
        // Detect MIME type
        String mimeType = null;
        try {
            mimeType = Files.probeContentType(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("无法检测文件类型: " + filePath);
        }
        if (mimeType == null || !mimeType.startsWith("image/")) {
            throw new IllegalArgumentException("不支持或无法识别的图像格式");
        }
        // Read file content and encode
        byte[] fileBytes = null;
        try{
            fileBytes = Files.readAllBytes(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("无法读取文件内容: " + filePath);
        }

        String encodedString = Base64.getEncoder().encodeToString(fileBytes);
        return "data:" + mimeType + ";base64," + encodedString;
    }

    public static void main(String[] args) {
        syncCall();
    }
}

Sample Response

The url is valid for 24 hours. Download the image in a timely manner.

{
    "request_id": "bf6c6361-f0fc-949c-9d60-xxxxxx",
    "output": {
        "task_id": "958db858-153b-4c81-b243-xxxxxx",
        "task_status": "SUCCEEDED",
        "results": [
            {
                "url": "https://dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com/xxx.png?xxxxxx"
            }
        ],
        "task_metrics": {
            "TOTAL": 1,
            "SUCCEEDED": 1,
            "FAILED": 0
        }
    },
    "usage": {
        "image_count": 1
    }
}

curl

This example covers the entire process from creating a node, polling the status, to obtaining and saving the result.

Note

  • For asynchronous calls, you must set the Header parameter X-DashScope-Async to enable.
  • The task_id of an asynchronous node can be queried within 24 hours. After it expires, the node status will become UNKNOWN.

Step 1: Send a node creation request

The request returns a node ID (task_id).

Sample request
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wanx2.1-imageedit",
  "input": {
    "function": "description_edit_with_mask",
    "prompt": "陶瓷兔子拿着陶瓷小花。",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_3.jpeg",
    "mask_image_url": "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_3_mask.png"
  },
  "parameters": {
    "n": 1
  }
}'
Sample response
{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

Step 2: Query the result by node ID

Use the task_id obtained in the previous step to poll the node status through the API until task_status becomes SUCCEEDED or FAILED.

Sample request

Please replace 86ecf553-d340-4e21-xxxxxxxxx with the real task_id.

curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Sample response

The image URL is valid for 24 hours. Download the image in a timely manner.

{
    "request_id": "eeef0935-02e9-9742-bb55-xxxxxx",
    "output": {
        "task_id": "a425c46f-dc0a-400f-879e-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-02-21 17:56:31.786",
        "scheduled_time": "2025-02-21 17:56:31.821",
        "end_time": "2025-02-21 17:56:42.530",
        "results": [
            {
                "url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/aaa.png"
            }
        ],
        "task_metrics": {
            "TOTAL": 1,
            "SUCCEEDED": 1,
            "FAILED": 0
        }
    },
    "usage": {
        "image_count": 1
    }
}

Key Capabilities

The general image editing API uses the function parameter to specify different image editing functions. All functions follow the calling method described in QuickStart.

The following uses a curl call as an example and only lists the input and parameters JSON fragments specific to each function, to illustrate what needs to be configured in the request body.

Note: A complete curl request should include top-level fields such as model, input, and parameters. For the specific structure, see General image editing API reference.

Global Stylization

Transfers the entire image to a specified artistic style. Use cases include: picture book creation, social media illustrations (generating backgrounds or concept images that match a specific visual style), and more.

  • How to use: Set the function parameter to stylization_all.

  • Supported styles:

    • French picture book style
    • Gold foil art style
  • Parameters used together: parameters.strength (0.0-1.0, default 0.5) controls the magnitude of modification. The smaller the value, the closer the result is to the original image.

  • Prompt tips: Use the pattern "transform into xx style", such as "transform into French picture book style".

Sample request

{
  "input": {
    "function": "stylization_all",
    "prompt": "转换成法国绘本风格",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/stylization_all_3.png"
  },
  "parameters": {
    "strength": 0.5
  }
}

Input image

Output image

Prompt: transform into French picture book style

Prompt: transform into gold foil art style

image

image

image

image

image

image

Control the magnitude of image modification with strength

Use the parameters.strength parameter to control the magnitude of image modification. This parameter is optional, with a value range of [0.0, 1.0] and a default value of 0.5. The closer the value is to 0, the closer the result is to the original image; the closer the value is to 1, the greater the magnitude of modification to the original image.

Input prompt:Transform the image into a French picture book style.

Input image

Output image

strength=0.0 (minimum)

strength=0.5 (default)

strength=1.0 (maximum)

image

image

image

image

Local stylization

Apply style transfer only to a local region of the image. Use cases include personalized customization (such as stylizing a person's clothing) and advertising design (highlighting products).

  • How to use: Set the function parameter to stylization_local.

  • Supported styles: The Chinese-English mapping is as follows:

    • Ice sculpture: ice
    • Cloud: cloud
    • Chinese festive lantern: chinese festive lantern
    • Wooden board: wooden
    • Blue and white porcelain: blue and white porcelain
    • Fluffy: fluffy
    • Weaving: weaving
    • Balloon: balloon
  • Prompt tips: Use the pattern "turn XX into XX style", for example, "turn the house into a wooden style".

Sample request

{
  "input": {
    "function": "stylization_local",
    "prompt": "把房子变成木板风格",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/stylization_local_1.png"
  }
}

Input image

Output image

image

image

Ice sculpture

image

Cloud

image

Chinese festive lantern

image

Wooden board

image

Blue and white porcelain

image

Fluffy

imageWeaving

image

Balloon

Instruction-based editing

Add or modify image content through text instructions alone, without specifying a region. Use cases include simple edits that do not require precise positioning, such as adding accessories to a person or changing hair color.

  • How to use: Set the function parameter to description_edit.
  • Parameters used together: parameters.strength (0.0-1.0, default 0.5) controls the modification magnitude; the smaller the value, the closer the result to the original image.
  • Prompt tips: Explicitly state operation descriptions such as "add" and "modify". For deletion, we recommend using local repainting.

Sample request

{
  "input": {
    "function": "description_edit",
    "prompt": "给小猫添加一副墨镜",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/description_edit_1.jpeg"
  },
  "parameters": {
    "strength": 0.5
  }
}

Capability

Input image

Output image

Adding elements

image

image

Add a pair of sunglasses to the kitten.

Modifying elements

image

image

Change her hair to red.

Control the image modification magnitude with strength

Use the parameters.strength parameter to control the magnitude of image modification. This parameter is optional, with a value range of [0.0, 1.0] and a default value of 0.5. The closer the value is to 0, the closer the result is to the original image; the closer the value is to 1, the greater the magnitude of modification to the original image.

Input prompt:Change the clothes she is wearing into a beach shirt with a colorful print.

Input image

Output image

strength=0.0 (minimum)

strength=0.5 (default)

strength=1.0 (maximum)

image

image

image

image

Local repainting

Add, modify, or delete content in a specified region by providing a mask image that marks the region. Use cases include edits that require precise control of the region, such as changing outfits, replacing objects, and removing distractions.

  • How to use: Set the function parameter to description_edit_with_mask.

  • Mask requirements: You must provide mask_image_url; in the mask image, white areas are the regions to edit and black areas are preserved.

  • Prompt tips: Explicitly state operation descriptions such as "add" and "modify", as well as descriptions of the content that should appear after deletion.

    • Add/modify: You can describe the action ("add a hat to the puppy") or describe the final result ("a puppy wearing a hat").
    • Delete: If the object to delete is small, prompt can be left empty (""); if the object is large, prompt must describe the background content that should appear after deletion (for example, "a transparent glass vase on a table") rather than "delete the teddy bear".

Sample request

{
  "input": {
    "function": "description_edit_with_mask",
    "prompt": "一只陶瓷兔子抱着一朵陶瓷花",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_1.jpeg",
    "mask_image_url": "http://wanx.alicdn.com/material/20250318/description_edit_with_mask_1_mask.png"
  }
}
CapabilityInput imageInput image with mask area(white indicates the region to be edited)Output image
Add elementsimageimageimage

Add a hat to the puppy.

The prompt can also be written as "a puppy wearing a hat" (describing the desired image content).

Modifying elementsimageimageimage

A ceramic rabbit holding a ceramic flower.

The prompt can also be written as "replace the carrot held by the ceramic rabbit with a ceramic flower" (describing the action).

Delete elementsimageimageimage

A transparent glass vase on a table.

The prompt should describe the content after deletion; do not write "delete a brown teddy bear".

Text and Watermark Removal

Note

Legal Risk Notice

Using this feature to process copyrighted images (such as removing another party's brand watermark) may constitute infringement. Please ensure you have the legal right to use the images you process, and bear all related legal responsibilities yourself.

Remove Chinese or English characters or common watermarks from images. Use cases include: reprocessing source materials, cleaning up advertising images, and more.

  • How to use: Set the parameter function to remove_watermark.
  • Prompt tips: You can use a general instruction such as "remove the text in the image", or specify a type such as "remove the English text".

Sample request

{
  "input": {
    "function": "remove_watermark",
    "prompt": "去除图像中的文字",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/remove_watermark_1.png"
  }
}

Input image

Output image (text removed from the image)

image

image

image

image

Outpainting

Expand the canvas proportionally in the four directions of the image (up, down, left, and right) and intelligently fill in content. Use cases include: adjusting composition, and expanding a portrait image to landscape to fit different media sizes.

  • How to use: Set the parameter function to expand.
  • Parameters used together: top_scale, bottom_scale, left_scale, right_scale in parameters control the expansion ratio in each of the four directions respectively (for example, setting all of them to 1.5 means expanding to 1.5 times the original size).
  • Prompt tips: Describe the complete scene content you expect to see after expansion.

Sample request

{
  "input": {
    "function": "expand",
    "prompt": "一家人在公园草坪上",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/expand_1.jpeg"
  },
  "parameters": {
    "top_scale": 1.5,
    "bottom_scale": 1.5,
    "left_scale": 1.5,
    "right_scale": 1.5
  }
}

Input image

Output image

image

image

Image Super-Resolution

Improve image clarity and support upscaling, making low-resolution or blurry images clear. Use cases include: restoring old photos, and increasing the resolution of materials to meet high-definition printing or display requirements.

  • How to use: Set the parameter function to super_resolution.
  • Parameters used together: parameters.upscale_factor (1-4, default 1) controls the upscaling factor. When the value is 1, only clarity is improved without upscaling.
  • Prompt tips: You can use "image super-resolution" or describe the image content.

Sample request

{
  "input": {
    "function": "super_resolution",
    "prompt": "图像超分",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/super_resolution_1.jpeg"
  },
  "parameters": {
    "upscale_factor": 2
  }
}

Input image (blurry image)

Output image (clear image)

image

image

Image Colorization

Convert black-and-white or grayscale images to color images (black-and-white/grayscale → color). Use cases include: colorizing historical photos, and filling colors into line drawings or grayscale images.

  • How to use: Set the parameter function to colorization.
  • Prompt tips: You can leave it empty to let the model colorize automatically, or specify the colors of key elements via the prompt (such as "blue background, yellow leaves").

Sample request

{
  "input": {
    "function": "colorization",
    "prompt": "蓝色背景,黄色的叶子",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/colorization_1.jpeg"
  }
}

Input image

Output image

image

image

Sketch-to-Image (doodle painting supported)

Generate new images based on the outline (sketch) of the input image combined with a prompt. Use cases include: architectural concept design, illustration design, and doodle painting.

  • How to use: Set the parameter function to doodle.

  • Parameter used together: parameters.is_sketch, which controls the model's generation effect.

    • false (default): The input is an RGB image, and the model first extracts a sketch and then generates an image (RGB image → sketch → new image).
    • true: The input is an RGB image (such as a doodle or sketch), and the model directly generates an image based on this image (RGB image → new image).
  • Prompt tips: Describe the content of the image you want to generate. The more specific the description, the better the generation result.

Sample request 1: sketch-to-image

{
  "input": {
    "function": "doodle",
    "prompt": "北欧极简风格的客厅。",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/doodle_1.png"
  },
  "parameters": {
    "is_sketch": false
  }
}

Sample request 2: doodle drawing

{
  "input": {
    "function": "doodle",
    "prompt": "一颗树,二次元动漫风格",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/doodle_2.png"
  },
  "parameters": {
    "is_sketch": true
  }
}

Capability

Input image

Output image

Sketch-to-image

(is_sketch=false)

image

image

A living room in Scandinavian minimalist style.

Doodle drawing

(is_sketch=true)

image

image

A tree in anime style.

Generate images from a cartoon character reference

Note

Legal Risk Notice

Using this feature to process copyrighted cartoon characters may constitute infringement. Please ensure that you have the legal right to use the referenced character, or use your own original character, and bear all related legal responsibilities yourself.

  • How to use: Set the function parameter to control_cartoon_feature.
  • Prompt tips: Use the "cartoon character..." pattern and describe in detail the character's actions and the surrounding environment.

Sample request 2: doodle drawing

{
  "input": {
    "function": "control_cartoon_feature",
    "prompt": "卡通形象小心翼翼地探出头,窥视着房间内一颗璀璨的蓝色宝石",
    "base_image_url": "http://wanx.alicdn.com/material/20250318/control_cartoon_feature_1.png"
  }
}

Input image

Output image

image

image

Going live

Best Practices

  • Asynchronous polling: When polling for asynchronous task results, we recommend adopting a reasonable polling strategy (for example, once every 3 seconds for the first 30 seconds, then extending the interval) to avoid triggering rate limits due to overly frequent requests.
  • Parameter tuning: For key parameters that affect the result, such as strength, we recommend running small-scale tests before going live to find the values that best fit your business scenario.
  • Image storage: The image URL returned by the API is valid for 24 hours. Please download the generated images promptly and transfer them to your own persistent storage service (such as Alibaba Cloud OSS).

Risk mitigation

  • Error handling: Check the task_status in the task query result. For the FAILED status, record the code and message for troubleshooting. Some errors (such as system timeouts) may be transient, so you can design retry logic.
  • Content safety: The API performs safety review on input and output content. If the content is non-compliant, the request will fail with the DataInspectionFailed error.

API Reference

For the input and output parameters of the Wanx general image editing model, see General image editing API reference.

Billing and rate limits

  • For model free quotas and billing unit prices, see Model list and pricing.

  • For model rate limits, see Wanx.

  • Billing details:

    • You are billed based on the number of images successfully generated. Billing occurs only after the API returns task_status as SUCCEEDED and the image is successfully generated.
    • Failed model calls or processing errors incur no charges and do not consume the new user free quota.

Error codes

If a model call fails and returns an error message, see Error codes to resolve the issue.

FAQ

Q: Why did my task fail (FAILED)?

A: Common causes of task failure include:

  1. Content moderation failure: The input or generated image content triggered safety policies.
  2. Parameter errors: A parameter in the request is invalid, such as an incorrect function name or an inaccessible URL.
  3. Internal model errors: The model encountered an unexpected issue during processing. Check the code and error fields in the task query response to obtain the specific error code and message for troubleshooting.