Skip to content

Translate Text

Translates text by automatically detecting the source language and translating it to the target language.

Endpoint POST

https://api.ttgtoolbox.com/v1/translations

Request body

This endpoint uses the POST method and requires a JSON object as the request body.

Required parameters

The request body requires the following parameters.

tostringrequired

The language to translate to. See supported languages below.

textstringrequired

The text to translate.

Optional parameters

fromstring

The language to translate from. Unless explicitly specified using the from parameter, the API will determine the source language automatically,

promptSuffixstringadvanced feature

A prompt suffix can be included to add additional context and instructions for the translation.


Example request body

json
{
  "to": "Spanish",
  "text": "Life is like a box of chocolates; you never know what you're gonna get."
}

Example request body with optional parameters

json
{
  "from": "English",
  "to": "French",
  "text": "Sometimes, I guess there just aren't enough rocks.",
  "promptSuffix": "Include the original text before the translated, formatted as: {original_test} --- {translation}"
}

Returns

A JSON object containing the translated text and estimated credit usage.


Response

json
{
  "translation": "Sometimes, I guess there just aren't enough rocks. --- Parfois, je suppose qu'il n'y a tout simplement pas assez de pierres.",
  "credits": 1
}

Notes

Be advised

The Translation API uses a Large Language Model (LLM) to generate the translated text. Repeated calls to the API using the same text may produce slightly different responses.

Supported languages

Bidirectional translation is supported for the following languages, which can be specified using either the from or to parameters.

Language
English
Mandarin Chinese
Spanish
Hindi
French
Standard Arabic
Bengali
Russian
Portuguese
German
Japanese
Javanese
Punjabi
Wu Chinese
Telugu
Korean
Italian
Tamil
Turkish
Marathi