This model is scheduled to be deprecated. To avoid service disruptions, switch to another model.
You can use this model to generate a complete poster from a background image and text. The model automatically arranges the text on the image.
Related guide: Image and text composition
Model overview
Model name | Description | Price | Rate limiting | |
QPS limit | Concurrent tasks | |||
wanx-ast | Input a background image and text to generate a complete poster. The model ensures a balanced text layout and harmonious color scheme, supports background images of any aspect ratio, and offers a variety of font pairings. | Free for a limited time | 2 | 1 |
Prerequisites
Create an API key and export the API key as an environment variable.
HTTP call
Create task
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
Headers | Image and text composition |
Content-Type string Required The content type of the request. The value is fixed to | |
Authorization string Required A Model Studio API key is recommended, but you can also use a DashScope API key. For example: Bearer d1xxx2a. | |
X-DashScope-Async string Required Enables asynchronous processing. You must set this parameter to | |
Request body | |
model string Required The model to call. | |
input object Required The background image, text elements, and other assets for the poster. | |
parameters object Required Parameters that control image generation. |
Response | Successful responseError response |
output object Task output information. | |
code string The error code. This field is returned only when a request fails. | |
message string The error message. This field is returned only when a request fails. | |
request_id string The unique request ID, which you can use for troubleshooting. |
Query task results
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Headers | Get task result |
Authorization string Required A Model Studio API key is recommended, but you can also use a DashScope API key. For example: Bearer d1xxx2a. | |
Path parameters | |
task_id string Required The unique ID of the task. |
Response | Task succeededTask results, including image URLs, are available for 24 hours. You must save any generated images within this period, as the task and all associated data are deleted afterward. Partial successThis model can generate multiple images in a single request. The task is marked as SUCCEEDED as long as at least one image is generated successfully. When you query the task, the response includes the successful results. If an image fails to generate, the response includes the corresponding failure reason. You are only billed for successfully generated images. Task running |
output dict The result of the call, which includes the image with text overlays. | |
request_id string The unique request ID. | |
usage dict Statistics on the output. |
(Optional) Configure a domain name whitelist to allow access to image links
The query API response includes an image OSS link, such as https://dashscope-result-xx.oss-cn-xxxx.aliyuncs.com/xxx.png. This link is publicly accessible, and you can use it to view or download the image.
If your business has high security requirements and cannot access external links, you must configure a whitelist. Add the following domain names to your whitelist to access the image links.
-
dashscope-result-bj.oss-cn-beijing.aliyuncs.com
-
dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com
-
dashscope-result-sh.oss-cn-shanghai.aliyuncs.com
-
dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com
-
dashscope-result-zjk.oss-cn-zhangjiakou.aliyuncs.com
-
dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com
-
dashscope-result-hy.oss-cn-heyuan.aliyuncs.com
-
dashscope-result-cd.oss-cn-chengdu.aliyuncs.com
-
dashscope-result-gz.oss-cn-guangzhou.aliyuncs.com
Error codes
If a model call fails and returns an error message, see Error codes for troubleshooting.
This API can also return the following specific error codes.
HTTP status code | API error code | API error message | Description |
200 | Success | Success | The request was successful. |
400 | InvalidParameter | Title field missing. | The title field is missing. |
Title is not [str]. | The title field is not a list of strings. | ||
Title list is empty. | The | ||
Subtitle is not [str]. | The subtitle field is not a list of strings. | ||
Text is not [str]. | The text field is not a list of strings. | ||
Invalid URL 'https:xxx.png': No host supplied | The URL for an image or asset is invalid or inaccessible. | ||
500 | InternalError | Inference error | An internal error occurred in the algorithm. |