tencent cloud

Hy API Guide

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-06-12 21:42:50

Overview

Tencent Hy is a large language model developed by Tencent. It possesses robust 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
Translation model with 7B parameters. It leads the industry in performance, excels on open-source test sets Flores200 and WMT25, and performs excellently in specialized domains and real-world business scenarios. It supports a comprehensive range of languages, with a focus on translation between 33 languages, and supports 5 ethnic minority languages/Chinese 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: Tencent Hunyuan is now available on the TokenHub platform, supporting capabilities such as deep thinking, structured output, and Function Calling."}
]
}'
from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",
)

target_lang = "English"
source_text = "Tencent Hunyuan is now available on the TokenHub platform, supporting capabilities such as deep thinking, structured output, and Function Calling."

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 = "Tencent Hunyuan is now available on the TokenHub platform, supporting capabilities such as deep thinking, structured output, and Function Calling.";
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 = 'Tencent Hunyuan is now available on the TokenHub platform, supporting capabilities such as deep thinking, structured output, and Function Calling.';
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 := "Tencent Hunyuan is now available on the TokenHub platform, supporting capabilities such as deep thinking, structured output, and Function Calling."
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": "The Tencent Hunyuan large model is now available on the TokenHub platform. It supports capabilities such as deep reasoning, structured output, and Function Calling."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 57,
"completion_tokens": 32,
"total_tokens": 89,
"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\\": \\"Product Introduction\\", \\"description\\": \\"Tencent Hunyuan is now available on the TokenHub platform\\", \\"tags\\": [\\"Large Model\\", \\"Translation\\", \\"AI\\"]}"}
]
}'
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": "Product Introduction", "description": "Tencent Hunyuan is now available on the TokenHub platform", "tags": ["Large Model", "Translation", "AI"]}'

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\\": \\"Product Introduction\\", \\"description\\": \\"Tencent Hunyuan Large Model is now available on the TokenHub platform.\\", \\"tags\\": [\\"Large Model\\", \\"Translation\\", \\"AI\\"]}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 158,
"completion_tokens": 41,
"total_tokens": 199,
"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.\\nTencent Hunyuan is now available<SEP>supports deep thinking and tool invocation<SEP>covers 38 languages for mutual translation"}
]
}'
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 = ["Tencent Hunyuan is now available", "supports deep thinking and tool invocation", "covers 38 languages for mutual translation"]
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": "Tencent Hunyuan large model is now live <SEP> Supports deep reasoning and tool invocation <SEP> Covers translation between 38 languages"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 77,
"completion_tokens": 31,
"total_tokens": 108,
"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 translations below:\\nTencent Hy translated as Tencent Hy\\nTencent Cloud translated as Tencent Cloud\\ndeep reasoning translated as deep reasoning\\nTranslate the following text into English, ensuring you only output the translated result without any additional explanation:\\nThe Tencent Hy model on Tencent Cloud supports deep reasoning capabilities."}
]
}'
from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",
)

target_lang = "English"
glossary = [
("Hunyuan Large Model", "Tencent Hy"),
("Tencent Cloud", "Tencent Cloud"),
("Deep Thinking", "deep reasoning"),
]
source_text = "The Tencent Hunyuan model on Tencent Cloud supports deep thinking capabilities."

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": "Tencent Hy on Tencent Cloud supports deep reasoning capabilities."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 72,
"completion_tokens": 13,
"total_tokens": 85,
"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": "Please translate the following text into English. Ensure the translation style strictly adheres to [marketing copy: concise, impactful, and engaging language that highlights key selling points, suitable for product introductions targeting overseas developers].\\nTencent Hunyuan: ready to use out of the box, making AI application development simpler."}
]
}'
from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",
)

target_lang = "English"
target_style = "marketing copy: concise, impactful, and engaging language that highlights key selling points, suitable for product introductions targeting overseas developers"
source_text = "Tencent Hunyuan is ready to use out of the box, making AI application development simpler."

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": "Tencent Hunyuan Large Model is ready to use right out of the box, making AI application development easier than ever."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 66,
"completion_tokens": 25,
"total_tokens": 91,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 0}
}
}

Supported Languages

Language
English Name
Code
Simplified Chinese
Chinese
zh
Traditional Chinese
Traditional Chinese
zh-Hant
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
tl
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


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan