Skip to main content
Specialized models

Machine translation (Qwen-MT)

Qwen-MT is a machine translation model fine-tuned from Qwen3. It supports 92 languages -- including Chinese, English, Japanese, Korean, French, Spanish, German, Thai, Indonesian, Vietnamese, and Arabic -- and offers term intervention, domain prompting, and translation memory to control translation quality.

How it works

  1. Provide the text to translate: The messages array must contain a single message with its role set to user. The content of this message is the text you want to translate.
  2. Set languages: Specify the source language (source_lang) and target language (target_lang) in the translation_options parameter. For a list of supported languages, see Supported languages. To let the model detect the source language automatically, set source_lang to auto.
    Specifying the source language improves translation accuracy.
    You can also set the language using custom prompts .
The following examples show how to call Qwen-MT using the OpenAI-compatible and DashScope Python SDKs.
# Import dependencies and create a client...
completion = client.chat.completions.create(
    model="qwen-mt-flash",    # Select the model
    # The messages parameter must contain only one message with the role set to user, and its content is the text to be translated.
    messages=[{"role": "user", "content": "No me reí después de ver este video"}],
    # Because translation_options is not a standard OpenAI parameter, it must be passed in the extra_body parameter.
    extra_body={"translation_options": {"source_lang": "auto", "target_lang": "English"}},
)
import os
from openai import OpenAI
client = OpenAI(
    # If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
    model="qwen-mt-flash",
    # The messages parameter must contain exactly one message with the role 'user', and its content is the text to be translated.
    messages=[
        {
            "role": "user",
            "content": "No me reí después de ver este video"
        }
    ],
    # Because translation_options is not a standard OpenAI parameter, you must pass it using the extra_body parameter.
    extra_body={
        # Configure translation options.
        "translation_options": {
            "source_lang": "auto",
            "target_lang": "English"
        }
    },
)
Use the translation_options parameter to access advanced translation features such as term intervention, translation memory, and domain prompting. Limitations
  • Single-turn translation only: Qwen-MT is purpose-built for translation and does not support multi-turn conversations.
  • System messages not supported: You cannot set global behavior through a system-role message. Instead, configure translation behavior in the translation_options parameter.

Model selection

  • For general scenarios, choose qwen-mt-flash. It offers the best balance of quality, speed, and cost, and supports incremental streaming output.
  • For the highest translation quality in professional domains, choose qwen-mt-plus.
  • For the fastest response speed in simple, real-time scenarios, choose qwen-mt-lite.
The following table compares the available models.

Model

Scenario

Result

Speed

Cost

Supported languages

Incremental stream

qwen-mt-plus

Provides high-quality translation for scenarios such as professional fields, formal documents, academic papers, and technical reports

Best

Standard

High

92

Unsupported

qwen-mt-flash

Recommended for general use. Suitable for website and app content, product descriptions, daily communication, and blog posts

Good

Fast

Low

92

Supported

qwen-mt-turbo

This model will not be updated in the future. Use flash instead.

Fair

Fast

Low

92

Unsupported

qwen-mt-lite

Simple, latency-sensitive scenarios like real-time chat and live comment translation

Basic

Fastest

Lowest

31

Supported

Check context window limits and pricing in the console. For concurrent request limits, see Qwen translation model.

Getting started

This section walks through a simple example: translating "No me reí después de ver este video" into English. Obtain an API key and export the API key as an environment variable. If you use the OpenAI SDK or DashScope SDK to make calls, install the SDK.
  • OpenAI compatible
  • DashScope
Sample request
import os
from openai import OpenAI

client = OpenAI(
    # If you have not configured the environment variable, replace the following line with your Alibaba Cloud Model Studio API key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
messages = [
    {
        "role": "user",
        "content": "No me reí después de ver este video"
    }
]
translation_options = {
    "source_lang": "auto",
    "target_lang": "English"
}

completion = client.chat.completions.create(
    model="qwen-mt-plus",
    messages=messages,
    extra_body={
        "translation_options": translation_options
    }
)
print(completion.choices[0].message.content)
Sample response
I didn't laugh after watching this video.

Streaming output

Streaming output delivers translated content incrementally, reducing perceived latency. Currently, qwen-mt-flash and qwen-mt-lite support incremental streaming, where each response contains only the newly generated content. Enable it with the incremental_output parameter. qwen-mt-plus and qwen-mt-turbo support only non-incremental streaming, where each response returns the full translation so far. For more information, see Streaming output.
  • OpenAI compatible
  • DashScope
Sample request
import os
from openai import OpenAI

client = OpenAI(
    # If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
messages = [{"role": "user", "content": "No me reí después de ver este video"}]
translation_options = {"source_lang": "auto", "target_lang": "English"}

completion = client.chat.completions.create(
    model="qwen-mt-flash",
    messages=messages,
    stream=True,
    stream_options={"include_usage": True},
    extra_body={"translation_options": translation_options},
)
for chunk in completion:
    if chunk.choices:
        content = chunk.choices[0].delta.content or ""
        print(content, end="", flush=True)
    else:
        print("="*20+"Usage"+"="*20)
        print(chunk.usage)
Sample response
I didn’t laugh after watching this video.
====================Usage====================
CompletionUsage(completion_tokens=9, prompt_tokens=56, total_tokens=65, completion_tokens_details=None, prompt_tokens_details=None)

Improve translation quality

Basic translation works well for everyday use cases like casual communication. For professional or high-stakes translation tasks, you may run into specific challenges:
  • Inconsistent terminology: Product names or industry-specific terms are translated incorrectly or inconsistently across passages.
  • Mismatched style: The translated text does not match the tone or conventions expected in a specific domain, such as legal or marketing content.
Qwen-MT provides three features to address these challenges: term intervention, translation memory, and domain prompting.

Term intervention

Supply a glossary in the terms field to ensure that brand names, product names, or technical terms are translated consistently every time. To define and pass your glossary:
  1. Define terms Create a JSON array and assign it to the terms field. Each object in the array maps a source term to its required translation:
{
    "source": "term",
    "target": "pre-translated term"
}
  1. Pass the terms Pass the translation_options parameter with your terms array included.
  • OpenAI compatible
  • DashScope
Sample request
import os
from openai import OpenAI

client = OpenAI(
    # If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
messages = [
    {
        "role": "user",
        "content": "Este conjunto de biosensores utiliza grafeno, un material novedoso. Su objetivo son los elementos químicos. Su agudo «sentido del olfato» le permite reflejar el estado de salud del cuerpo de forma más profunda y precisa."
    }
]

# --- First request: without the terms parameter ---
print("--- [Translation result without terms] ---")
translation_options_without_terms = {
    "source_lang": "auto",
    "target_lang": "English"
}

completion_without_terms = client.chat.completions.create(
    model="qwen-mt-turbo",
    messages=messages,
    extra_body={
        "translation_options": translation_options_without_terms
    }
)
print(completion_without_terms.choices[0].message.content)

print("\n" + "="*50 + "\n") # Separator for comparison

# --- Second request: with the terms parameter ---
print("--- [Translation result with terms] ---")
translation_options_with_terms = {
    "source_lang": "auto",
    "target_lang": "English",
    "terms": [
        {
            "source": "biosensor",
            "target": "biological sensor"
        },
        {
            "source": "estado de salud del cuerpo",
            "target": "health status of the body"
        }
    ]
}

completion_with_terms = client.chat.completions.create(
    model="qwen-mt-turbo",
    messages=messages,
    extra_body={
        "translation_options": translation_options_with_terms
    }
)
print(completion_with_terms.choices[0].message.content)
Sample responseAfter you add the glossary, the translation output reflects your specified terms: "biological sensor" and "health status of the body".
--- [Translation result without terms] ---
This set of biosensors uses graphene, a new material, whose target substance is chemical elements. Its sensitive "sense of smell" allows it to more deeply and accurately reflect one's health condition.

==================================================

--- [Translation result with terms] ---
This biological sensor uses a new material called graphene. Its target is chemical elements, and its sensitive "sense of smell" enables it to reflect the health status of the body more deeply and accurately.

Translation memory

When you need the model to follow a specific translation style or sentence pattern, provide source-target sentence pairs as examples in the tm_list field. The model learns from the style of these reference pairs and applies it to the current translation. This is useful for maintaining consistency across large documentation sets or when adapting to an organization’s established writing conventions.
  1. Define the translation memory Create a JSON array named tm_list. Each object pairs a source sentence with its reference translation:
{
    "source": "source statement",
    "target": "translated statement"
}
  1. Pass the translation memory Include the translation_options parameter with your translation memory array.
The following example demonstrates translation memory in action.
  • OpenAI compatible
  • DashScope
Sample request
import os
from openai import OpenAI

client = OpenAI(
    # If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
messages = [
    {
        "role": "user",
        "content": "El siguiente comando muestra la información de la versión de Thrift instalada."
    }
]
translation_options = {
    "source_lang": "auto",
    "target_lang": "English",
    "tm_list": [
        {
            "source": "Puede utilizar uno de los siguientes métodos para consultar la versión del motor de un clúster:",
            "target": "You can use one of the following methods to query the engine version of a cluster:"
        },
        {
            "source": "La versión de Thrift utilizada por nuestro HBase en la nube es la 0.9.0. Por lo tanto, recomendamos que la versión del cliente también sea la 0.9.0. Puede descargar Thrift 0.9.0 desde aquí. El paquete de código fuente descargado se utilizará posteriormente. Primero debe instalar el entorno de compilación de Thrift. Para la instalación desde el código fuente, puede consultar el sitio web oficial de Thrift.",
            "target": "The version of Thrift used by ApsaraDB for HBase is 0.9.0. Therefore, we recommend that you use Thrift 0.9.0 to create a client. Click here to download Thrift 0.9.0. The downloaded source code package will be used later. You must install the Thrift compiling environment first. For more information, see Thrift official website."
        },
        {
            "source": "Puede instalar el SDK a través de PyPI. El comando de instalación es el siguiente:",
            "target": "You can run the following command in Python Package Index (PyPI) to install Elastic Container Instance SDK for Python:"
        }
    ]
}

completion = client.chat.completions.create(
    model="qwen-mt-plus",
    messages=messages,
    extra_body={
        "translation_options": translation_options
    }
)
print(completion.choices[0].message.content)
Sample response
You can run the following command to view the version of Thrift that is installed:

Domain prompting

Pass a domain prompt in translation_options to tailor the translation style for a specific field. For example, legal or government content calls for formal language, while social media posts work better with a conversational tone.
Domain prompts currently support only English.
  • OpenAI compatible
  • DashScope
Sample request
import os
from openai import OpenAI

client = OpenAI(
    # If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
messages = [
    {
        "role": "user",
        "content": "La segunda instrucción SELECT devuelve un número que indica la cantidad de filas que habría devuelto la primera instrucción SELECT si no se hubiera utilizado la cláusula LIMIT."
    }
]

# --- First request: without the domains parameter ---
print("--- [Translation result without domains] ---")
translation_options_without_domains = {
    "source_lang": "auto",
    "target_lang": "English",
}

completion_without_domains = client.chat.completions.create(
    model="qwen-mt-plus",
    messages=messages,
    extra_body={
        "translation_options": translation_options_without_domains
    }
)
print(completion_without_domains.choices[0].message.content)

print("\n" + "="*50 + "\n") # Separator for comparison

# --- Second request: with the domains parameter ---
print("--- [Translation result with domains] ---")
translation_options_with_domains = {
    "source_lang": "auto",
    "target_lang": "English",
    "domains": "The sentence is from Ali Cloud IT domain. It mainly involves computer-related software development and usage methods, including many terms related to computer software and hardware. Pay attention to professional troubleshooting terminologies and sentence patterns when translating. Translate into this IT domain style."
}

completion_with_domains = client.chat.completions.create(
    model="qwen-mt-plus",
    messages=messages,
    extra_body={
        "translation_options": translation_options_with_domains
    }
)
print(completion_with_domains.choices[0].message.content)
Sample response
--- [Translation result without domains] ---
The second SELECT statement returns a number indicating how many rows the first SELECT statement would return without the LIMIT clause.

==================================================

--- [Translation result with domains] ---
The second SELECT statement returns a number that indicates how many rows the first SELECT statement would have returned if it had not included a LIMIT clause.

Custom prompts

Use custom prompts with Qwen-MT to control details such as the target language, tone, or domain. The translation_options parameter and custom prompts can be passed together, but when both are set simultaneously, settings in translation_options (such as target_lang, source_lang, and so on) take priority over corresponding settings in the custom prompt and will override language or style specifications in the custom prompt.
For the best translation results, use translation_options to configure translation settings instead.
The following example shows a Spanish-to-English legal translation using a detailed prompt:
  • OpenAI compatible
  • DashScope
import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the following line with your Alibaba Cloud Model Studio API Key: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The base_url varies by region. Update it based on the region you use.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
prompt_template = """
# Role
You are a professional legal translation expert, proficient in both Spanish and English, and you are especially skilled at handling commercial contracts and legal documents.

# Task
I need you to translate the following Spanish legal text into professional, accurate, and formal English.

# Translation Requirements
1.  **Fidelity to the Original**: Strictly translate according to the meaning and legal intent of the original text. Do not add or omit information.
2.  **Precise Terminology**: Use standard legal terms common in the Common Law system. For example, "甲方" should be translated as "Party A", "乙方" as "Party B", and "不可抗力" as "Force Majeure".
3.  **Formal Tone**: Maintain the rigorous, objective, and formal style inherent in legal documents.
4.  **Clarity of Language**: The translation must be clear, unambiguous, and conform to the expressive conventions of English legal writing.
5.  **Format Preservation**: Retain the paragraphs, numbering, and basic format of the original text.

# Text to be Translated
{text_to_translate}
"""

# --- 2. Prepare the legal text to be translated ---
chinese_legal_text = "Este contrato entrará en vigor a partir de la fecha en que ambas partes lo firmen y sellen, y tendrá una vigencia de un año."
final_prompt = prompt_template.format(text_to_translate=chinese_legal_text)

# --- 3. Construct the messages ---
messages = [{"role": "user", "content": final_prompt}]

# --- 4. Initiate the API request ---
completion = client.chat.completions.create(model="qwen-mt-plus", messages=messages)

# --- 5. Print the model's translation result ---
translation_result = completion.choices[0].message.content
print(translation_result)
Sample response
This Contract shall become effective from the date on which both parties sign and affix their seals, and its term of validity shall be one year.

Going live

  • Control the input token count Qwen-MT models accept a maximum of 8,192 input tokens. For longer content, use the following strategies to stay within this limit:
    • Translate in segments: Break long text into manageable chunks at natural semantic boundaries -- such as paragraphs or complete sentences -- rather than splitting by character count. This preserves contextual coherence and yields more accurate translations.
    • Provide only the most relevant references: Terms, translation memory entries, and domain prompts all consume input tokens. Include only references directly relevant to the text being translated. Avoid passing large, generic reference lists.
  • Setsource_langbased on the scenario
    • When the source language is uncertain -- for example, in multilingual chat scenarios -- set source_lang to auto. The model identifies the language automatically.
    • When the source language is known and accuracy is critical -- such as for technical documentation or operation manuals -- always specify source_lang explicitly. This improves translation accuracy.

Supported languages

When sending a request, use either the English name or the Code from the tables below.
If you are unsure of the source language, you can set the source_lang parameter to auto for automatic detection.
  • Languages supported by qwen-mt-plus/flash/turbo (92)
  • Languages supported by qwen-mt-lite (31)

Language

English name

Code

English

English

en

Simplified Chinese

Chinese

zh

Traditional Chinese

Traditional Chinese

zh_tw

Russian

Russian

ru

Japanese

Japanese

ja

Korean

Korean

ko

Spanish

Spanish

es

French

French

fr

Portuguese

Portuguese

pt

German

German

de

Italian

Italian

it

Thai

Thai

th

Vietnamese

Vietnamese

vi

Indonesian

Indonesian

id

Malay

Malay

ms

Arabic

Arabic

ar

Hindi

Hindi

hi

Hebrew

Hebrew

he

Burmese

Burmese

my

Tamil

Tamil

ta

Urdu

Urdu

ur

Bengali

Bengali

bn

Polish

Polish

pl

Dutch

Dutch

nl

Romanian

Romanian

ro

Turkish

Turkish

tr

Khmer

Khmer

km

Lao

Lao

lo

Cantonese

Cantonese

yue

Czech

Czech

cs

Greek

Greek

el

Swedish

Swedish

sv

Hungarian

Hungarian

hu

Danish

Danish

da

Finnish

Finnish

fi

Ukrainian

Ukrainian

uk

Bulgarian

Bulgarian

bg

Serbian

Serbian

sr

Telugu

Telugu

te

Afrikaans

Afrikaans

af

Armenian

Armenian

hy

Assamese

Assamese

as

Asturian

Asturian

ast

Basque

Basque

eu

Belarusian

Belarusian

be

Bosnian

Bosnian

bs

Catalan

Catalan

ca

Cebuano

Cebuano

ceb

Croatian

Croatian

hr

Egyptian Arabic

Egyptian Arabic

arz

Estonian

Estonian

et

Galician

Galician

gl

Georgian

Georgian

ka

Gujarati

Gujarati

gu

Icelandic

Icelandic

is

Javanese

Javanese

jv

Kannada

Kannada

kn

Kazakh

Kazakh

kk

Latvian

Latvian

lv

Lithuanian

Lithuanian

lt

Luxembourgish

Luxembourgish

lb

Macedonian

Macedonian

mk

Maithili

Maithili

mai

Maltese

Maltese

mt

Marathi

Marathi

mr

Mesopotamian Arabic

Mesopotamian Arabic

acm

Moroccan Arabic

Moroccan Arabic

ary

Najdi Arabic

Najdi Arabic

ars

Nepali

Nepali

ne

North Azerbaijani

North Azerbaijani

az

North Levantine Arabic

North Levantine Arabic

apc

Northern Uzbek

Northern Uzbek

uz

Norwegian Bokmål

Norwegian Bokmål

nb

Norwegian Nynorsk

Norwegian Nynorsk

nn

Occitan

Occitan

oc

Odia

Odia

or

Pangasinan

Pangasinan

pag

Sicilian

Sicilian

scn

Sindhi

Sindhi

sd

Sinhala

Sinhala

si

Slovak

Slovak

sk

Slovenian

Slovenian

sl

South Levantine Arabic

South Levantine Arabic

ajp

Swahili

Swahili

sw

Tagalog

Tagalog

tl

Ta’izzi-Adeni Arabic

Ta’izzi-Adeni Arabic

acq

Tosk Albanian

Tosk Albanian

sq

Tunisian Arabic

Tunisian Arabic

aeb

Venetian

Venetian

vec

Valaisan

Waray

war

Welsh

Welsh

cy

Western Persian

Western Persian

fa

API reference

For detailed input and output parameter specifications, see Qwen-MT.
Token Plan
Statistics and Monitoring
Support