Skip to content

Translation (Batch Mode)

Translate multiple texts with the same translation settings in a single blocking request.

Endpoint: POST /translation/translate-batch

Sent as JSON.

Field Type Required Description
texts array of strings yes Texts to translate (max 20)
contexts array of strings/nulls no Optional per-text translator context, aligned by index with texts
sourceLanguage string yes Source language code (use auto for automatic detection)
targetLanguage string yes Target language code
glossaryId string no Glossary ID to apply during translation
prompt string no Custom prompt to guide translation
flag boolean no Preserve source length when translating
ignoreCache boolean no Ignore previously cached translation results
fluency boolean no Evaluate translation fluency for each text in the same LLM call

Success Response (200)

{
"status": "ok",
"timestamp": "2025-01-12T22:31:48.856Z",
"data": {
"translations": [
{ "index": 0, "content": "Hallo, Welt!" },
{ "index": 1, "content": "Wie geht es dir?" },
{ "index": 2, "content": "Vielen Dank" }
],
"batch_summary": {
"total": 3,
"successful": 3,
"failed": 0,
"total_credits": 12
},
"word_count": 9
}
}
Terminal window
curl -X POST "https://platform.algebras.ai/api/v1/translation/translate-batch" \
-H "X-Api-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"sourceLanguage": "en",
"targetLanguage": "de",
"texts": [
"Hello, World!",
"How are you?",
"Thank you very much"
]
}'

Same request shape as /translation/translate-batch, but dispatches the batch and returns a job ID immediately instead of blocking for the result.

Endpoint: POST /translation/translate-batch-async

Same fields as Translate Batch above: texts, contexts, sourceLanguage, targetLanguage, glossaryId, prompt, flag, ignoreCache, fluency.

Header Required Description
X-Webhook-Url no URL to receive a POST notification with the batch result once the job completes

Success Response (200)

{
"status": "ok",
"timestamp": "2025-01-12T22:31:48.856Z",
"data": {
"job_id": "cmabc123batchjob",
"status": "PENDING"
}
}
Terminal window
curl -X POST "https://platform.algebras.ai/api/v1/translation/translate-batch-async" \
-H "X-Api-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"sourceLanguage": "en",
"targetLanguage": "de",
"texts": [
"Hello, World!",
"How are you?",
"Thank you very much"
]
}'

Get the status and result of an async batch translation job by ID.

Endpoint: GET /translation/translate-batch-async/{id}

  • id: The job_id returned from the start-job endpoint

Success Response (200)

{
"status": "ok",
"timestamp": "2025-01-12T22:31:48.856Z",
"data": {
"id": "cmabc123batchjob",
"status": "READY",
"createdAt": "2025-01-12T22:31:00.000Z",
"completedAt": "2025-01-12T22:31:48.856Z",
"result": {
"translations": [
{ "index": 0, "content": "Hallo, Welt!" },
{ "index": 1, "content": "Wie geht es dir?" },
{ "index": 2, "content": "Vielen Dank" }
],
"batch_summary": {
"total": 3,
"successful": 3,
"failed": 0,
"total_credits": 12
},
"word_count": 9
},
"sourceLanguage": "en",
"targetLanguage": "de"
}
}

status is one of PENDING, READY, or ERROR. result (same shape as the sync /translate-batch response data) is present only when status is READY; error is present only when status is ERROR.

Terminal window
curl -X GET "https://platform.algebras.ai/api/v1/translation/translate-batch-async/cmabc123batchjob" \
-H "X-Api-Key: your_api_key_here"