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.
Model overview
Example results
![]() Original image | ![]() Change her hair to red | ![]() Put a pair of sunglasses on her | ![]() Convert to French picture book style |
For more examples, see Key capabilities.Models and pricing
- Beijing region
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
- Java
- curl
Sample Request
Sample Response
The url is valid for 24 hours. Download the image in a timely manner.
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
functionparameter tostylization_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
Sample request
Input image | Output image | |
|---|---|---|
Prompt: transform into French picture book style | Prompt: transform into gold foil art style | |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
Control the magnitude of image modification with strength
Use theparameters.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) | |
![]() | ![]() | ![]() | ![]() |
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
functionparameter tostylization_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
Sample request
Input image | Output image | |||
|---|---|---|---|---|
![]() | ![]() Ice sculpture | ![]() Cloud | ![]() Chinese festive lantern | ![]() Wooden board |
![]() Blue and white porcelain | ![]() Fluffy | ![]() | ![]() 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
functionparameter todescription_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
Sample request
Capability | Input image | Output image |
|---|---|---|
Adding elements | ![]() | ![]() Add a pair of sunglasses to the kitten. |
Modifying elements | ![]() | ![]() Change her hair to red. |
Control the image modification magnitude with strength
Use theparameters.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) | |
![]() | ![]() | ![]() | ![]() |
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
functionparameter todescription_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,
promptcan be left empty (""); if the object is large,promptmust 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
Sample request
| Capability | Input image | Input image with mask area(white indicates the region to be edited) | Output image |
|---|---|---|---|
| Add elements | ![]() | ![]() | ![]() The prompt can also be written as "a puppy wearing a hat" (describing the desired image content). |
| Modifying elements | ![]() | ![]() | ![]() The prompt can also be written as "replace the carrot held by the ceramic rabbit with a ceramic flower" (describing the action). |
| Delete elements | ![]() | ![]() | ![]() The prompt should describe the content after deletion; do not write "delete a brown teddy bear". |
Text and Watermark Removal
- How to use: Set the parameter
functiontoremove_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
Sample request
Input image | Output image (text removed from the 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
functiontoexpand. - Parameters used together:
top_scale,bottom_scale,left_scale,right_scaleinparameterscontrol 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
Sample request
Input image | Output 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
functiontosuper_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
Sample request
Input image (blurry image) | Output image (clear 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
functiontocolorization. - 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
Sample request
Input image | Output 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
functiontodoodle. -
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
Sample request 1: sketch-to-image
Sample request 2: doodle drawing
Sample request 2: doodle drawing
Capability | Input image | Output image |
|---|---|---|
Sketch-to-image (is_sketch=false) | ![]() | ![]() A living room in Scandinavian minimalist style. |
Doodle drawing (is_sketch=true) | ![]() | ![]() A tree in anime style. |
Generate images from a cartoon character reference
- How to use: Set the
functionparameter tocontrol_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
Sample request 2: doodle drawing
Input image | Output 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_statusin the task query result. For theFAILEDstatus, record thecodeandmessagefor 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
DataInspectionFailederror.
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_statusasSUCCEEDEDand the image is successfully generated. - Failed model calls or processing errors incur no charges and do not consume the new user free quota.
- You are billed based on the number of images successfully generated. Billing occurs only after the API returns
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:
- Content moderation failure: The input or generated image content triggered safety policies.
- Parameter errors: A parameter in the request is invalid, such as an incorrect
functionname or an inaccessible URL. - Internal model errors: The model encountered an unexpected issue during processing. Check the
codeanderrorfields in the task query response to obtain the specific error code and message for troubleshooting.





















































