Skip to contentOceanToken

11 min read

Hunyuan MT Translation API Guide

Call the Hunyuan MT translation API (Tencent Hy-MT2) with the OpenAI SDK: model ids, prompt templates, the 8K context limit, glossaries, and when to use Hy4.

By OceanToken Team

Hunyuan MT Translation API Guide

Editor's note: Hy-MT2 is a translation model, not a chat model that happens to translate. That sounds like a detail, but it changes how you call it. It wants one plain instruction, a full language name and the text, and it gives back only the translation. Treat it like a general assistant, with a long system prompt and follow-up questions, and you are paying for a small model to do a job it was not built for.

Short answer: The Hunyuan MT translation API is Tencent's Hy-MT2 family: tencent/hy-mt2-1.8b, tencent/hy-mt2-7b and tencent/hy-mt2-30b-a3b. Call them on /v1/chat/completions with one user message built from Tencent's template, a full target language name, and a source chunk that leaves room in the 8,192-token window. Use Hy4 for rewriting or long documents.

On OceanToken these three models sit behind the same OpenAI-compatible base URL and key as every other model in the catalog, so a translation step can live next to your chat or video calls without a second SDK or account. The rest of this guide covers the request, the model sizes, the limits that catch people, and the point where a general model is the better tool.

01 · What the Hunyuan MT translation API is

Tencent open-sourced the Hy-MT2 series on May 21, 2026, according to the project's README on GitHub. The family has three sizes. The README positions the 1.8B model for on-device use, and the model page calls the 30B-A3B model, a mixture-of-experts design, Tencent's flagship translation model in the family. The 7B sits between them.

The Hy-MT2-7B model page describes it as supporting 33 language pairs plus five Chinese dialect and minority-language pairs, with workflows for structured, delimiter-based, contextual, glossary-based and style-guided translation. Tencent's own language table lists 38 entries, which includes Traditional Chinese, Cantonese, Tibetan, Kazakh, Mongolian and Uyghur alongside the major world languages.

Here is what the API docs list for each model, checked on November 20, 2026:

Model id Context window Max output Endpoints Notes
tencent/hy-mt2-1.8b 8,192 tokens 4,096 tokens /v1/chat/completions, /v1/responses Compact model; its model page does not list structured outputs
tencent/hy-mt2-7b 8,192 tokens 4,096 tokens /v1/chat/completions, /v1/responses Structured outputs via response_format
tencent/hy-mt2-30b-a3b 8,192 tokens 4,096 tokens /v1/chat/completions, /v1/responses Flagship MoE model; structured outputs via response_format
tencent/hy4 1,048,576 tokens 65,536 tokens /v1/chat/completions, /v1/responses General model with reasoning, tool calling and image input

All three Hy-MT2 models are text in, text out. There is no tool calling and no reasoning mode listed, which is what you want from a translator: an answer that is the translation and nothing else. The /hunyuan-api page lists all four Hunyuan models together with their current rates.

02 · Tencent hy-mt2 API in Python: the minimal request

The quickest way to see Hy-MT2 work is a single call through the OpenAI SDK. The only things that change from a normal chat call are the base URL, the key and the model id. If you have not used the OpenAI SDK against a Hunyuan model before, our Tencent Hy3 OpenAI SDK guide covers client setup, streaming and errors; here we only add what is specific to translation.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.oceantoken.ai/v1",
    api_key=os.environ["OCEANTOKEN_API_KEY"],
)

def translate(text, target_lang, model="tencent/hy-mt2-7b"):
    prompt = (
        f"Translate the following text into {target_lang}.\n"
        "Note that you should only output the translated result "
        "without any additional explanation:\n\n"
        f"{text}"
    )
    resp = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}],
        temperature=0.7,
        max_tokens=4096,
    )
    choice = resp.choices[0]
    if choice.finish_reason == "length":
        raise ValueError("Translation was cut off; send a shorter chunk")
    return choice.message.content

print(translate("The invoice is due at the end of the month.", "Japanese"))

The prompt string follows the default English template in Tencent's README almost word for word. That matters more than it looks. The model was trained with these templates, so the closer your instruction is to them, the less likely you are to get a preamble like "Here is the translation:" that you then have to strip.

The same request in curl, for checking a key or a firewall rule:

curl https://api.oceantoken.ai/v1/chat/completions \
  -H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "tencent/hy-mt2-7b",
       "messages": [{"role": "user", "content": "Translate the following text into German.\nNote that you should only output the translated result without any additional explanation:\n\nPlease restart the router before calling support."}]}'

Three details in that code are deliberate. There is no system message, because Tencent's README says the models have no default system prompt and its examples send a single user message. The target is a full language name, "Japanese" rather than "ja", which the README asks for; it also says to use English names inside English prompts and Chinese names inside Chinese prompts. And the code checks finish_reason, because a translation that hits max_tokens ends mid-sentence without any error.

03 · Request parameters that matter for translation

The docs page for Hy-MT2-7B  lists the parameters this model takes and states that anything else is left out before the request reaches the model. That rule has a direct consequence for translation work, covered after the table.

Parameter Values Why it matters here
model tencent/hy-mt2-1.8b, tencent/hy-mt2-7b, tencent/hy-mt2-30b-a3b Pick by quality need; all share the same request shape
messages One user message with the template Instructions go in the user turn, not a system turn
max_tokens 1 to 4,096 Caps the translation length; set it high enough for expansion
temperature 0 to 2 Tencent recommends 0.7 for all three sizes
stop Up to 4 strings Rarely needed; the template already asks for translation only
response_format json_object, json_schema Listed for 7B and 30B-A3B; useful when you translate fields of a JSON record
stream true or false Helps show long translations progressively in a UI

Here is the pitfall. Tencent's README recommends top_p, top_k and repetition_penalty values as well as temperature, and the recommended values differ between the small models and the 30B-A3B. None of those three appear in the docs' parameter table for these models. If you copy Tencent's full sampling block into your request, the extra fields are dropped silently and you get the endpoint's defaults for them. Your output will still look fine, but you should not assume you are running Tencent's recommended configuration, and you should not compare results against a self-hosted setup that does use those values without noting the difference.

04 · Prompt templates: glossaries, delimiters and structured text

Tencent publishes several templates beyond the default one, and they are the most useful part of the README for anyone building a product. Each exists in an English and a Chinese version. The ones you will reach for most:

Job Template idea When to use it
Plain translation "Translate the following text into {target_lang}" plus "only output the translated result" UI strings, support replies, short documents
Terminology A list of "X translates to Y" pairs before the default instruction Product names, legal terms, anything with a fixed rendering
Delimiters Keep the exact same number of delimiters, in place, untranslated Subtitles, segmented text you will split again
Structured data Translate only user-visible values; keep keys, tags and placeholders JSON locale files, HTML fragments, Markdown with code
Background context Background text first, then the source text Ambiguous short strings that need a hint
Style The translation must match a named style Marketing copy in a set register

A glossary request looks like this, following the terminology template:

glossary = {"OceanBox": "OceanBox", "balance": "残高", "top up": "チャージ"}
terms = "\n".join(f"{k} translates to {v}" for k, v in glossary.items())
prompt = (
    "Reference the following translations:\n"
    f"{terms}\n"
    "Translate the following text into Japanese.\n"
    "Note that you must ONLY output the translated result "
    "without any additional explanation:\n\n"
    "Top up your balance before you renew OceanBox."
)

The glossary costs input tokens on every call, and every call has the same 8,192-token budget, so a glossary of hundreds of terms crowds out the text you came to translate. Filter it per chunk: include only the terms that actually appear in the source. That keeps the prompt short and also makes it obvious, when you review output, which terms the model was asked to respect.

For structured data, the template is strict about not touching keys or placeholders. That is exactly the behavior you want for a locale file, but verify it on your own files: a placeholder style the model has not seen, such as a custom [[name]] token, is where you would expect trouble first.

05 · Long text and the 8K window

The single biggest constraint on Hy-MT2 is the context window. 8,192 tokens covers the prompt, the glossary, the source text and the translation together, and the output alone is capped at 4,096 tokens. A long article will not fit in one call, and even a medium one may not leave room for its own translation.

So you split. A practical approach:

  1. Split the source on paragraph boundaries, never mid-sentence. Translation quality drops when a sentence is cut, because the model loses its grammatical frame.
  2. Count tokens per chunk and keep each one well under half the window, so the translation has room. Text can grow when it changes language, and the direction depends on the language pair, so measure your own expansion from the usage field rather than guessing. A starting point of about 2,000 source tokens per chunk is easy to tune from there.
  3. If a chunk depends on earlier text, for pronouns or a running term, use the background-context template and pass a short summary or the previous paragraph as background.
  4. Reassemble in order and check that every chunk returned finish_reason: "stop".

Diagram: Splitting a long document for Hy-MT2

Chunking also gives you something useful for free: each request is small enough to retry on its own. If one paragraph comes back truncated or wrong, you resend that paragraph, not the whole file.

06 · Hy-MT2 model sizes: which to pick

All three sizes have the same window, the same output cap and the same request shape, so switching between them is a one-word change. That makes the choice cheap to revisit, and it means the right way to choose is a short side-by-side on your own text rather than a debate.

Your job Start with Why
High-volume, short strings where speed and spend matter most tencent/hy-mt2-1.8b The compact model; /hunyuan-api lists it as the lowest-priced Hunyuan model
General product translation, support replies, documentation tencent/hy-mt2-7b The middle size, with structured outputs listed
Customer-facing copy, contracts, low-resource pairs tencent/hy-mt2-30b-a3b Tencent's flagship model in the family
JSON records where output must parse 7B or 30B-A3B Both list response_format; the 1.8B page does not

On /hunyuan-api today, the 7B and 30B-A3B are listed at the same rate, so price is not the tiebreaker between them; check the page before you decide, since rates change. If they stay level, there is little reason to default to the 7B for anything a customer reads. Keep the 1.8B for the high-volume, low-stakes tier, and confirm its quality on your hardest language pair before routing traffic to it.

Diagram: Which Hunyuan model for which translation job

07 · When to use Hy4 instead of a Hunyuan translation model

Hy-MT2 does one thing. The moment your task is more than "put this text into that language", a general model is the better call. Here that means tencent/hy4, which the docs list with a 1,048,576-token window, up to 65,536 output tokens, reasoning, tool calling and image input.

Move to Hy4 when:

  • The job is adaptation, not translation. Rewriting a headline for a different market, shortening copy to fit a button, or changing tone needs judgment the translation templates do not ask for.
  • You need an explanation. "Why did you translate this term that way?" or "list the ambiguous phrases" is a conversation. Hy-MT2 is built to answer with the translation only.
  • The document must stay in one call. A long contract where cross-references matter is safer in a model whose window holds the whole thing than in forty separate chunks.
  • The source is an image. Hy4 lists image input; the Hy-MT2 models are text only.
  • You run a review loop. Translate with Hy-MT2, then ask Hy4 to check the output against your glossary and flag problems. That splits the work along each model's strengths.

The reverse also holds. Do not send bulk, short, glossary-bound translation to Hy4 just because it is the bigger model. You pay for a large window and reasoning you are not using, and a general model is more likely to add commentary you have to strip.

How to test this on your workload

We have not run a translation benchmark for this article, so here is a test you can run in an afternoon before choosing a model:

  1. Take 50 real sentences from your product, including your hardest cases: product names, numbers with units, idioms and a few strings with placeholders.
  2. Send the same set to tencent/hy-mt2-1.8b, tencent/hy-mt2-7b and tencent/hy-mt2-30b-a3b with the default template and the same temperature.
  3. Run it again with your glossary in the terminology template and count how many glossary terms appear exactly as specified in each output.
  4. Send your longest real document through your chunker and confirm every chunk ended with finish_reason: "stop".
  5. Send ten strings to tencent/hy4 with an adaptation instruction (shorten to fit, change the tone) and compare against the Hy-MT2 output for the same strings.
  6. Record usage.prompt_tokens and usage.completion_tokens per request so you know your real expansion ratio and cost per thousand strings.

Have a native speaker score a blind sample rather than reading the outputs yourself. Machine translation errors that look fine to a non-speaker are the expensive ones.

Our take: Default to tencent/hy-mt2-7b for product translation and move customer-facing copy to the 30B-A3B if it holds up on your test set. Use Tencent's templates verbatim, keep chunks well inside the 8K window, filter glossaries per chunk, and check finish_reason on every call. Send anything that needs rewriting, explaining or a whole long document in one pass to Hy4.

Running it on OceanToken

All three Hy-MT2 models and Hy4 answer on one OpenAI-compatible base URL, https://api.oceantoken.ai/v1, with one key and one prepaid balance. Moving a job from tencent/hy-mt2-7b to tencent/hy4 is a change to the model field, not a new account or SDK, so a translate-then-review pipeline is two calls in the same client. Billing is per use with no subscription, and each API key can carry its own spending limit, which helps when a translation job runs in a batch you do not watch. See the current rates on /hunyuan-api.

FAQ

Is Hy-MT2 the Hunyuan translation model? Yes. Hy-MT2 is Tencent's translation model family, in 1.8B, 7B and 30B-A3B sizes, and the model pages describe it as a translation model.

Is the Hunyuan translation model OpenAI compatible here? Yes. It answers on /v1/chat/completions and /v1/responses, so the OpenAI SDKs work with only the base URL, key and model id changed.

How long can a single request be? The context window is 8,192 tokens for prompt and translation together, and the translation itself is capped at 4,096 tokens. Split longer documents by paragraph.

Should I use a system prompt? Tencent's README says the models have no default system prompt and its examples use a single user message. Put the instruction and the text in the user turn.

Can I pass top_k and repetition_penalty? They are not in the docs' parameter list for these models, and parameters a model does not list are left out before the request reaches it. Temperature is supported.

Which languages are supported? The model page lists 33 language pairs and five Chinese dialect and minority-language pairs; use full language names in the prompt.

Sources

  1. Tencent-Hunyuan Hy-MT2 repository and README: sizes, languages, prompt templates, recommended parameters  (checked 2026-11-20)
  2. OceanToken docs: Hy-MT2-7B parameters and limits  (checked 2026-11-20)
  3. OceanToken docs: Hy4  (checked 2026-11-20)
  4. OceanToken: Hy-MT2-7B model page (checked 2026-11-20)
  5. OceanToken: Hunyuan API models and rates (checked 2026-11-20)
  6. OceanToken: Hy-MT2-30B-A3B model page (checked 2026-11-20)
  7. OceanToken docs: Hy-MT2-1.8B  (checked 2026-11-20)

Get your OceanToken API key

  1. Create an OceanToken account and an API key.
  2. Copy the snippet below, paste your key, and run it.
  3. Check the current rate on /hunyuan-api.
curl https://api.oceantoken.ai/v1/chat/completions \
  -H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "tencent/hy-mt2-7b", "messages": [{"role": "user", "content": "Translate the following text into French.\nNote that you should only output the translated result without any additional explanation:\n\nYour order has shipped."}]}'

Get API Key 

  • Hunyuan
  • LLM API
  1. 11 min read

    Veo 3.1 Reference Images API Guide

    How to send reference images to Veo 3.1 through the API: input_references vs first frame, which tiers take them, two-shot Python script and a consistency test.

    • Veo
    • AI video
    • Tutorial
  2. 12 min read

    LLM Function Calling API Across Models

    Write one LLM function calling API loop that works across GPT, Claude, Gemini, Qwen, GLM and DeepSeek: tool_choice, streaming and the silent no-call trap.

    • LLM API
    • Tutorial
  3. 10 min read

    LLM Image Input API: Screenshots and Scans

    Send screenshots, photos and scans to a chat model with one LLM image input API: URL vs base64 data URL, per-model image limits, the 400 error and token costs.

    • LLM API
    • Tutorial