model (API Parameter) | Capability Description | Context Window | Max Input | Max Output |
hy-mt2-plus | A translation model with 7B parameters. It leads the industry in performance, excels on open-source benchmarks such as Flores200 and WMT25, and demonstrates outstanding performance in specialized domains and real-world business scenarios. It supports a comprehensive range of languages, with a focus on 33 language pairs for mutual translation, and includes support for 5 ethnic minority languages and dialects. | 8k | 4k | 4k |
user message (target_lang uses the full Chinese name, such as "Chinese" or "English")."messages": {"role": "user", "content": "Translate the following text into {target_lang}. Only output the translated result, without any additional explanation: {source_text}"}
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","messages": [{"role": "user", "content": "Translate the following text into English. Only output the translated result, without any additional explanation: Please confirm that all attendees have received the agenda before the meeting starts."}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)target_lang = "English"source_text = "Please confirm that all attendees have received the agenda before the meeting starts."prompt = f"""Translate the following text into {target_lang}. Only output the translated result, without any additional explanation:{source_text}"""response = client.chat.completions.create(model="hy-mt2-plus",messages=[{"role": "user", "content": prompt}],)print(response.choices[0].message.content)
import okhttp3.*;import com.google.gson.Gson;import java.util.*;public class TranslationDemo {public static void main(String[] args) throws Exception {String targetLang = "English";String sourceText = "Please confirm that all attendees have received the agenda before the meeting starts.";String prompt = "Translate the following text into " + targetLang + ". Only output the translated result, without any additional explanation:\\n" + sourceText;Map<String, Object> body = new HashMap<>();body.put("model", "hy-mt2-plus");body.put("messages", List.of(Map.of("role", "user", "content", prompt)));Request request = new Request.Builder().url("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions").header("Authorization", "Bearer YOUR_API_KEY").post(RequestBody.create(new Gson().toJson(body),MediaType.parse("application/json"))).build();try (Response response = new OkHttpClient().newCall(request).execute()) {System.out.println(response.body().string());}}}
import OpenAI from 'openai';const client = new OpenAI({apiKey: 'YOUR_API_KEY',baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1',});const targetLang = 'English';const sourceText = 'Please confirm that all attendees have received the agenda before the meeting starts.';const prompt = `Translate the following text into ${targetLang}. Only output the translated result, without any additional explanation:\\n${sourceText}`;const response = await client.chat.completions.create({model: 'hy-mt2-plus',messages: [{ role: 'user', content: prompt }],});console.log(response.choices[0].message.content);
package mainimport ("bytes""encoding/json""fmt""io""net/http")func main() {targetLang := "English"sourceText := "Please confirm that all attendees have received the agenda before the meeting starts."prompt := "Translate the following text into " + targetLang + ". Only output the translated result, without any additional explanation:\\n" + sourceTextbody, _ := json.Marshal(map[string]interface{}{"model": "hy-mt2-plus","messages": []map[string]string{{"role": "user", "content": prompt},},})req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",bytes.NewBuffer(body))req.Header.Set("Authorization", "Bearer YOUR_API_KEY")req.Header.Set("Content-Type", "application/json")resp, _ := http.DefaultClient.Do(req)defer resp.Body.Close()data, _ := io.ReadAll(resp.Body)fmt.Println(string(data))}
{"id": "REPLACED_ID","object": "chat.completion","model": "hy-mt2-plus","created": 1775146513,"choices": [{"index": 0,"message": {"role": "assistant","content": "Please ensure that all attendees have received the agenda before the meeting starts."},"finish_reason": "stop"}],"usage": {"prompt_tokens": 35,"completion_tokens": 15,"total_tokens": 50,"prompt_tokens_details": {"cached_tokens": 0},"completion_tokens_details": {"reasoning_tokens": 0}}}
"messages": {"role": "user", "content": "# Task ObjectiveTranslate the {format_type} format data in the following {source_text} into {target_lang}.# Strict Constraints1. Structure Locking: Absolutely keep the original {format_type} data structure, indentation, and hierarchy completely unchanged.2. Selective Translation: Translate only the visible text content that is displayed to users.3. No Modification: Do not translate or alter any code tags, key names (Key), variable placeholders (such as {{var}}, ${var}, %s, %d, etc.), or code attributes.# Data Input{source_text}"}
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","messages": [{"role": "user", "content": "# Task Objective\\nTranslate the JSON format data in the following source_text into English.\\n\\n# Strict Constraints\\n1. Structure Locking: Absolutely keep the original JSON data structure, indentation, and hierarchy completely unchanged.\\n2. Selective Translation: Translate only the visible text content that is displayed to users.\\n3. No Modification: Do not translate or alter any code tags, key names (Key), variable placeholders (such as {{var}}, ${var}, %s, %d, etc.), or code attributes.\\n\\n# Data Input\\n{\\"title\\": \\"West Lake Scenic Area\\", \\"description\\": \\"Located in the center of Hangzhou, it is a national 5A-level tourist attraction with pleasant scenery throughout the four seasons.\\", \\"tags\\": [\\"Natural Scenery\\", \\"World Heritage\\", \\"Free Admission\\"]}"}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)target_lang = "English"format_type = "JSON"source_text = '{"title": "West Lake Scenic Area", "description": "Located in the center of Hangzhou, it is a national 5A-level tourist attraction with pleasant scenery throughout the four seasons.", "tags": ["Natural Scenery", "World Heritage", "Free Admission"]}'prompt = f"""# Task ObjectiveTranslate the {format_type} format data in the following source_text into {target_lang}.# Strict Constraints1. Structure Locking: Absolutely keep the original {format_type} data structure, indentation, and hierarchy completely unchanged.2. Selective Translation: Translate only the visible text content that is displayed to users.3. No Modification: Do not translate or alter any code tags, key names (Key), variable placeholders (such as {{var}}, ${{var}}, %s, %d, etc.), or code attributes.# Data Input{source_text}"""response = client.chat.completions.create(model="hy-mt2-plus",messages=[{"role": "user", "content": prompt}],)print(response.choices[0].message.content)
{"id": "REPLACED_ID","object": "chat.completion","model": "hy-mt2-plus","created": 1779966611,"choices": [{"index": 0,"message": {"role": "assistant","content": "{\\"title\\": \\"West Lake Scenic Area\\", \\"description\\": \\"Located in the heart of Hangzhou, it is a national 5A-level tourist attraction known for its pleasant scenery throughout the four seasons.\\", \\"tags\\": [\\"Natural Scenery\\", \\"World Heritage\\", \\"Free Admission\\"]}"},"finish_reason": "stop"}],"usage": {"prompt_tokens": 159,"completion_tokens": 59,"total_tokens": 218,"prompt_tokens_details": {"cached_tokens": 0},"completion_tokens_details": {"reasoning_tokens": 0}}}
<SEP> and ### that do not conflict with target language punctuation as delimiters. Tags like ||| and --- can be recognized as exclamation marks, dashes, or other punctuation marks in some languages, making the translated text unsplittable."messages": {"role": "user", "content": "Please accurately translate the following text into {target_lang}.You must retain an equal number of delimiters in the translation. Do not omit, escape, or translate this symbol, and pay attention to the delimiter positions. {source_text}"}
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","messages": [{"role": "user", "content": "Please accurately translate the following text into English. You must retain an equal number of delimiters in the translation. Do not omit, escape, or translate this symbol, and pay attention to the delimiter positions.\\nGetting eight hours of sleep daily contributes to physical health<SEP>Properly planning work and rest can improve efficiency<SEP>Moderate exercise can effectively relieve stress"}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)target_lang = "English"SEP = "<SEP>"source_segments = ["Getting eight hours of sleep daily contributes to physical health", "Properly planning work and rest can improve efficiency", "Moderate exercise can effectively relieve stress"]source_text = SEP.join(source_segments)prompt = f"""Please accurately translate the following text into {target_lang}. You must retain an equal number of delimiters in the translation. Do not omit, escape, or translate this symbol, and pay attention to the delimiter positions.{source_text}"""response = client.chat.completions.create(model="hy-mt2-plus",messages=[{"role": "user", "content": prompt}],)translated = response.choices[0].message.content.split(SEP)for src, tgt in zip(source_segments, translated):print(f"{src.strip()} → {tgt.strip()}")
{"id": "REPLACED_ID","object": "chat.completion","model": "hy-mt2-plus","created": 1779966612,"choices": [{"index": 0,"message": {"role": "assistant","content": "Getting eight hours of sleep every day is beneficial for good health<SEP>Properly planning work and rest can improve efficiency<SEP>Moderate exercise can effectively relieve stress"},"finish_reason": "stop"}],"usage": {"prompt_tokens": 65,"completion_tokens": 36,"total_tokens": 101,"prompt_tokens_details": {"cached_tokens": 0},"completion_tokens_details": {"reasoning_tokens": 0}}}
"messages": {"role": "user", "content": "[Background Information] {background_text}Please translate the following text into {target_lang} by incorporating the background information.[Text to be translated] {source_text}"}
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","messages": [{"role": "user", "content": "[Background Information]\\nThis is a technical document introducing a database system. The term 'transaction' mentioned above refers to a database transaction, and 'index' refers to a database index.\\nPlease translate the following text into English by incorporating the background information.\\n[Text to be translated]\\nAfter a transaction is committed, the index is asynchronously flushed to disk."}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)target_lang = "English"background_text = "This is a technical document introducing a database system. The term 'transaction' mentioned above refers to a database transaction, and 'index' refers to a database index."source_text = "After a transaction is committed, the index is asynchronously flushed to disk."prompt = f"""[Background Information]{background_text}Please translate the following text into {target_lang} by incorporating the background information.[Text to be translated]{source_text}"""response = client.chat.completions.create(model="hy-mt2-plus",messages=[{"role": "user", "content": prompt}],)print(response.choices[0].message.content)
{"id": "REPLACED_ID","object": "chat.completion","model": "hy-mt2-plus","created": 1779966614,"choices": [{"index": 0,"message": {"role": "assistant","content": "After a transaction is committed, the index is asynchronously flushed to disk."},"finish_reason": "stop"}],"usage": {"prompt_tokens": 68,"completion_tokens": 15,"total_tokens": 83,"prompt_tokens_details": {"cached_tokens": 0},"completion_tokens_details": {"reasoning_tokens": 0}}}
"messages": {"role": "user", "content": "Refer to the translation below:{text} translated into {text}{text} translated into {text}{text} translated into {text}Translate the following text into {target_lang}. Only output the translated result, without any additional explanation: {source_text}"}
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","messages": [{"role": "user", "content": "Refer to the translation below:\\npremiere translated to premiere\\nratings translated to ratings\\nTranslate the following text into English. Only output the translated result, without any additional explanation:\\nThe show's ratings have been rising steadily since its premiere on the media platform."}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)target_lang = "English"glossary = [("premiere", "premiere"),("ratings", "ratings"),]source_text = "The show's ratings have been rising steadily since its premiere on the media platform."glossary_text = "\\n".join(f"{src} translated into {tgt}" for src, tgt in glossary)prompt = f"""Refer to the translation below:{glossary_text}Translate the following text into {target_lang}. Only output the translated result, without any additional explanation:{source_text}"""response = client.chat.completions.create(model="hy-mt2-plus",messages=[{"role": "user", "content": prompt}],)print(response.choices[0].message.content)
{"id": "REPLACED_ID","object": "chat.completion","model": "hy-mt2-plus","created": 1779967706,"choices": [{"index": 0,"message": {"role": "assistant","content": "The ratings for this drama kept rising after its premiere on media platforms."},"finish_reason": "stop"}],"usage": {"prompt_tokens": 56,"completion_tokens": 15,"total_tokens": 71,"prompt_tokens_details": {"cached_tokens": 0},"completion_tokens_details": {"reasoning_tokens": 0}}}
"messages": {"role": "user", "content": "Please translate the following text into {target_lang}.Ensure the translation style strictly adheres to {target_style}.{source_text}"}
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","messages": [{"role": "user", "content": "Translate the following text into English. Ensure the translation style strictly adheres to [popular science copy: concise, impactful, and engaging language].\\nModerate outdoor activities help regulate mood and relieve mental stress."}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)target_lang = "English"target_style = "popular science copy: concise, impactful, and engaging language"source_text = "Moderate outdoor activities help regulate mood and relieve mental stress."prompt = f"""Please translate the following text into {target_lang}. Ensure the translation style strictly adheres to {target_style}.{source_text}"""response = client.chat.completions.create(model="hy-mt2-plus",messages=[{"role": "user", "content": prompt}],)print(response.choices[0].message.content)
{"id": "REPLACED_ID","object": "chat.completion","model": "hy-mt2-plus","created": 1779966617,"choices": [{"index": 0,"message": {"role": "assistant","content": "Moderate outdoor activities help regulate emotions and alleviate mental stress."},"finish_reason": "stop"}],"usage": {"prompt_tokens": 48,"completion_tokens": 13,"total_tokens": 61,"prompt_tokens_details": {"cached_tokens": 0},"completion_tokens_details": {"reasoning_tokens": 0}}}
Parameter | Type | Required | Description |
model | string | Yes | The model parameter, for example hy-mt2-plus |
text | string | Yes | The text to be translated |
target | string | Yes | Target language code |
source | string | No | The source language code. If not provided, the model automatically identifies it. |
stream | bool | No | Whether to return in streaming mode. The default value is false. |
context | string | No | Context information for making the translation more coherent. |
references | list of object | No | Reference examples (sentences or terms), up to 10. |
glossary_ids | list of string | No | A list of glossary IDs, up to 10 |
Field | Type | Description |
id | string | id of this request |
Created | integer | Unix timestamp |
choices | list | Returned replies, supporting multiple |
choices[n].finish_reason | string | stop indicates normal termination, and sensitive indicates review failure. |
choices[n].message | json | Returned content |
choices[n].message.role | string | Role Name |
choices[n].message.content | string | Translated text |
choices[n].delta | json | Returned content (streaming) |
choices[n].delta.role | string | Role Name (streaming) |
choices[n].delta.content | string | Translated text (streaming) |
source | string | Source language of the request |
target | string | Target language |
usage | object | token usage |
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/api/translations' \\-H 'Content-Type: application/json' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-d '{"model": "hy-mt2-plus","text": "This vehicle model features an advanced battery management system, offers a range exceeding 600 kilometers, and supports fast charging.""source": "zh","target": "en","glossary_ids": ["YOUR_GLOSSARY_ID"]}'
import requestsurl = "https://tokenhub-intl.tencentcloudmaas.com/v1/api/translations"headers = {"Authorization": "Bearer YOUR_API_KEY","Content-Type": "application/json",}payload = {"model": "hy-mt2-plus","text": "This vehicle model features an advanced battery management system, offers a range exceeding 600 kilometers, and supports fast charging.""source": "zh","target": "en","glossary_ids": ["YOUR_GLOSSARY_ID"],}response = requests.post(url, headers=headers, json=payload)data = response.json()print(data["choices"][0]["message"]["content"])
{"id": "REPLACED_ID","created": 1781604284,"choices": [{"index": 0,"finish_reason": "stop","message": {"role": "assistant","content": "This model is equipped with an advanced Battery Management System (BMS), offering a driving range of over 600 kilometers along with fast charging support."}}],"source": "zh","target": "en","usage": {"prompt_tokens": 82,"completion_tokens": 32,"total_tokens": 114}}
Language | English Name | Code |
Simplified Chinese | Chinese | zh |
Traditional Chinese | Traditional Chinese | zh-TR |
English | English | en |
French | French | fr |
Portuguese | Portuguese | pt |
Spanish | Spanish | es |
Japanese | Japanese | ja |
Turkish | Turkish | tr |
Russian | Russian | ru |
Arabic | Arabic | ar |
Korean | Korean | ko |
Thai | Thai | th |
Italian | Italian | it |
German | German | de |
Vietnamese | Vietnamese | vi |
Malay | Malay | ms |
Indonesian | Indonesian | id |
Filipino | Filipino | fil |
Hindi | Hindi | hi |
Polish | Polish | pl |
Czech | Czech | cs |
Dutch | Dutch | nl |
Khmer | Khmer | km |
Burmese | Burmese | my |
Persian | Persian | fa |
Gujarati | Gujarati | gu |
Urdu | Urdu | ur |
Telugu | Telugu | te |
Marathi | Marathi | mr |
Hebrew | Hebrew | he |
Bengali | Bengali | bn |
Tamil | Tamil | ta |
Ukrainian | Ukrainian | uk |
Tibetan | Tibetan | bo |
Kazakh | Kazakh | kk |
Mongolian | Mongolian | mn |
Uyghur | Uyghur | ug |
Cantonese | Cantonese | yue |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback