tencent cloud

Hy API Guide

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-07-15 15:23:29

Overview

Tencent Hy is a large language model developed by Tencent. It possesses strong capabilities in Chinese content creation, logical reasoning in complex contexts, and reliable task execution.

Prerequisites

You have registered a Tencent Cloud account and activated the TokenHub service.
You have obtained the API Key in the TokenHub console.

Supported Models

Hy-MT2 is a family of "fast-thinking" multilingual translation models designed for complex real-world scenarios. It includes three model sizes: 1.8B, 7B, and 30B-A3B (MoE), all of which support translation among 33 languages and effectively follow translation instructions in multiple languages. Multi-dimensional evaluations show that Hy-MT2 delivers outstanding performance across general, real-world business, domain-specific, and instruction-following translation tasks.
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

Default Translation

In the most common translation scenario, the target language is explicitly specified in the 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
Python
Java
Node.js
Go
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 OpenAI

client = 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 main

import (
"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" + sourceText

body, _ := 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))
}
Response Example:
{
"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}
}
}

Structured Data Translation

When the original text is structured data such as JSON / Markdown / HTML / XML, the model "locks the structure, translates only the visible values, and retains all keys and placeholders."
"messages": {"role": "user", "content": "
# Task Objective
Translate the {format_type} format data in the following {source_text} into {target_lang}.

# Strict Constraints
1. 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
Python
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 OpenAI

client = 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 Objective
Translate the {format_type} format data in the following source_text into {target_lang}.

# Strict Constraints
1. 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)
Response Example:
{
"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}
}
}

Delimiters Translation

When you need to compare sentences side-by-side or translate multiple text segments in batches, instruct the model to retain an equal number of delimiters without omission, escaping, or translation, to facilitate alignment by index on the business side.
It is recommended to use tags such as <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
Python
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 OpenAI

client = 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()}")
Response Example:
{
"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}
}
}

Contextual Translation

When the original text contains polysemous words, proper nouns, or pronoun references that require contextual disambiguation, providing "background information" enables the model to select terminology consistent with the context.
"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
Python
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 OpenAI

client = 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)
Response Example:
{
"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}
}
}

Terminology Translation

When the business side possesses a domain glossary (containing product names, brand terms, proprietary nouns, and so on, which require fixed translations), you can preload the term comparison list as a reference. The model then prioritizes using the specified translations.
"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
Python
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 OpenAI

client = 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)
Response Example:
{
"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}
}
}

Style Translation

Different business scenarios require different translation styles (colloquial / formal / marketing copy / legal contracts / academic / classical Chinese). Describe the target style, and the model will adjust its vocabulary and sentence structures accordingly.
"messages": {"role": "user", "content": "
Please translate the following text into {target_lang}.
Ensure the translation style strictly adheres to {target_style}.
{source_text}"}
cURL
Python
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 OpenAI

client = 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)
Response Example:
{
"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}
}
}

Glossary

Unlike the Terminology Translation approach (embedding terms in prompts) described above, this section uses a dedicated translation API and a persistent glossary, making it more suitable for engineering scenarios with large volumes of frequently reused terms.
Attention:
Currently, only the OpenAPI protocol supports using the translation glossary. API endpoint: https://tokenhub-intl.tencentcloudmaas.com/v1/api/translations
You can refer to glossary management APIs to create, modify, and query glossary.
Request Parameter Description
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
Response Field Description
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
Example Requests
cURL
Python
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 requests

url = "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"])
Response Example
{
"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
}
}

Supported Languages

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


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック