Skip to content

Machine Translation API

Comvi integrates with multiple machine translation providers to generate translation suggestions automatically. You can request suggestions for individual keys, translate in bulk, or stream real-time suggestions as they arrive from each provider.

ProviderIDGlossary support
Google TranslategoogleYes
DeepLdeeplYes
Amazon TranslateawsNo
Azure TranslatorazureNo
OpenAIopenaiNo
Anthropic ClaudeanthropicNo

Check which machine translation providers are available on the server.

GET /api/v1/projects/:projectId/mt/configured-providers
ParameterTypeRequiredDescription
projectIdintegerYesProject ID
Terminal window
curl -X GET \
-H "X-API-Key: tlk_your_api_key" \
https://api.comvi.io/api/v1/projects/1/mt/configured-providers
{
"providers": {
"google": true,
"deepl": true,
"aws": false,
"azure": false,
"openai": true,
"anthropic": true
}
}
StatusErrorDescription
401UNAUTHORIZEDMissing or invalid authentication
403FORBIDDENNo permission to view MT settings

Request machine translation suggestions for a specific translation key. Returns suggestions from all enabled providers.

POST /api/v1/projects/:projectId/mt/suggestions
ParameterTypeRequiredDescription
projectIdintegerYesProject ID
FieldTypeRequiredDescription
keystringYesTranslation key name (1-512 characters)
namespacestringNoNamespace name (uses default if omitted)
sourceLocalestringYesSource language code
targetLocalestringYesTarget language code
sourceTextstringNoSource text to translate (auto-resolved from key if omitted)
limitintegerNoMax number of suggestions (1-10)
Terminal window
curl -X POST \
-H "X-API-Key: tlk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"key": "welcome.message",
"sourceLocale": "en",
"targetLocale": "uk",
"limit": 3
}' \
https://api.comvi.io/api/v1/projects/1/mt/suggestions
[
{
"providerId": "google",
"providerLabel": "Google Translate",
"text": "Ласкаво просимо до нашого додатку!"
},
{
"providerId": "deepl",
"providerLabel": "DeepL",
"text": "Ласкаво просимо до нашого застосунку!"
},
{
"providerId": "openai",
"providerLabel": "OpenAI",
"text": "Вітаємо у нашому застосунку!"
}
]
StatusErrorDescription
400INVALID_INPUTSource and target locales must be different
401UNAUTHORIZEDMissing or invalid authentication
403FORBIDDENNo permission to use machine translation
429TOO_MANY_REQUESTSRate limit exceeded

Stream machine translation suggestions in real time. Suggestions arrive incrementally as each provider responds, rather than waiting for all providers to finish.

Browser-friendly variant using Server-Sent Events. Compatible with the EventSource API.

GET /api/v1/projects/:projectId/mt/suggestions/stream
ParameterTypeRequiredDescription
keystringYesTranslation key name
sourceLocalestringYesSource language code
targetLocalestringYesTarget language code
namespacestringNoNamespace name
sourceTextstringNoSource text to translate
limitintegerNoMax providers (1-10)
const url = new URL('https://api.comvi.io/api/v1/projects/1/mt/suggestions/stream');
url.searchParams.set('key', 'welcome.message');
url.searchParams.set('sourceLocale', 'en');
url.searchParams.set('targetLocale', 'uk');
const source = new EventSource(url, { withCredentials: true });
source.addEventListener('suggestion', (event) => {
const data = JSON.parse(event.data);
console.log(`${data.providerLabel}: ${data.text}`);
});
source.addEventListener('done', () => {
source.close();
});

Programmatic variant using newline-delimited JSON.

POST /api/v1/projects/:projectId/mt/suggestions/stream

Same as Get MT suggestions.

Each line is a JSON object:

{"event":"suggestion","data":{"providerId":"google","providerLabel":"Google Translate","text":"Ласкаво просимо!"}}
{"event":"suggestion","data":{"providerId":"deepl","providerLabel":"DeepL","text":"Ласкаво просимо!"}}
{"event":"done","data":{}}

Translate multiple keys at once for a target locale. The job is queued and processed asynchronously. Returns a job ID you can use to poll for status.

POST /api/v1/projects/:projectId/keys/batch/mt
ParameterTypeRequiredDescription
projectIdintegerYesProject ID
FieldTypeRequiredDescription
keyIdsinteger[]YesArray of translation key IDs to translate (at least 1)
sourceLocaleCodestringYesSource language code
targetLocaleCodestringYesTarget language code
overwriteExistingbooleanNoOverwrite existing translations (default: false)
Terminal window
curl -X POST \
-H "X-API-Key: tlk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"keyIds": [42, 43, 44, 45],
"sourceLocaleCode": "en",
"targetLocaleCode": "uk",
"overwriteExisting": false
}' \
https://api.comvi.io/api/v1/projects/1/keys/batch/mt

Returns 202 Accepted:

{
"jobId": "mt_job_abc123",
"status": "queued",
"totalKeys": 4,
"message": "Batch MT job queued successfully"
}

Poll the status of a batch machine translation job.

GET /api/v1/projects/:projectId/keys/batch/mt/:jobId/status
ParameterTypeRequiredDescription
projectIdintegerYesProject ID
jobIdstringYesJob ID from the batch MT response
Terminal window
curl -X GET \
-H "X-API-Key: tlk_your_api_key" \
https://api.comvi.io/api/v1/projects/1/keys/batch/mt/mt_job_abc123/status
{
"jobId": "mt_job_abc123",
"status": "completed",
"progress": 100,
"result": {
"processed": 4,
"failed": 0,
"duration": 3200.5,
"errors": []
}
}
StatusDescription
waitingJob is in the queue
activeJob is being processed
completedJob finished successfully
failedJob failed

Cancel a running or queued batch machine translation job.

POST /api/v1/projects/:projectId/keys/batch/mt/:jobId/cancel
Terminal window
curl -X POST \
-H "X-API-Key: tlk_your_api_key" \
https://api.comvi.io/api/v1/projects/1/keys/batch/mt/mt_job_abc123/cancel
{
"success": true,
"message": "Job cancelled successfully"
}

Translate ICU plural, select, or combined message forms. Returns translations for each form variant via an NDJSON stream.

POST /api/v1/projects/:projectId/mt/icu-translate
FieldTypeRequiredDescription
sourceLocalestringYesSource language code
targetLocalestringYesTarget language code
icuTypestringYesICU type: plural, select, or combined
formsobjectYesICU form variants keyed by category (e.g., one, other)
pluralVariablestringNoVariable name for plural (e.g., count)
selectVariablestringNoVariable name for select (e.g., gender)
Terminal window
curl -X POST \
-H "X-API-Key: tlk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"sourceLocale": "en",
"targetLocale": "uk",
"icuType": "plural",
"forms": {
"one": "{count} item",
"other": "{count} items"
},
"pluralVariable": "count"
}' \
https://api.comvi.io/api/v1/projects/1/mt/icu-translate
{"event":"form","data":{"form":"one","text":"{count} елемент"}}
{"event":"form","data":{"form":"other","text":"{count} елементів"}}
{"event":"done","data":{}}