Translate text from one language to another for multilingual communication, content localization, and language learning.

Quickstart

Translate Text

Send a text input to translate it into another language.

import Bytez from "bytez.js";

const client = new Bytez("YOUR_BYTEZ_KEY_HERE");
const model = client.model("Helsinki-NLP/opus-mt-en-zh");

const inputText = "Hello, how are you? Beautiful day today, isn't it?";

const { error, output: [{ translation_text }] } = await model.run(inputText);

if (error) {
  console.error("Error:", error);
} else {
  console.log("Translation:", translation_text);
}

```python python
from bytez import Bytez

client = Bytez("YOUR_BYTEZ_KEY_HERE")

model = client.model("Helsinki-NLP/opus-mt-en-zh")

model.load()

input_text = "Hello, how are you? Beautiful day today, isn't it?"

result = model.run(input_text)

# Extract the translation text
output = result["output"]

translation_text = output[0]["translation_text"]

print(translation_text)

Demo