Qwen MT Lite
alibaba/qwen-mt-lite — a llm model by Alibaba. Call it through the gateway’s standard OpenAI-compatible door using the catalog slug; the full parameter schema is reproduced in full below.
| Catalog slug | alibaba/qwen-mt-lite |
| Kind | llm |
| Vendor | Alibaba |
| Native model id | qwen-mt-lite |
How to call
Section titled “How to call”Through the Sociaro SDK / OpenAI-compatible door
Section titled “Through the Sociaro SDK / OpenAI-compatible door”from sociaro_ai import Sociaro
client = Sociaro(api_key="gw_live_...") # base_url defaults to https://api.sociaro.com
resp = client.chat.completions.create( model="alibaba/qwen-mt-lite", # always the catalog slug messages=[{"role": "user", "content": "Hello"}], # any parameter from the schema below is passed through unchanged)print(resp.choices[0].message.content)TypeScript: client.chat.completions.create({ model: "alibaba/qwen-mt-lite", messages: [...] }) — see the TypeScript SDK.
Through Alibaba DashScope’s native API (advanced)
Section titled “Through Alibaba DashScope’s native API (advanced)”Optional: send Alibaba DashScope’s native request to the /alibaba prefix, using the native model id qwen-mt-lite. The gateway injects the upstream Alibaba DashScope credential and forwards the body unchanged (catalog, pricing and entitlements still apply).
curl https://api.sociaro.com/alibaba/<native-path> \ -H "Authorization: Bearer $SOCIARO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen-mt-lite", ... }'The exact path, request body and response shape are documented in full in the schema below.
Parameters — full schema
Section titled “Parameters — full schema”The complete, one-to-one API schema for this model, transcribed from the official source. Nothing omitted. Examples in the schema may use a representative model of the family — for this model use the slug alibaba/qwen-mt-lite (or the native id qwen-mt-lite for the native API) as shown in How to call above.
Per-model coverage map
Section titled “Per-model coverage map”| Author slug (catalog) | Model name (API model) | Covered by this schema | Languages | Incremental streaming | Domain prompting | Status |
|---|---|---|---|---|---|---|
alibaba/qwen-mt-plus | qwen-mt-plus | Yes | 92 | No (non-incremental) | Yes | Best quality / Standard speed / High cost |
alibaba/qwen-mt-flash | qwen-mt-flash | Yes | 92 | Yes (incremental) | Yes | Recommended default — Good / Fast / Low cost |
alibaba/qwen-mt-lite | qwen-mt-lite | Yes | 31 (subset) | Yes (incremental) | No | Basic / Fastest / Lowest cost |
| (legacy) | qwen-mt-turbo | Listed as supported model value | 92 | No (non-incremental) | Yes | ”This model will not be updated in the future. Use flash instead.” Fair / Fast / Low |
All four model names are accepted in the model field. The target catalog family is flash/lite/plus; qwen-mt-turbo is documented for completeness (legacy, deprecated for updates).
Critical per-model differences
Section titled “Critical per-model differences”- qwen-mt-lite supports only 31 languages, NOT the full 92. (plus/flash/turbo = 92.) See section D for both lists.
- qwen-mt-lite does not support domain prompting (
translation_options.domains). Confirmed by the official Java SDK example comment in the user guide:// Note: qwen-mt-lite does not support domain prompting. plus/flash/turbo support it. - Incremental streaming:
qwen-mt-flashandqwen-mt-litestream incrementally (each chunk = only the new content).qwen-mt-plusandqwen-mt-turbostream non-incrementally (each chunk = the entire sequence generated so far). This behavior cannot be changed. - Everything else (parameter set, defaults, value ranges, request/response shape, the
translation_optionsschema) is identical across all four models.
Family-wide notes (important for gateway transparent-first passthrough)
Section titled “Family-wide notes (important for gateway transparent-first passthrough)”translation_optionswithsource_lang+target_langis required on every translation request.source_lang: "auto"= automatic source-language detection.- Exactly one user message;
systemrole and multi-turn dialogues are not supported. (Translation behavior is set viatranslation_options, not via a system message.) - Custom prompts feature: you can instead drive the model with a plain instruction prompt in
contentand omittranslation_options. The two approaches are mutually exclusive — if you supply both,translation_optionsmay be ignored. For best results the docs recommend usingtranslation_options. - Hard input limit: 8,192 input tokens per request.
terms/tm_list/domainsalso consume input tokens. Long text must be segmented at semantic boundaries. top_k(default 1) andrepetition_penalty(default 1.0) are non-standard OpenAI parameters: in the Python OpenAI SDK they go intoextra_body; in the Node.js SDK / direct HTTP they are top-level. Same handling applies totranslation_optionsitself.- Sampling defaults are Qwen-MT-specific:
temperature=0.65(NOT 0.7/1.0),top_p=0.8,top_k=1,repetition_penalty=1.0. - The
domainsprompt text must be written in English, regardless of the source/target language pair. - Two protocols: OpenAI-compatible (
/compatible-mode/v1/chat/completions) and native DashScope (/api/v1/services/aigc/text-generation/generation). In native DashScope:messages→input.messages; all params →parameters.*; auth header has noBearer; Java SDK 2.20.6+; streaming viaX-DashScope-SSE: enableheader +incremental_output. - Context-window limits and pricing are in the Model Studio console; concurrency/rate limits are on the rate-limit page (Qwen Translation Models).
- For the gateway:
translation_optionspasses through in the body; billing usesinput_tokens/output_tokens(native) orprompt_tokens/completion_tokens(OpenAI-compatible) fromusage.
How it works (from user guide)
Section titled “How it works (from user guide)”- Provide text to translate:
messagesmust contain a single message withrole: "user"; itscontentis the text to translate. - Set languages: specify
source_langandtarget_langinsidetranslation_options. Setsource_lang: "auto"for auto-detection. - Optional quality controls: Term intervention (
terms), Translation memory (tm_list), Domain prompting (domains).
Limitations (verbatim intent):
- Single-turn translation only — Qwen-MT does not support multi-turn conversations.
- System messages not supported — global behavior is configured through
translation_options, not asystem-role message. - Max 8,192 input tokens per request.
- Language support: qwen-mt-plus/flash/turbo = 92; qwen-mt-lite = 31.
- Domain prompting not supported by qwen-mt-lite.
- Streaming incremental vs non-incremental as in the per-model differences above; cannot be changed.
A. OpenAI-compatible mode
Section titled “A. OpenAI-compatible mode”Endpoints (by region)
Section titled “Endpoints (by region)”| Region | base_url (SDK) | HTTP endpoint |
|---|---|---|
| Beijing | https://dashscope.aliyuncs.com/compatible-mode/v1 | POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions |
| Singapore | https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1 | POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions |
| Virginia (US) | https://dashscope-us.aliyuncs.com/compatible-mode/v1 | POST https://dashscope-us.aliyuncs.com/compatible-mode/v1/chat/completions |
Auth header: Authorization: Bearer $DASHSCOPE_API_KEY.
Request body shape (OpenAI-compatible)
Section titled “Request body shape (OpenAI-compatible)”All fields are top-level in the JSON body. translation_options, top_k, repetition_penalty are non-standard for OpenAI: in the Python OpenAI SDK pass them via extra_body; in the Node.js SDK / direct HTTP they are ordinary top-level fields.
{ "model": "qwen-mt-plus", "messages": [ { "role": "user", "content": "<text to translate>" } ], "stream": false, "stream_options": { "include_usage": false }, "max_tokens": 0, "seed": 0, "temperature": 0.65, "top_p": 0.8, "top_k": 1, "repetition_penalty": 1.0, "translation_options": { "source_lang": "auto", "target_lang": "English", "terms": [ { "source": "...", "target": "..." } ], "tm_list": [ { "source": "...", "target": "..." } ], "domains": "<english domain prompt>" }}All request parameters (OpenAI-compatible)
Section titled “All request parameters (OpenAI-compatible)”| Parameter | Type | Required | Default | Allowed values / range | Description |
|---|---|---|---|---|---|
model | string | Yes | — | qwen-mt-plus, qwen-mt-flash, qwen-mt-lite, qwen-mt-turbo | Model name. |
messages | array | Yes | — | array of exactly 1 user message | Messages providing context. Only user messages are supported. |
messages[].role | string | Yes | — | user | Must be user. |
messages[].content | string | Yes | — | any text | Sentence/text to translate. |
stream | boolean | No | false | true | false | Streaming output. true → response in chunks; client reconstructs. flash/lite → incremental; plus/turbo → non-incremental (cannot be changed). |
stream_options | object | No | — | — | Streaming config. Takes effect only when stream:true. |
stream_options.include_usage | boolean | No | false | true | false | Include token-usage info in the last chunk. |
max_tokens | integer | No | model max output length | up to model max output length | Max tokens to generate; output truncated if exceeded. Default and max = model’s max output length. |
seed | integer | No | — | [0, 2^31 − 1] | Seed for reproducibility. Same seed + same params → consistent output. |
temperature | float | No | 0.65 | [0, 2) | Sampling temperature; higher → more diverse. Set only one of temperature/top_p. |
top_p | float | No | 0.8 | (0, 1.0] | Nucleus sampling threshold; higher → more diverse. Set only one of temperature/top_p. |
top_k | integer | No | 1 | >= 0; if None or > 100 → top_k disabled, only top_p applies | Candidate-set size for sampling. Non-standard OpenAI param: Python SDK → extra_body={"top_k": ...}; Node.js SDK / HTTP → top-level. |
repetition_penalty | float | No | 1.0 | > 0, no strict upper limit; 1.0 = no penalty | Penalty for repetition in consecutive sequences; higher → less repetition. Non-standard: Python SDK → extra_body; Node.js SDK / HTTP → top-level. |
translation_options | object | Yes | — | see below | Translation parameters. Non-standard OpenAI param: Python SDK → extra_body={"translation_options": ...}; Node.js SDK / HTTP → top-level. |
translation_options — full nested schema (identical in both protocols)
Section titled “translation_options — full nested schema (identical in both protocols)”| Field | Type | Required | Allowed values | Description |
|---|---|---|---|---|
source_lang | string | Yes | full English language name (see language tables) OR auto | Source language. auto → model auto-detects input language. Specifying the explicit language improves accuracy. |
target_lang | string | Yes | full English language name (see language tables) | Target language. |
terms | array | No | array of objects | Term list for the Term intervention feature (terminology override). |
terms[].source | string | Yes (within terms) | string | Term in the source language. |
terms[].target | string | Yes (within terms) | string | Term in the target language. |
tm_list | array | No | array of objects | Translation-memory entries for the Translation memory feature. |
tm_list[].source | string | Yes (within tm_list) | string | Statement in the source language. |
tm_list[].target | string | Yes (within tm_list) | string | Statement in the target language. |
domains | string | No | string (in English) | Domain prompt for the Domain prompting feature. Must be in English. Not supported by qwen-mt-lite. |
Note on terms / tm_list: both use the same object shape { "source": "...", "target": "..." }. For terms it is “source term → desired target term”; for tm_list it is “source sentence → its translation”.
Response shape — non-streaming (OpenAI-compatible)
Section titled “Response shape — non-streaming (OpenAI-compatible)”{ "id": "chatcmpl-999a5d8a-f646-4039-968a-167743ae0f22", "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "I didn't laugh after watching this video.", "refusal": null, "role": "assistant", "annotations": null, "audio": null, "function_call": null, "tool_calls": null } } ], "created": 1762346157, "model": "qwen-mt-plus", "object": "chat.completion", "service_tier": null, "system_fingerprint": null, "usage": { "completion_tokens": 9, "prompt_tokens": 53, "total_tokens": 62, "completion_tokens_details": null, "prompt_tokens_details": null }}Response fields (non-streaming):
| Field | Type | Description |
|---|---|---|
id | string | Unique request ID. |
choices[] | array | Model-generated content. |
choices[].finish_reason | string | stop (complete) | length (output length limit reached). |
choices[].index | integer | Index in the choices array. |
choices[].logprobs | — | Present in payload; null. |
choices[].message.content | string | Translation result. |
choices[].message.role | string | Fixed assistant. |
choices[].message.refusal | string | Currently fixed null. |
choices[].message.annotations | — | Present in payload; null. |
choices[].message.audio | object | Currently fixed null. |
choices[].message.function_call | object | Currently fixed null. |
choices[].message.tool_calls | array | Currently fixed null. |
created | integer | UNIX timestamp of request creation. |
model | string | Model used. |
object | string | Always chat.completion. |
service_tier | string | Currently fixed null. |
system_fingerprint | string | Currently fixed null. |
usage.prompt_tokens | integer | Input tokens. |
usage.completion_tokens | integer | Output tokens. |
usage.total_tokens | integer | prompt + completion. |
usage.completion_tokens_details | object | Currently fixed null. |
usage.prompt_tokens_details | object | Currently fixed null. |
Response shape — streaming chunk (OpenAI-compatible)
Section titled “Response shape — streaming chunk (OpenAI-compatible)”object: "chat.completion.chunk". Each chunk carries choices[].delta instead of choices[].message.
| Field | Type | Description |
|---|---|---|
id | string | Same ID across all chunks of the call. |
choices[] | array | Generated content. Empty [] in the last chunk when include_usage:true. |
choices[].delta.content | string | Translation increment. flash/lite → incremental (only new content); plus/turbo → non-incremental (full sequence to date). |
choices[].delta.role | string | Has a value only in the first chunk (assistant); null afterward. |
choices[].delta.function_call | object | Currently fixed null. |
choices[].delta.refusal | object | Currently fixed null. |
choices[].delta.tool_calls | array | Currently fixed null. |
choices[].finish_reason | string | null during generation; then stop (complete) | length. |
choices[].index | integer | Index in choices. |
choices[].logprobs | — | null. |
created | integer | UNIX timestamp; same across chunks. |
model | string | Model used. |
object | string | Always chat.completion.chunk. |
service_tier | string | Fixed null. |
system_fingerprint | string | Fixed null. |
usage | object | null on normal chunks; populated only in the last chunk when include_usage:true (same shape as non-streaming usage). |
Example last chunk (with include_usage:true):
{"id":"chatcmpl-...","choices":[],"created":1762504029,"model":"qwen-mt-flash","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":{"completion_tokens":9,"prompt_tokens":56,"total_tokens":65,"completion_tokens_details":null,"prompt_tokens_details":null}}Example incremental chunk (flash/lite):
{"id":"chatcmpl-...","choices":[{"delta":{"content":" didn","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1762504029,"model":"qwen-mt-flash","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}Example non-incremental chunk (plus/turbo — note delta.content carries the full string so far):
{"id":"chatcmpl-...","choices":[{"delta":{"content":"I didn't laugh after","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1762346453,"model":"qwen-mt-plus","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}B. Native DashScope mode
Section titled “B. Native DashScope mode”Endpoints
Section titled “Endpoints”| Region | HTTP endpoint | base_http_api_url (SDK) |
|---|---|---|
| Beijing | POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation | https://dashscope.aliyuncs.com/api/v1 (default, can be omitted) |
| Singapore | POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation | https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1 |
| Virginia (US) | POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/text-generation/generation | https://dashscope-us.aliyuncs.com/api/v1 |
Auth header: Authorization: $DASHSCOPE_API_KEY (no Bearer, unlike OpenAI mode). DashScope Java SDK requires version 2.20.6+.
Request body shape (native DashScope HTTP)
Section titled “Request body shape (native DashScope HTTP)”messages lives under input; all parameters live under parameters:
{ "model": "qwen-mt-plus", "input": { "messages": [ { "content": "<text to translate>", "role": "user" } ] }, "parameters": { "translation_options": { "source_lang": "auto", "target_lang": "English", "terms": [ { "source": "...", "target": "..." } ], "tm_list": [ { "source": "...", "target": "..." } ], "domains": "<english domain prompt>" }, "max_tokens": 0, "seed": 0, "temperature": 0.65, "top_p": 0.8, "top_k": 1, "repetition_penalty": 1.0, "incremental_output": true }}Parameters (native DashScope) — placement differences from OpenAI mode
Section titled “Parameters (native DashScope) — placement differences from OpenAI mode”Same parameters, same defaults and ranges as OpenAI mode; the table notes where each goes and the Java SDK name.
| Parameter | Type | Required | Default | Range | Placement | Description / Java SDK name |
|---|---|---|---|---|---|---|
model | string | Yes | — | qwen-mt-plus/flash/lite/turbo | top-level | Model name. |
messages | array | Yes | — | exactly 1 user message | inside input (HTTP); SDK param messages | One user message (role+content). Only user messages supported. |
messages[].content | string | Yes | — | any text | inside input.messages[] | Sentence to translate. |
messages[].role | string | Yes | — | user | inside input.messages[] | Must be user. |
max_tokens | integer | No | model max output | up to model max output | parameters (HTTP); Java SDK: maxTokens | Max output tokens; truncated if exceeded. |
seed | integer | No | — | [0, 2^31 − 1] | parameters (HTTP) | Reproducibility seed. |
temperature | float | No | 0.65 | [0, 2) | parameters (HTTP) | Set only one of temperature/top_p. |
top_p | float | No | 0.8 | (0, 1.0] | parameters (HTTP); Java SDK: topP | Set only one of temperature/top_p. |
top_k | integer | No | 1 | >= 0; None or >100 → disabled (only top_p) | parameters (HTTP); Java SDK: topK | Candidate-set size. |
repetition_penalty | float | No | 1.0 | > 0; 1.0 = no penalty | parameters (HTTP); Java SDK: repetitionPenalty | Repetition penalty. |
stream | boolean | No | — | true | false | Python SDK only | Java SDK: use streamCall. HTTP: header X-DashScope-SSE: enable. Same incremental/non-incremental per-model behavior. |
incremental_output | boolean | No | — | true | false | parameters (HTTP); Java SDK: incrementalOutput | Incremental streaming (effective only on flash/lite). |
translation_options | object | Yes | — | see section A nested schema | parameters (HTTP); Java SDK: translationOptions | Same nested schema (source_lang/target_lang/terms/tm_list/domains). |
result_format | string | (recommended) | — | message | SDK | SDK examples set result_format='message' (Python) / ResultFormat.MESSAGE (Java). |
In the Python DashScope SDK,
translation_options,max_tokens, etc. are passed as ordinary named arguments todashscope.Generation.call(...).
Response shape (native DashScope — same for streaming and non-streaming)
Section titled “Response shape (native DashScope — same for streaming and non-streaming)”{ "status_code": 200, "request_id": "9b4ec3b2-6d29-40a6-a08b-7e3c9a51c289", "code": "", "message": "", "output": { "text": null, "finish_reason": "stop", "choices": [ { "finish_reason": "stop", "message": { "role": "assistant", "content": "I didn't laugh after watching this video." } } ], "model_name": "qwen-mt-plus" }, "usage": { "input_tokens": 53, "output_tokens": 9, "total_tokens": 62 }}Response fields (native DashScope):
| Field | Type | Description |
|---|---|---|
status_code | string/int | 200 = success; other = failure. Java SDK does not return this (throws an exception; the message contains status_code + message). |
request_id | string | Unique request ID. Java SDK: requestId. |
code | string | Error code; empty on success. Only the Python SDK returns this. |
message | string | Error message; empty on success. |
output | object | Call result. |
output.text | string | Currently fixed null. |
output.finish_reason | string | null during generation | stop (natural stop) | length. |
output.choices[] | array | Model output. |
output.choices[].finish_reason | string | null | stop | length. |
output.choices[].message.role | string | Fixed assistant. |
output.choices[].message.content | string | Translation result. |
output.model_name | string | Model used. |
usage.input_tokens | integer | Input tokens. |
usage.output_tokens | integer | Output tokens. |
usage.total_tokens | integer | input + output. |
C. Model comparison (from user guide)
Section titled “C. Model comparison (from user guide)”| Model | Scenario | Result | Speed | Cost | Languages | Incremental stream |
|---|---|---|---|---|---|---|
| qwen-mt-plus | Professional fields, formal documents, academic papers, technical reports | Best | Standard | High | 92 | Unsupported |
| qwen-mt-flash | Recommended for general use. Website/app content, product descriptions, daily communication, blog posts | Good | Fast | Low | 92 | Supported |
| qwen-mt-turbo | Will not be updated in the future; use flash instead | Fair | Fast | Low | 92 | Unsupported |
| qwen-mt-lite | Simple, latency-sensitive scenarios: real-time chat, live comment translation | Basic | Fastest | Lowest | 31 | Supported |
Model selection guidance: general → flash; highest quality (professional) → plus; fastest (simple real-time) → lite. Context-window limits and pricing: Model Studio console. Concurrency limits: rate-limit page (Qwen Translation Models).
D. Supported languages
Section titled “D. Supported languages”In a request, use either the English name or the Code. source_lang: "auto" enables auto-detection.
qwen-mt-plus / flash / turbo (92 languages): English(en), Chinese(zh, Simplified), Traditional Chinese(zh_tw), Russian(ru), Japanese(ja), Korean(ko), Spanish(es), French(fr), Portuguese(pt), German(de), Italian(it), Thai(th), Vietnamese(vi), Indonesian(id), Malay(ms), Arabic(ar), Hindi(hi), Hebrew(he), Burmese(my), Tamil(ta), Urdu(ur), Bengali(bn), Polish(pl), Dutch(nl), Romanian(ro), Turkish(tr), Khmer(km), Lao(lo), Cantonese(yue), Czech(cs), Greek(el), Swedish(sv), Hungarian(hu), Danish(da), Finnish(fi), Ukrainian(uk), Bulgarian(bg), Serbian(sr), Telugu(te), Afrikaans(af), Armenian(hy), Assamese(as), Asturian(ast), Basque(eu), Belarusian(be), Bosnian(bs), Catalan(ca), Cebuano(ceb), Croatian(hr), Egyptian Arabic(arz), Estonian(et), Galician(gl), Georgian(ka), Gujarati(gu), Icelandic(is), Javanese(jv), Kannada(kn), Kazakh(kk), Latvian(lv), Lithuanian(lt), Luxembourgish(lb), Macedonian(mk), Maithili(mai), Maltese(mt), Marathi(mr), Mesopotamian Arabic(acm), Moroccan Arabic(ary), Najdi Arabic(ars), Nepali(ne), North Azerbaijani(az), North Levantine Arabic(apc), Northern Uzbek(uz), Norwegian Bokmål(nb), Norwegian Nynorsk(nn), Occitan(oc), Odia(or), Pangasinan(pag), Sicilian(scn), Sindhi(sd), Sinhala(si), Slovak(sk), Slovenian(sl), South Levantine Arabic(ajp), Swahili(sw), Tagalog(tl), Ta’izzi-Adeni Arabic(acq), Tosk Albanian(sq), Tunisian Arabic(aeb), Venetian(vec), Waray(war), Welsh(cy), Western Persian(fa).
qwen-mt-lite (31 languages): English(en), Chinese(zh, Simplified), Traditional Chinese(zh_tw), Russian(ru), Japanese(ja), Korean(ko), Spanish(es), French(fr), Portuguese(pt), German(de), Italian(it), Thai(th), Vietnamese(vi), Indonesian(id), Malay(ms), Arabic(ar), Hindi(hi), Hebrew(he), Urdu(ur), Bengali(bn), Polish(pl), Dutch(nl), Turkish(tr), Khmer(km), Czech(cs), Swedish(sv), Hungarian(hu), Danish(da), Finnish(fi), Tagalog(tl), Persian(fa).
Note: in the 92-language table the Persian entry is “Western Persian” (English name
Western Persian, codefa); in the 31-language qwen-mt-lite table the same codefais listed simply as “Persian”.
E. Minimal example (OpenAI-compatible, curl)
Section titled “E. Minimal example (OpenAI-compatible, curl)”curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \ -H "Authorization: Bearer $DASHSCOPE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen-mt-flash", "messages": [{"role": "user", "content": "No me reí después de ver este video"}], "translation_options": { "source_lang": "auto", "target_lang": "English" } }'Result text: I didn't laugh after watching this video.
Python (OpenAI SDK), minimal:
completion = client.chat.completions.create( model="qwen-mt-flash", messages=[{"role": "user", "content": "No me reí después de ver este video"}], extra_body={"translation_options": {"source_lang": "auto", "target_lang": "English"}},)print(completion.choices[0].message.content)F. Full example (OpenAI-compatible, curl) — all three features + sampling + streaming
Section titled “F. Full example (OpenAI-compatible, curl) — all three features + sampling + streaming”curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \ -H "Authorization: Bearer $DASHSCOPE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen-mt-plus", "messages": [ {"role": "user", "content": "Este conjunto de biosensores utiliza grafeno..."} ], "stream": true, "stream_options": {"include_usage": true}, "max_tokens": 2048, "seed": 1234, "temperature": 0.65, "top_p": 0.8, "top_k": 1, "repetition_penalty": 1.0, "translation_options": { "source_lang": "auto", "target_lang": "English", "terms": [ {"source": "biosensor", "target": "biological sensor"}, {"source": "grafeno", "target": "graphene"} ], "tm_list": [ {"source": "Puede instalar el SDK a través de PyPI...", "target": "You can run the following command in PyPI to install the SDK..."} ], "domains": "The sentence is from Ali Cloud IT domain. It mainly involves computer-related software development and usage methods... Translate into this IT domain style." } }'
domainsis not supported by qwen-mt-lite. Thedomainstext must be in English.
G. Full example (native DashScope, curl)
Section titled “G. Full example (native DashScope, curl)”curl -X POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation \ -H "Authorization: $DASHSCOPE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen-mt-plus", "input": { "messages": [ {"content": "Este conjunto de biosensores utiliza grafeno...", "role": "user"} ] }, "parameters": { "translation_options": { "source_lang": "auto", "target_lang": "English", "terms": [ {"source": "biosensor", "target": "biological sensor"} ] } } }'DashScope streaming over HTTP: add header X-DashScope-SSE: enable and "incremental_output": true in parameters (incremental output effective only on flash/lite).
H. Custom prompts (alternative to translation_options)
Section titled “H. Custom prompts (alternative to translation_options)”You can drive Qwen-MT with a plain instruction prompt in content (controlling target language, tone, domain, etc.) and omit translation_options. This is mutually exclusive with translation_options — if you supply both, translation_options may be ignored. For best results the docs recommend translation_options.
# OpenAI-compatible, no translation_options — instructions live in the prompt content.completion = client.chat.completions.create( model="qwen-mt-plus", messages=[{"role": "user", "content": "<detailed translation instructions + source text>"}],)print(completion.choices[0].message.content)