This topic describes the input and output parameters for the Wanx text-to-image V1 model.
Model overview
Model overview
Model | Model overview |
|---|---|
wanx-v1 | The Wanx text-to-image large model, with main features including:
|
Prerequisites
The text-to-image V1 model API supports calls via HTTP and the DashScope SDK.
Before calling, you need to obtain and configure an API Key, and then configure the API Key in environment variables.
To call via SDK, please install the DashScope SDK. Currently, the SDK supports Python and Java.
HTTP calls
Image models take longer to process. To avoid request timeouts, HTTP calls only support retrieving model results asynchronously. You need to make two requests:
- Create a task to get the task ID: First send a task creation request, which returns a task ID (task_id).
- Query results by task ID: Use the task ID obtained in the previous step to query the task status and results. When the task completes successfully, an image URL is returned, valid for 24 hours.
Step 1: Create a task to get the task ID
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
When calling, replace {WorkspaceId} with your actual Workspace ID.
Request parametersRequest headersContent-Typestring(required)The request content type. This parameter must be set to application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.X-DashScope-Asyncstring(required)Asynchronous processing configuration parameter. HTTP requests support asynchronous calls only; it must be set to enable.X-DashScope-WorkSpacestring(Optional)The Alibaba Cloud Model Studio Workspace ID. Example value: llm-xxxx.You can obtain the Workspace ID here.
Detailed description This parameter is filled in based on the Alibaba Cloud Model Studio API Key.
For information on how to distinguish between Alibaba Cloud Model Studio primary accounts and RAM sub-accounts, see Primary account management. Request Bodymodelstring(Required)The model name. Example value: wanx-v1.inputobject(Required)The basic input information, such as prompts.
Properties prompt string(Required)The positive prompt, used to describe the elements and visual features that you want in the generated image.Supports Chinese and English, up to 800 characters in length. Each Chinese character or letter counts as one character, and any excess is automatically truncated.Example value: An orange tabby cat sitting down, with a pleasant expression, lively and adorable, realistic and accurate.For tips on using prompts, see Text-to-image prompt guide.negative_promptstring (Optional)The negative prompt, used to describe the content you do not want in the image, which constrains the image.Supports Chinese and English, up to 500 characters in length. Any excess is automatically truncated.Example value: low resolution, errors, worst quality, low quality, deformities, extra fingers, bad proportions, etc.ref_imgstring(Optional)The URL of the reference image. The model generates an image with a similar style based on the reference image.Image limits:
object (Optional)The image processing parameters.
Properties style string (Optional)The style of the output image. The following styles are supported:
Enumeration values
string (Optional)The resolution of the output image. The following four image resolutions are currently supported:
Enumeration values
integer (Optional)The number of images to generate. The value must be an integer from 1 to 4. The default value is 4.seed integer (Optional)The random number seed, which is used to control the randomness of the generated content. The value must be in the range of [0, 2147483647].If not provided, the algorithm automatically generates a random number as the seed. If provided, a seed parameter is generated for each of the n images based on the value of n; for example, with n=4, the algorithm generates images with seed, seed+1, seed+2, and seed+3 as their parameters respectively.To ensure the generated content is relatively stable, use the same seed value for each request.ref_strength float (Optional)Controls the similarity between the output image and the reference image.The value must be in the range of [0.0, 1.0]. A larger value indicates that the generated image is more similar to the reference image.ref_mode string (Optional)The mode for generating an image based on a reference image. The following modes are supported:
Enumeration values
|
|
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes. |
Please save the task_id, which is used to query the task status and results. |
Step 2: Query the result by task ID
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
Please replace 86ecf553-d340-4e21-xxxxxxxxx with the actual task_id.If you use a model in the Singapore region, replace base_url with https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx, where {WorkspaceId} must be replaced with the actual workspace ID. |
Response parametersoutputobjectThe task output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
objectStatistics for the task result.
Properties TOTAL integerThe total number of tasks.SUCCEEDED integerThe number of successful tasks.FAILED integerThe number of failed tasks.array of objectThe list of task results, including image URLs, error messages in case of partial task failure.
Structure stringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes.objectThe output statistics. Only successful results are counted.
Properties image_count integerNumber of images successfully generated. Billing: Cost = Number of images × Unit price.stringUnique request identifier for tracing and troubleshooting. |
Task data (task status and image URLs) is retained for only 24 hours and then automatically purged. Save generated images promptly. |
DashScope SDK invocation
Make sure you have installed the latest version of the DashScope SDK. Otherwise, a runtime error may occur. For more information, see Install the SDK.
The DashScope SDK currently supports Python and Java.
The parameter names in the SDK are mostly consistent with those in the HTTP API. The parameter structure varies based on the SDK encapsulation for each language. For parameter descriptions, see HTTP invocation.
Because image model processing can be time-consuming, the underlying service is provided asynchronously. The SDK is encapsulated to support both synchronous and asynchronous invocation methods.
Python SDK invocation
- Synchronous call
- Asynchronous call
Request example
Response example
Java SDK invocation
- Synchronous call
- Asynchronous call
Request example
Response example
Image output storage domains
The Tongyi Wan image generation service stores generated images in OSS, and the domain in the generated result URL varies by region. If your corporate network environment has egress whitelist restrictions, you must add the following OSS domains to the whitelist to retrieve the generated images.
The egress domains of the following 10 regions are currently supported:
Region | OSS domain |
China (Beijing) |
|
China (Hangzhou) |
|
China (Shanghai) |
|
China (Ulanqab) |
|
China (Zhangjiakou) |
|
China (Shenzhen) |
|
China (Heyuan) |
|
China (Chengdu) |
|
China (Guangzhou) |
|
China (Ulanqab) ACDR |
|
Error codes
If a model call fails and returns an error message, see Error messages for a solution.
FAQ
Model billing and rate limiting
Free quota
- Description: The free quota applies only to successfully generated output images. Input images or failed model processing do not consume the free quota.
- How to get: It is automatically granted when you activate Model Studio. Valid for 90 days.
- Account scope: Shared between your Alibaba Cloud account and its RAM users.
- For more details, see Free quota for new users.
- If billing shows a limited-time free trial, the model is in public preview. You cannot use the model after the free quota runs out.
- If a clear unit price is shown — for example, CNY 0.2 per second — the model is commercially available. You must pay after the free quota expires or is fully consumed.
- Billing scope: Charges apply only to successfully generated output images. Other scenarios are not billed.
- Billing method: Billing is applied to your Alibaba Cloud account. RAM users cannot be billed independently. Your Alibaba Cloud account must cover all associated charges. To view billing information, go to the Bills page.
- Recharge: Go to the Expenses and Costs console.
- View invocation metrics: Go to the Monitoring page.
- For more billing questions, see Billing Items.
- Rate limit scope: Shared between your Alibaba Cloud account and its RAM users.