All Products
Search
Document Center

Alibaba Cloud Model Studio:Qwen - image translation API reference

Last Updated:Oct 28, 2025

Qwen-MT-Image can accurately translate text in images while preserving the original layout. The model also supports custom features such as domain hints, sensitive word filtering, and terminology intervention.

Important

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

Model overview

Examples

en

Source language: English

ja

Japanese

es

Portuguese

ar

Arabic

Supported languages

When you translate an image, at least one of the source or target languages must be Chinese or English. Direct translation between two non-Chinese or non-English languages, such as from Japanese to Korean, is not supported. If you are unsure of the source language, set source_lang to auto for automatic detection.

Language

Code

As source language

As target language

Chinese

zh

Supported

Supported

English

en

Supported

Supported

Korean

ko

Supported

Supported

Japanese

ja

Supported

Supported

Russian

ru

Supported

Supported

Spanish

es

Supported

Supported

French

fr

Supported

Supported

Portuguese

pt

Supported

Supported

Italian

it

Supported

Supported

Germany

de

Supported

Not supported

Vietnamese

vi

Supported

Supported

Malay

ms

Not supported

Supported

Thai

th

Not supported

Supported

Indonesian

id

Not supported

Supported

Arabic

ar

Not supported

Supported

Model and pricing

Billing is based on the number of successfully translated images. The billing rules are as follows:

  • You are charged when a task succeeds (task_status is SUCCEEDED) and an image is generated.

  • Special case: If no translatable text is found in the image, or if no text remains after subject identification is enabled, the task still succeeds and will incur fees. However, a message No text detected for translation is returned.

  • Requests that fail due to parameter errors, internal service errors, or network connectivity issues do not incur charges.

Model

Unit price

Rate limit (shared by Alibaba Cloud account and RAM users)

Task submission API RPS limit

Number of concurrent tasks

qwen-mt-image

$0.000431/image

1

2

HTTP

You must obtain an API key and set the API key as an environment variable.

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis

Image translation uses the same API endpoint as image synthesis.

Because image translation takes time, the HTTP API uses an asynchronous mode. The process involves two steps:

  1. Create a task and obtain a task ID: Send a request to create a task. The request returns a task ID (task_id).

  2. Query the result using the task ID: Use the task_id to poll the task status until the task is complete and you retrieve the image URL.

Step 1: Create a task and get a task ID

Note
  • After the task is created, use the returned task_id to query the result. The task_id is valid for 24 hours. Do not create duplicate tasks. Use polling to retrieve the result.

Request parameters

Image translation

curl --location 'https://dashscope.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": "qwen-mt-image",
    "input": {
        "image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250916/arpjoo/p1000391.webp",
        "source_lang": "en",
        "target_lang": "ja"
    }
}'

Request headers

Content-Type string (Required)

The content type of the request. Set this parameter to application/json.

Authorization string (Required)

The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx.

X-DashScope-Async string (Required)

The asynchronous processing configuration parameter. HTTP requests support only asynchronous processing. You must set this parameter to enable.

Important

If this request header is missing, the error message "current user api does not support synchronous calls" is returned.

Request body

model string (Required)

The model name. Set it to qwen-mt-image.

input object (Required)

The input parameter object. It contains the following fields:

Properties

image_url string (Required)

A publicly accessible URL of the image. HTTP and HTTPS protocols are supported.

  • Supported formats: JPG, JPEG, PNG, BMP, PNM, PPM, TIFF, or WEBP

  • Dimension limit: The width and height of the image must be between 15 and 8,192 pixels. The aspect ratio must be between 1:10 and 10:1.

  • Size limit: No more than 10 MB

  • If the URL contains non-ASCII characters, you must URL-encode it before submitting it.

    URL encoding

    from urllib.parse import quote
    
    # Replace the following URL with the one you need to encode
    url = "https://example.com/search?q=test&page=1"
    encoded_url = quote(url, safe=':/?#[]@!$&\'()*+,;=%')
    print(f"Original URL: {url}")
    print(f"Encoded URL: {encoded_url}")
  • Example: https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250916/arpjoo/p1000391.webp

source_lang string (Required)

The source language.

  • Supported values: The full language name, language code, or auto (for automatic detection). The value is case-insensitive.

  • Limit: Must be different from target_lang, and at least one of them must be Chinese or English.

  • Example: Chinese, en, or auto

target_lang string (Required)

The target language.

  • Supported values: The full language name or language code. The value is case-insensitive.

  • Limit: Must be different from source_lang, and at least one of them must be Chinese or English.

  • Example: Chinese, en

ext object (Optional)

Optional extended parameters.

Properties

domainHint string (Optional)

A domain hint. To make the translation style more suitable for a specific domain. Use English to describe the scenario, translation style, and other requirements.

To ensure translation quality, the hint should not exceed 200 words.

Important

Domain hints must be in English.

Example: These sentences are from seller-buyer conversations on a B2C ecommerce platform. Translate them into clear, engaging customer service language, ensuring the translation is appropriate for handling potential issues or disputes.

sensitives array (Optional)

A list of sensitive words to filter from the image text before translation. The filter performs an exact match and is case-sensitive.

The language of the sensitive words can be different from the source language. All source languages and target languages are supported. To ensure translation quality, add no more than 50 sensitive words per request.

Example: ["10% off for the whole store", "7-day free return"]

terminologies array (Optional)

A list of custom terms and their translations. The language of each term pair must correspond to source_lang and target_lang.

Properties

src string (Required)

The source text of the term. The language must be the same as source_lang.

tgt string (Required)

The target text of the term. The language must be the same as target_lang.

Example: [{"src": "Application Programming Interface", "tgt": "Interfaz de Programación de Aplicaciones"}, {"src": "machine learning", "tgt": "Aprendizaje Automático"}]

config object (Optional)

Properties

skipImgSegment bool (Optional)

Controls whether to translate text that appears on subjects in the image, such as people, products, or logos.

  • false: (Default) Performs subject detection and does not translate text that appears on subjects.

  • true: Does not perform subject detection and translates all text, including text that appears on subjects.

Response parameters

Successful response

Save the task_id to query the task status and result.

{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

Error response

The task creation failed. For more information, see Error messages to resolve the issue.

{
    "code":"InvalidApiKey",
    "message":"Invalid API-key provided.",
    "request_id":"fb53c4ec-1c12-4fc4-a580-xxxxxx"
}

output object

Task output information.

Properties

task_id string

The task ID. The query is valid for 24 hours.

task_status string

The task status.

Enumeration

  • PENDING

  • RUNNING

  • SUCCEEDED

  • FAILED

  • CANCELED

  • UNKNOWN

request_id string

The unique request ID. You can use this ID to trace and troubleshoot issues.

message string

The detailed information about a failed request. This parameter is not returned if the request is successful. For more information, see Error messages.

code string

The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages.

Step 2: Query the result using the task ID

GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}

Note
  • The model takes about 15 seconds to process. Use a polling mechanism with a reasonable query interval, such as 5 seconds, to retrieve the result.

  • The task_id is valid for 24 hours. If the ID does not exist or has expired, the task status will be UNKNOWN.

  • The url returned for a successful task is valid for 24 hours. Download and save the image promptly.

Request parameters

Query task result

Replace 86ecf553-d340-4e21-xxxxxxxxx with the actual task_id.

curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"
Request headers

Authorization string (Required)

The identity authentication credentials for the request. This API uses an Model Studio API key for identity authentication. Example: Bearer sk-xxxx.

URL path parameters

task_id string (Required)

The task ID.

Response parameters

Task successful

Task data, such as the task status and image URLs, is retained for only 24 hours and is automatically purged after this period. You must save the generated images promptly.

{
    "request_id": "5fec62eb-bf94-91f8-b9f4-f7f758e4e27e",
    "output": {
        "task_id": "72c52225-8444-4cab-ad0c-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-08-13 18:11:16.954",
        "scheduled_time": "2025-08-13 18:11:17.003",
        "end_time": "2025-08-13 18:11:23.860",
        "image_url": "http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx?Expires=xxx"
    },
    "usage": {
        "image_count":1
    }
}

Task failed

If a task fails, task_status is set to FAILED, and an error code and message are provided. For more information, see Error messages to resolve the issue.

{
    "request_id": "daad9007-6acd-9fb3-a6bc-d55902b9c9ff",
    "output": {
        "task_id": "fe8aa114-d9f1-4f76-b598-xxxxxx",
        "task_status": "FAILED",
        "submit_time": "2025-08-20 09:54:21.911",
        "scheduled_time": "2025-08-20 09:54:21.984",
        "end_time": "2025-08-20 12:55:00.818",
        "code": "InternalError",
        "message": "xxxxxx"
    }
}

output object

Task output information.

Properties

task_id string

The task ID. The query is valid for 24 hours.

task_status string

The task status.

Enumeration

  • PENDING

  • RUNNING

  • SUCCEEDED

  • FAILED

  • CANCELED

  • UNKNOWN

submit_time string

The time when the task was submitted. The format is YYYY-MM-DD HH:mm:ss.SSS.

scheduled_time string

The time when the task started running. The format is YYYY-MM-DD HH:mm:ss.SSS.

end_time string

The time when the task was completed. The format is YYYY-MM-DD HH:mm:ss.SSS.

image_url string

The URL of the image generated by the model. The URL is valid for 24 hours. Download and save the image promptly.

code string

The error code for a failed request. This parameter is not returned if the request is successful. For more information, see Error messages.

message string

The detailed information about the failed request, see Error messages.

This parameter is usually not returned for successful requests. However, if the image contains no translatable text (for example, no text remains after subject identification), the request still succeeds, but the message No text detected for translation is returned.

usage object

Usage statistics for the task. Only successful tasks are counted.

Properties

image_count integer

The number of images generated by the model. The value is fixed at 1.

request_id string

The unique request ID. You can use this ID to trace and troubleshoot issues.

Code examples

In addition to cURL, this section provides code examples for other HTTP requests that use polling to obtain results.

Python

# The requests library is required.
import requests
import time
import json
import os

# If you have not configured the environment variable, replace the following line with: DASHSCOPE_API_KEY="sk-xxx"
DASHSCOPE_API_KEY = os.environ['DASHSCOPE_API_KEY']

POST_URL = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis"
GET_URL_TEMPLATE = "https://dashscope.aliyuncs.com/api/v1/tasks/{}"

# Request headers
headers = {
    "X-DashScope-Async": "enable",
    "Authorization": f"Bearer {DASHSCOPE_API_KEY}",
    "Content-Type": "application/json"
}

# Request data
data = {
    "model": "qwen-mt-image",
    "input": {
        "image_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250916/arpjoo/p1000391.webp",
        "source_lang": "en",
        "target_lang": "ja"
    }
}

def send_async_request():
    """
    Sends an asynchronous POST request.
    """
    print("Sending asynchronous POST request...")
    response = requests.post(POST_URL, headers=headers, json=data)
    
    if response.status_code == 200:
        result = response.json()
        print("Request successful. Response:")
        print(json.dumps(result, indent=2, ensure_ascii=False))
        
        # Extract the task_id
        task_id = result.get("output", {}).get("task_id")
        if task_id:
            return task_id
        else:
            raise ValueError("task_id not found in the response")
    else:
        print(f"Request failed. Status code: {response.status_code}")
        print(response.text)
        raise Exception(f"POST request failed: {response.status_code}")

def poll_task_status(task_id, interval=5, max_attempts=10):
    """
    Polls the task status.
    
    :param task_id: The task ID.
    :param interval: The polling interval in seconds.
    :param max_attempts: The maximum number of polling attempts.
    :return: The final task result.
    """
    print(f"\nStart polling task status for task_id: {task_id}")
    
    for attempt in range(1, max_attempts + 1):
        print(f"Polling attempt {attempt}...")
        
        # Construct the GET request URL
        get_url = GET_URL_TEMPLATE.format(task_id)
        
        # Send the GET request
        response = requests.get(get_url, headers={"Authorization": f"Bearer {DASHSCOPE_API_KEY}"})
        
        if response.status_code == 200:
            result = response.json()
            task_status = result.get("output", {}).get("task_status")
            print(f"Current task status: {task_status}")
            
            # If the task is complete or has failed, return the result
            if task_status == "SUCCEEDED":
                print("Task completed successfully")
                return result
            elif task_status == "FAILED":
                print("Task failed")
                return result
            elif task_status == "PENDING" or task_status == "RUNNING":
                # Continue polling
                print(f"Task is still in progress. Polling again in {interval} seconds...")
                time.sleep(interval)
            else:
                print(f"Unknown task status: {task_status}")
                time.sleep(interval)
        else:
            print(f"Polling request failed. Status code: {response.status_code}")
            print(response.text)
            time.sleep(interval)
    
    # Maximum polling attempts exceeded
    raise TimeoutError("Polling timed out. The task did not complete within the expected time.")

def main():
    task_id = send_async_request()
    result = poll_task_status(task_id)
    print("\nFinal task result:")
    print(json.dumps(result, indent=2, ensure_ascii=False))
    if result.get("output", {}).get("task_status") == "SUCCEEDED":
        image_url = result.get("output", {}).get("image_url")
        if image_url:
            print(f"\nGenerated image URL: {image_url}")

if __name__ == "__main__":
    main()

Java

// The Gson library is required.
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.nio.charset.StandardCharsets;

public class Main {
    private static final String POST_URL = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis";
    private static final String GET_URL_TEMPLATE = "https://dashscope.aliyuncs.com/api/v1/tasks/";
    private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();

    public static void main(String[] args) {
        try {
            // 1. Get the API key.
            // If you have not configured the environment variable, replace the following line with: apiKey="sk-xxx"
            String apiKey = System.getenv("DASHSCOPE_API_KEY");
            if (apiKey == null || apiKey.isEmpty()) {
                System.err.println("Please set the DASHSCOPE_API_KEY environment variable.");
                return;
            }

            // 2. Send an asynchronous request.
            String taskId = sendAsyncRequest(apiKey);

            // 3. Poll the task status.
            JsonObject result = pollTaskStatus(apiKey, taskId, 5, 10);

            // 4. Print the final result.
            System.out.println("\nFinal task result:");
            System.out.println(gson.toJson(result));

            // 5. If the task is successful, print the image URL.
            String taskStatus = result.getAsJsonObject("output").get("task_status").getAsString();
            if ("SUCCEEDED".equals(taskStatus)) {
                String imageUrl = result.getAsJsonObject("output").get("image_url").getAsString();
                System.out.println("\nGenerated image URL: " + imageUrl);
            }

        } catch (Exception e) {
            System.err.println("An error occurred during execution: " + e.getMessage());
            e.printStackTrace();
        }
    }

    /**
     * Sends an asynchronous POST request.
     */
    private static String sendAsyncRequest(String apiKey) throws IOException {
        System.out.println("Sending asynchronous POST request...");

        // Build the request data.
        Map<String, Object> data = new HashMap<>();
        data.put("model", "qwen-mt-image");

        Map<String, Object> input = new HashMap<>();
        input.put("image_url", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250916/arpjoo/p1000391.webp");
        input.put("source_lang", "en");
        input.put("target_lang", "ja");
        data.put("input", input);

        String jsonData = gson.toJson(data);

        // Create a connection.
        URL url = new URL(POST_URL);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        // Set the request headers.
        connection.setRequestMethod("POST");
        connection.setRequestProperty("X-DashScope-Async", "enable");
        connection.setRequestProperty("Authorization", "Bearer " + apiKey);
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setDoOutput(true);

        // Send the request body.
        try (OutputStream os = connection.getOutputStream()) {
            byte[] inputBytes = jsonData.getBytes(StandardCharsets.UTF_8);
            os.write(inputBytes, 0, inputBytes.length);
        }

        // Read the response.
        int responseCode = connection.getResponseCode();
        if (responseCode == 200) {
            StringBuilder response = new StringBuilder();
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
            }

            System.out.println("Request successful. Response:");
            JsonObject jsonResponse = gson.fromJson(response.toString(), JsonObject.class);
            System.out.println(gson.toJson(jsonResponse));

            // Extract the task_id.
            JsonObject result = gson.fromJson(response.toString(), JsonObject.class);
            String taskId = result.getAsJsonObject("output").get("task_id").getAsString();
            if (taskId != null && !taskId.isEmpty()) {
                return taskId;
            } else {
                throw new RuntimeException("task_id not found in the response");
            }
        } else {
            System.out.println("Request failed. Status code: " + responseCode);
            StringBuilder errorResponse = new StringBuilder();
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    errorResponse.append(responseLine.trim());
                }
            }
            System.out.println(errorResponse.toString());
            throw new RuntimeException("POST request failed: " + responseCode);
        }
    }

    /**
     * Polls the task status.
     *
     * @param apiKey The API key.
     * @param taskId The task ID.
     * @param interval The polling interval in seconds.
     * @param maxAttempts The maximum number of polling attempts.
     * @return The final task result.
     */
    private static JsonObject pollTaskStatus(String apiKey, String taskId, int interval, int maxAttempts) throws IOException, InterruptedException {
        System.out.println("\nStart polling task status for task_id: " + taskId);

        for (int attempt = 1; attempt <= maxAttempts; attempt++) {
            System.out.println("Polling attempt " + attempt + "...");

            // Construct the GET request URL.
            String getUrl = GET_URL_TEMPLATE + taskId;

            // Create a connection.
            URL url = new URL(getUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();

            // Set the request headers.
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Authorization", "Bearer " + apiKey);

            // Read the response.
            int responseCode = connection.getResponseCode();
            if (responseCode == 200) {
                StringBuilder response = new StringBuilder();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
                    String responseLine;
                    while ((responseLine = br.readLine()) != null) {
                        response.append(responseLine.trim());
                    }
                }

                JsonObject result = gson.fromJson(response.toString(), JsonObject.class);
                String taskStatus = result.getAsJsonObject("output").get("task_status").getAsString();
                System.out.println("Current task status: " + taskStatus);

                // If the task is complete or has failed, return the result.
                if ("SUCCEEDED".equals(taskStatus) || "FAILED".equals(taskStatus)) {
                    System.out.println("Task execution completed");
                    return result;
                } else if ("PENDING".equals(taskStatus) || "RUNNING".equals(taskStatus)) {
                    // Continue polling.
                    System.out.println("Task is still in progress. Polling again in " + interval + " seconds...");
                    TimeUnit.SECONDS.sleep(interval);
                } else {
                    System.out.println("Unknown task status: " + taskStatus);
                    TimeUnit.SECONDS.sleep(interval);
                }
            } else {
                System.out.println("Polling request failed. Status code: " + responseCode);
                StringBuilder errorResponse = new StringBuilder();
                try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
                    String responseLine;
                    while ((responseLine = br.readLine()) != null) {
                        errorResponse.append(responseLine.trim());
                    }
                }
                System.out.println(errorResponse.toString());
                TimeUnit.SECONDS.sleep(interval);
            }
        }

        // Maximum polling attempts exceeded.
        throw new RuntimeException("Polling timed out. The task did not complete within the expected time.");
    }
}

Response

Sending asynchronous POST request...
Request successful. Response:
{
  "request_id": "ba607b73-8743-42cb-a605-c4db9688fc6e",
  "output": {
    "task_id": "9e82f1a9-12f4-4423-93e0-bb49xxxxxxxx",
    "task_status": "PENDING"
  }
}

Start polling task status for task_id: 9e82f1a9-12f4-4423-93e0-bb49xxxxxxxx
Polling attempt 1...
Current task status: RUNNING
Task is still in progress. Polling again in 5 seconds...
Polling attempt 2...
Current task status: RUNNING
Task is still in progress. Polling again in 5 seconds...
Polling attempt 3...
Current task status: SUCCEEDED
Task completed successfully

Final task result:
{
  "request_id": "a1419de4-3f62-4582-8097-e6a66a843536",
  "output": {
    "task_id": "9e82f1a9-12f4-4423-93e0-bb49xxxxxxxx",
    "task_status": "SUCCEEDED",
    "submit_time": "2025-09-13 16:33:14.835",
    "scheduled_time": "2025-09-13 16:33:14.861",
    "end_time": "2025-09-13 16:33:20.436",
    "image_url": "http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx?Expires=xxx",
    "message": ""
  },
  "usage": {
    "image_count": 1
  }
}

Generated image URL: http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx?Expires=xxx

Image access permission configuration

Images generated by the model are stored in Alibaba Cloud OSS. Each image is assigned an OSS link, such as https://dashscope-result-xx.oss-cn-xxxx.aliyuncs.com/xxx.png. The OSS link is publicly accessible. You can use this link to view or download the image. The link is valid for only 24 hours.

If your business has high security requirements and cannot access Alibaba Cloud OSS links, you must configure a public access 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
dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com

Error codes

If a call fails, see Error messages for troubleshooting.

FAQ

Q: How to convert a temporary image link to a permanent one?

A: You cannot directly convert a temporary link to a permanent one. Instead, download the image through a backend service and then upload it to Object Storage Service (OSS), to generate a new permanent link.

Example code: Download an image to your local machine

import requests

def download_and_save_image(image_url, save_path):
    try:
        response = requests.get(image_url, stream=True, timeout=300) # Set a timeout
        response.raise_for_status() # Raise an exception if the HTTP status code is not 200
        with open(save_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print(f"Image successfully downloaded to: {save_path}")
        # You can add the logic to upload to permanent storage here
    except requests.exceptions.RequestException as e:
        print(f"Image download failed: {e}")

if __name__ == '__main__':
    image_url = "http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx?Expires=xxx"
    save_path = "image-translation.jpg"
    download_and_save_image(image_url, save_path)

Q: How to view my model usage?

A: One hour after a request is complete, you can view metrics such as the number of model invocations and success rate on the Model Observation (Singapore) or Model Observation (Beijing) page. For more information, see How do I view model call records?.