HuggingFace — Machine Translation
hf_inference.nlp.translateTranslate text between languages using the Helsinki-NLP opus-mt model family via HuggingFace Inference API. Covers 1,000+ language pairs (English to French, Spanish, German, Chinese, Japanese, Arabic, Russian, etc.). Specify target_lang as a 2-letter ISO 639-1 code (e.g. "fr", "es", "de", "zh", "ja"). The adapter automatically selects the opus-mt-{source}-{target} model. Useful for multilingual content pipelines, localization, and cross-language information retrieval.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Input text to process. Maximum ~10,000 characters depending on model context window. | |
| model | No | Override the HuggingFace model ID for translation. If omitted, the adapter automatically selects "Helsinki-NLP/opus-mt-{source_lang}-{target_lang}" (e.g. "Helsinki-NLP/opus-mt-en-fr"). Use this to specify a different translation model, such as "facebook/nllb-200-distilled-600M" for broader multilingual coverage. | |
| source_lang | No | ISO 639-1 two-letter source language code. Default: "en" (English). Change if the input text is in a language other than English (e.g. "fr" for French input, "es" for Spanish input). A Helsinki-NLP/opus-mt model must exist for the source→target language pair. | |
| target_lang | Yes | ISO 639-1 two-letter target language code (e.g. "fr" for French, "es" for Spanish, "de" for German, "pt" for Portuguese, "it" for Italian, "nl" for Dutch, "ru" for Russian, "zh" for Chinese, "ja" for Japanese, "ar" for Arabic, "ko" for Korean, "hi" for Hindi). Must have an available Helsinki-NLP/opus-mt model for the source→target pair. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present only when the call failed. Includes error code, message, request_id, and any provider-specific extras. | |
| result | No | Tool response payload. Shape varies per tool — consult the tool description and inputSchema. May be an object, array, string, or number depending on the upstream provider response. |