Mansa Platform Docs

Translate

Translate text from one supported language to another.

POST/v1/translate

Request example

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Good morning",
  "from": "English",
  "to": "Swahili",
  "tone": "natural"
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Habari za asubuhi"
  }
}

Translate text from one supported language to another. Send the full language name, such as English and Swahili. Codes such as en and sw also work.

Request fields

FieldTypeDefaultDescription
textstringRequiredText to translate
fromstringRequiredSource language name or code
tostringRequiredTarget language name or code
tonestringOmittedprecise, natural, expressive, or formal
contextstringOmittedExtra context that clarifies the text

The source language must be explicit. Automatic detection is not supported.

Read the result from data.translation.

Tone

Use tone when you need a specific register. Omit it otherwise.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Please send the invoice today.",
  "from": "English",
  "to": "Yoruba",
  "tone": "formal"
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Jọwọ fi ìwé àjọ-owó ránṣẹ lónìí."
  }
}

Context

Pass context when a word could mean more than one thing.

curl --fail-with-body "$MANSA_API_BASE_URL/v1/translate" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "The bank is closed.",
  "from": "English",
  "to": "Hausa",
  "tone": "precise",
  "context": "A river bank, not a financial institution."
}'

Output

{
  "context": "ok",
  "data": {
    "translation": "Gabar kogin ta rufe."
  }
}

Supported languages

Stable languages

LanguageCodeLanguageCode
EnglishenSwahilisw
ArabicarAfrikaansaf
AmharicamHausaha
IgboigSomaliso
XhosaxhZuluzu
YorubayoKinyarwandarw
ShonasnTswanatn
ChichewanyLugandalg
MalagasymgOromoom
SesothostSepedinso
Tsongats

Beta languages

LanguageCodeLanguageCode
KirundirnNdebele (South)nr
SwatissTigrinyati
TwiakEweee
LingalalnKikongokg
BambarabmBembabem

Stable languages support translation between one another. Beta coverage is primarily available between English and the beta language.

Errors and billing

Unsupported languages and tones return invalid_request. Successful translations debit Mansa Credits according to text length.