BatchTranslate

更新时间:
复制 MD 格式

Tongyi Multimodal Translation: Batch Translation

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

anytrans:BatchTranslate

none

*All Resource

*

None None

Request syntax

POST /anytrans/translate/batch HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

workspaceId

string

Yes

The ID of the Model Studio workspace used for this request.

llm-kqtrcpdee4xm29xx

sourceLanguage

string

Yes

The source language.

zh

targetLanguage

string

Yes

The target language.

en

text

object

Yes

A map of texts to translate, in which the key is a custom identifier and the value is the source text.

{"0":"明天天气怎么样?","1":"你中午吃饭了吗"}

scene

string

No

The translation model.

Valid values:

  • mt-plus :

    Professional Edition

  • mt-turbo :

    Lightweight Edition

mt-turbo

format

string

No

The translation format.

text

appName

string

No

The name of the calling application.

baidufanyi

ext

object

No

The extended parameters that control translation features.

examples

array<object>

No

A list of translation examples.

object

No

A translation example.

tgt

string

No

The target text.

hello

src

string

No

The source text.

你好

domainHint

string

No

A natural language instruction in English that guides the model's translation style.

this sentence from an e-commerce product image, please provide a translation that is both highly concise and no more than 1.2 times the length of the original.

sensitives

array

No

A list of sensitive terms.

string

No

A sensitive term to filter out.

password

terminologies

array<object>

No

A list of custom terminology for overriding translations.

object

No

A terminology pair for a translation override.

tgt

string

No

The target text to use for the override.

API

src

string

No

The source text to be overridden.

应用接口

textTransform

object

No

Specifies case transformations for the translated text.

toLower

boolean

No

Specifies whether to convert the entire translated text to lowercase.

Valid values:

  • true :

    Converts the translated text to lowercase.

  • false :

    Does not convert the translated text to lowercase (default).

false

toUpper

boolean

No

Specifies whether to convert the entire translated text to uppercase.

Valid values:

  • true :

    Converts the translated text to uppercase.

  • false :

    Does not convert the translated text to uppercase (default).

false

toTitle

boolean

No

Specifies whether to convert the entire translated text to title case.

Valid values:

  • true :

    Converts the translated text to title case.

  • false :

    Does not convert the translated text to title case (default).

false

config

object

No

Controls the translation behavior.

skipCsiCheck

boolean

No

Specifies whether to skip the Content Moderation check. To set this to true, you must first complete the required process to disable Content Moderation.

Valid values:

  • true :

    Skips the Content Moderation check.

  • false :

    Performs the Content Moderation check (default).

false

paramMap

any

No

Extended parameters for applying custom terminology that is isolated by user or business scenario.

Valid values:

  • bizType :

    The business scenario type.

  • bizUserId :

    The business user ID.

{"bizUserld":"123456","bizType":session"}

langDetect

boolean

No

Specifies whether to enable automatic detection of the source language. If set to true, the sourceLanguage parameter is ignored.

Response elements

Element

Type

Description

Example

object

The schema of the response body.

code

string

The status code for the overall API call.

200

message

string

The response message.

success

requestId

string

The unique identifier for the request. Use this ID for tracing and troubleshooting.

3BE338D3-16B1-513F-8DD2-57C8528DEAAA

success

boolean

Indicates whether the API call was successful.

Valid values:

  • true :

    The API call was successful.

  • false :

    The API call failed.

true

httpStatusCode

string

The HTTP status code.

200

data

object

The response payload that contains the translation results.

translationList

array<object>

An array of translation results, one for each text provided in the request.

array<object>

A single translation result.

code

integer

The status code for the individual translation within the batch.

200

message

string

The status message for the individual translation.

OK

index

string

The zero-based index of this result, which corresponds to the order of the source text in the original request.

0

translation

string

The translated text.

What will the weather be like tomorrow?

detectedLang

string

The language code of the detected source language.

usage

object

An object detailing the token usage for this translation.

inputTokens

integer

The number of tokens in the source text.

53

outputTokens

integer

The number of tokens in the generated translation.

8

totalTokens

integer

The total number of tokens processed for the translation (the sum of inputTokens and outputTokens).

61

Examples

Success response

JSON format

{
  "code": "200",
  "message": "success",
  "requestId": "3BE338D3-16B1-513F-8DD2-57C8528DEAAA",
  "success": true,
  "httpStatusCode": "200",
  "data": {
    "translationList": [
      {
        "code": 200,
        "message": "OK",
        "index": "0",
        "translation": "What will the weather be like tomorrow?",
        "detectedLang": "",
        "usage": {
          "inputTokens": 53,
          "outputTokens": 8,
          "totalTokens": 61
        }
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 IdempotentParameterMismatch The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.