Translation API
POST /v1/text/translate
Please refer to the Quickstart Guide to obtain your API key.
Replace $YOUR_API_KEY with your actual API key generated in the previous step.
curl --location --request POST 'https://api-platform.ope.ai/v1/text/translate' \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"opeai/MT-LLM",
"source_lang":"en",
"target_lang":"zh",
"stream":true,
"text": "Wuhan has many places worth visiting. For example, East Lake Scenic Area offers beautiful natural scenery; Yellow Crane Tower is a unique combination of ancient architecture and cultural history; and the Hankou River Beach is a great spot for walking and relaxation. Other famous attractions include the Wuhan Yangtze River Bridge and Hubu Alley. Hope you have a great time in Wuhan!"
}'
import requests
import json
url = 'https://api-platform.ope.ai/v1/text/translate'
headers = {
'Authorization': 'Bearer $YOUR_API_KEY',
'Content-Type': 'application/json'
}
payload = {
"model": "opeai/MT-LLM",
"source_lang": "en",
"target_lang": "zh",
"stream": True,
"text": "Wuhan has many places worth visiting. For example, East Lake Scenic Area offers beautiful natural scenery; Yellow Crane Tower is a unique combination of ancient architecture and cultural history; and the Hankou River Beach is a great spot for walking and relaxation. Other famous attractions include the Wuhan Yangtze River Bridge and Hubu Alley. Hope you have a great time in Wuhan!"
}
response = requests.post(url, headers=headers, json=payload)
print(response.text)
model String Required
Please select opeai/MT-LLM to ensure translation quality.
source_lang Language Code Required
Source language
| Language Name | Code | Note |
|---|---|---|
| English | en | Core support |
| Chinese (Simplified / Traditional) | zh | Main support |
| Korean | ko | East Asian coverage |
| Japanese | ja | East Asian coverage |
| Urdu | ur | National language of Pakistan |
| Bengali | bn | |
| Hindi | hi | |
| Portuguese | pt | |
| Filipino | tl | |
| Indonesian | id | |
| Malay | ms | |
| Cantonese | yue | |
| Spanish | es | |
| Russian | ru | Representative of Slavic languages |
| Hokkien | nan | |
| Brazilian Portuguese | pt-br |
model String Required
Please select opeai/MT-LLM to ensure translation quality.
stream Boolean or null Optional Default is false
Specify whether to use streaming output. Values:
false: The model returns the full result after all content is generated.
true: The model returns partial content as it is generated. You must read the chunks in real time to reconstruct the result.
text String Required
Text to be translated