API call issues

更新时间:
复制 MD 格式
Note

For more questions about API calls, contact Pre-sales Consultation or join our DingTalk group (ID: 23369411) for expert advice.

Does Machine Translation offer other forms of translation besides text translation?

Machine Translation provides APIs for text translation, image translation (including general images and certificates), and document translation (for formats such as Word, PPT, and Excel). We also offer an online translation platform for non-developers. You can use this platform to directly translate documents, images, and videos.

QPS limit exceeded

If the queries per second (QPS) limit is reached, API calls fail. The QPS limits for each product are listed in the table below. To increase your limit, contact us through our DingTalk group (ID: 23369411).

Product Name

QPS

General-purpose Edition translation engine

50

Professional Edition translation engine

50

Custom translation engine

3

Document Translation

5

General Image Translation

20

E-commerce Image Translation

20

ID Card Translation

10

Driver's License Translation

40

Language Detection

50

Cross-border E-commerce Language Tool (Smart Product Image Translation)

3

Cross-border E-commerce Language Tool (Smart Title Optimization/Generation)

10

Cross-border E-commerce Language Tool (Title Quality Diagnosis)

10

Cross-border E-commerce Language Tool (Image Language Detection)

3

Does Machine Translation offer customized translation services?

For any questions, you can contact our customer service representative at mt_support@list.alibaba-inc.com or join our DingTalk group: 23369411.

Can Machine Translation translate one source language into multiple target languages?

No, Machine Translation does not support translating one source language into multiple target languages in a single API call. To do this, you must call the API multiple times.

What should I do if a RAM user encounters an authorization issue when calling a Machine Translation API?

You can grant permissions to a Resource Access Management (RAM) user by creating a new access policy in the Permission Management section of the RAM console (https://ram.console.aliyun.com/policies).

How to grant permissions to a RAM user

  1. Log on to the RAM console. Go to Identities > Users. Select the RAM user that you want to authorize and click Add Permissions.

  1. Select an access policy.

a. System policy

i. Select System Policy. In the text box, enter mt. The system automatically finds system policies related to Machine Translation.

ii. In the list of policy names, click the policy that you want to add. The policy is added to the Selected list on the right.

    Note

    The RAM user must log on using their RAM username and password.

1. Enter mt in the text box. 2. Select the policy to add. 3. Add the policy to the Selected list on the right. 4. Click OK.

The following table lists the system policies for Machine Translation.

    Policy Name

    Note:

    Details

    AliyunMTFullAccess

    Manage permissions for Machine Translation (alimt)

    Allows access to and operations on all Machine Translation APIs and the console.

    AliyunMTReadOnlyAccess

    Grants read-only permissions for Machine Translation (alimt).

    Allows read-only access to all Machine Translation APIs and the console.

b. Custom policy

i. Add a custom policy

1. Select Custom Policy.

2. In the list of policy names, find the custom policy that you want to add and add it to the Selected list on the right.

3. If the required custom policy is not in the list, you can create it manually.

ii. Create a custom policy

1. Click Create Policy.

2. Select Script Editor.

3. Create an access policy based on your requirements.

Note

You can use a custom policy to grant permissions on one or more API operations.

Note

Sample code for a custom policy:

For example, the requirements for the permission are as follows:

  1. The root account ID is 123456.

  2. The policy allows API calls to the General-purpose Edition of Machine Translation.

In this case, the permission is as follows:

{
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "alimt:TranslateGeneral",
            "Resource": "acs:alimt:*:123456:*"
        }
    ],
    "Version": "1"
}

For more information about how to configure policies, see Manage access policies.

How to obtain a Machine Translation token

  • A RAM user with the required permissions can use their AccessKey pair to call the AssumeRole API operation and obtain a Security Token Service (STS) token for a RAM role.

  • When you perform role-based single sign-on (SSO), you can call the AssumeRoleWithSAML API operation to obtain an STS token for a RAM role.

For more information, see What is STS?

Timeout error when calling the image translation or machine translation API in API Explorer

This error occurs because the service is not activated. You must first activate the service on the product page or in the Machine Translation console before you can call the API.

Cannot find the SDK for a specific language

First, find the API that you want to call in the API reference. Then, click the Debug button to open OpenAPI Explorer and select your preferred programming language.

How to view an AccessKey pair

Log on to the Alibaba Cloud Management Console. Move the mouse pointer over your profile picture in the upper-right corner and select AccessKey Management. You can then view your AccessKey pair. For more information, see Create an AccessKey pair.

Can Machine Translation automatically detect the language like Google Translate?

Yes. For text translation, you can set the source language to `auto` to automatically detect the language. However, image translation does not support this feature.

How to translate multiple items in a batch for text translation

  1. You can use the batch translation feature. For more information, see Call batch machine translation.

  2. You can combine the content into a single request and define a custom delimiter. After the translation is complete, you can split the result in your application based on the delimiter.

Is there a character limit for a single text translation request?

Yes. For a single text translation request, the text string cannot exceed 5,000 characters. The length is calculated using `String.length() <= 5000` in Java. For batch text translation, each item cannot exceed 1,000 characters, and you can translate up to 50 items at a time. If the character limit is exceeded, a timeout error is returned. If your text exceeds the limit, we recommend that you use Document Translation.

How to customize translation results

Source text often contains elements such as proper nouns, terms, non-translatable words, acronyms, and code. Alibaba Cloud Machine Translation provides a pre-processing feature that lets you define how terms or non-translatable elements are handled. You can upload a glossary or dictionary to the intervention platform to customize parts of the machine translation output. For more information, see Use glossary intervention.

Note

The glossary intervention feature is available only in the console and cannot be called using an API.

Can Machine Translation automatically detect the source language?

Yes, but only for text translation. You can call the language detection API operation. For more information, see Introduction to Language Detection. You can also set the source language code to `auto` when you call the translation API.

How to prevent specific characters from being translated

In the source text, enclose the characters that you do not want to translate in a tag. The tagged content appears in the target text untranslated but is still included in billing. Use the following tag format: `I'am a <ALIMT > boy </ALIMT>`.

Note

The content enclosed in the `<ALIMT ></ALIMT>` tags is not translated. Note that a space exists after ALIMT in the opening tag `<ALIMT >`.

Can Machine Translation translate an entire website?

Text Translation supports the HTML format. For more information, see the Machine Translation (General-purpose Edition) API Guide.

Does Machine Translation have a Node.js SDK?

Machine Translation provides a TypeScript SDK for Node.js. For more information, see the TypeScript SDK.

Java SDK call returns an SDK.InvalidRegionId error

  1. Check whether you are using the correct versions of `aliyun-java-sdk-core` and `aliyun-java-sdk-alimt`.

  2. You can try changing the format.

Note

An AccessKey pair of an Alibaba Cloud account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine operations and maintenance (O&M).

We strongly recommend that you do not hard-code the AccessKey ID and AccessKey secret in your project code. If you do, the AccessKey pair may be leaked, which threatens the security of all resources in your account. This example uses the Alibaba Cloud Credentials tool to manage the AccessKey pair for identity verification when you call API operations. For more information about how to configure the tool or environment variables, see https://help.aliyun.com/document_detail/378659.html.

DefaultProfile profile = DefaultProfile.getProfile(
        "cn-hangzhou", // Region ID
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();// Read the access credential from the environment variable.  
IAcsClient client = new DefaultAcsClient(profile);
TranslateGeneralRequest generalRequest = new TranslateGeneralRequest();// Create an API request and set its parameters.
generalRequest.setMethod(MethodType.POST); // Set the request method to POST.
generalRequest.setFormatType("text");  // The format of the text to be translated.
generalRequest.setSourceLanguage("zh");  // Source language
generalRequest.setSourceText(URLEncoder.encode("Hello","UTF-8"));  // Source text
generalRequest.setTargetLanguage("en");  // Target language
System.out.println(JSON.toJSON(eCommerceResponse));                 

Image size limits for the Image Translation API

The image size cannot exceed 10 MB. The image dimensions must be between 15 px and 8,192 px. The aspect ratio cannot exceed 10:1.

Does Document Translation support the PDF format?

Yes, Document Translation supports the PDF format.

Can Audio and Video Translation be called using an API?

No, Audio and Video Translation does not currently support API calls. You can use the online editing platform for audio and video translation. For more information, see User guide for the online editing platform for audio and video translation.

Can Chinese speech in an audio or video file be directly translated into English speech?

No, Chinese speech cannot be directly translated into English speech. You can only translate Chinese speech into English captions.

Image translation fails with a timeout error due to excessive content

You can call the asynchronous image translation API operation.

Where is the product entity text filtering service in Smart Product Image Translation?

image

Issue with the CategoryId value for title optimization

The value of `CategoryId` depends on the value of the `Platform` parameter. If `Platform` is set to an internal Alibaba platform, such as AE, you must pass the corresponding product category ID. If `Platform` is set to an external platform, you can pass the default value `0`.

Description of request parameters for smart title generation

This parameter specifies the underlying category ID for AE. You must call an AE OpenAPI to view the ID. If you are using an external platform, you can pass the default value `0`.

image

In which regions is Machine Translation available?

On the Alibaba Cloud China website, the service is available only in the Hangzhou region. On the Alibaba Cloud International website (www.alibacloud.com), the service is available in the Hangzhou and Singapore regions.

How to disable Machine Translation

You cannot disable the Machine Translation service with a single click because this may affect your business.

If you no longer need the service, you can log on to the Machine Translation console, check the content, back up your data, and then delete all content. For more information about the settings, see Log off from an account.

Alternatively, you can use the following methods to stop using the Machine Translation service or prevent unauthorized use:

  1. Click Create Policy.

  2. Select Script Editor.

  3. Create an access policy based on your requirements.

  4. Note

    You can use a custom policy to grant permissions on one or more API operations.

  5. The Machine Translation service is billed based on usage. If you do not use or call the service, no fees are generated. For products on the Alibaba Cloud China website, bills are generated on an hourly basis. If you have an overdue payment after a bill is generated, the service is immediately suspended.

  6. If you are a developer who calls the Machine Translation API, you can go to the Users page of the RAM console to disable or delete the AccessKey ID of the RAM user that is used to call the API. Alternatively, you can go to the AccessKey Management page to disable or delete the AccessKey ID of the Alibaba Cloud account that is used to call the API.