Translations#

The translation endpoints let you programmatically translate text using AI.

Translate a String#

Translate a single string from one language to another.

POST /api/translate

Authentication: Token required

Body#

{
  "string": "Welcome to our app!",
  "to": "es",
  "from": "en"
}
Field Type Required Description
string string Yes The text to translate
to string Yes Target language code
from string No Source language code (auto-detected if omitted)

Response#

{
  "string": "Welcome to our app!",
  "translation": "¡Bienvenido a nuestra aplicación!",
  "from": "en",
  "to": "es"
}

Example#

curl -X POST https://api.multilocale.com/api/translate \
  -H "Authorization: Token <base64-token>" \
  -H "Content-Type: application/json" \
  -d '{"string": "Hello world", "to": "fr", "from": "en"}'

Translate to All Languages#

Translate a value to multiple languages at once.

POST /api/translate-to-all-languages

Authentication: Token required

Body#

{
  "value": "Welcome to our app!",
  "languages": ["es", "fr", "de", "ja"],
  "model": "gpt-5-mini",
  "context": "This is a greeting shown on the homepage"
}
Field Type Required Description
value string Yes The text to translate
languages string[] No Target language codes. If omitted, translates to all supported languages.
model string No Translation engine: gpt-5-mini (default), gemini-3.5-flash, or claude-haiku-4-5. Unknown values fall back to the default.
context string No Additional context to improve translation quality
projectId string No When set, the project's saved context is prepended to context so translations use the product's domain terminology

Response#

Returns an object mapping language codes to translated values:

{
  "es": "¡Bienvenido a nuestra aplicación!",
  "fr": "Bienvenue dans notre application !",
  "de": "Willkommen in unserer App!",
  "ja": "私たちのアプリへようこそ!"
}

Example#

curl -X POST https://api.multilocale.com/api/translate-to-all-languages \
  -H "Authorization: Token <base64-token>" \
  -H "Content-Type: application/json" \
  -d '{"value": "Hello", "languages": ["es", "fr"]}'

Variable Handling#

The translation endpoint preserves {variable} placeholders in your strings:

{
  "value": "Hello {name}, you have {count} messages",
  "languages": ["es"]
}

Response:

{
  "es": "Hola {name}, tienes {count} mensajes"
}