Try it online! | Translation API | Blog
Free and Open Source Machine Translation Models in 12 languages, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary providers such as Google or AWS to perform translations. Instead, its translation engine is powered by the open source CTranslate2 library.
Also we have translation models for 100 other languages. Contact us info@lingvanex.com
The models support the following languages:
- English-Kurdish
- Kurdish-English
- English-Samoan
- Samoan-English
- English-Xhosa
- Xhosa-English
- English-Lao
- Lao-English
- English-Corsican
- Corsican-English
- English-Cebuano
- Cebuano-English
- English-Galician
- Galician-English
- English-Yiddish
- Yiddish-English
- English-Swahili
- Swahili-English
- English-Yoruba
- Yoruba-English
The models are available for download and you can use them in your projects. You can easily run them in your Python environment as shown below.
To run the models, you need to install ctranslate2 and sentencepiece:
pip install ctranslate2 sentencepiece
The following code demonstrates how to load and use a model for translation from English to Kurdish (en → ku).
import sentencepiece as spm
from ctranslate2 import Translator
path_to_model = <here_is_your_path_to_the_model>
source = 'en'
target = 'ku'
translator = Translator(path_to_model, compute_type='int8')
source_tokenizer = spm.SentencePieceProcessor(f'{path_to_model}/{source}.spm.model')
target_tokenizer = spm.SentencePieceProcessor(f'{path_to_model}/{target}.spm.model')
text = [
'I need to make a phone call.',
'Can I help you prepare food?',
'We want to go for a walk.'
]
input_tokens = source_tokenizer.EncodeAsPieces(text)
translator_output = translator.translate_batch(
input_tokens,
batch_type='tokens',
beam_size=2,
max_input_length=0,
max_decoding_length=256
)
output_tokens = [item.hypotheses[0] for item in translator_output]
translation = target_tokenizer.DecodePieces(output_tokens)
print('\n'.join(translation))
Request:
const url = 'https://api-b2b.backenster.com/b1/api/v3/translate';
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
Authorization: 'API Key'
},
body: JSON.stringify({
platform: 'api',
from: 'en',
to: 'es',
data: 'Hello'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
Response:
{
"err": null,
"result": "Hola"
}
List of language codes: https://docs.lingvanex.com/reference/user-guide
Request:
const url = 'https://api-b2b.backenster.com/b1/api/v3/translate';
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
Authorization: 'API Key'
},
body: JSON.stringify({
platform: 'api',
to: 'en',
data: 'Auf Wiedersehen'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
Response:
{
"err": null,
"result": "Goodbye",
"from": "de"
}
Request:
const url = 'https://api-b2b.backenster.com/b1/api/v3/translate';
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
Authorization: 'API Key'
},
body: JSON.stringify({
platform: 'api',
translateMode: 'html',
from: 'en',
to: 'es',
data: '<h1>Welcome to the test page</h1>'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
Response:
{
"err": null,
"result": "<h1>Bienvenido a la página de prueba</h1>"
}
Request:
const url = 'https://api-b2b.backenster.com/b1/api/v3/translate';
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
Authorization: 'API Key'
},
body: JSON.stringify({
platform: 'api',
from: 'en',
to: 'zh-Hans_CN',
data: 'Hello',
enableTransliteration: true
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
Response:
{
"err": null,
"result": "你好",
"sourceTransliteration": "Hello",
"targetTransliteration": "Ni Hao"
}
You can use the Lingvanex API using the following different languages:
- JavaScript: https://github.com/lingvanex-mt/js-translation-api
- PHP: https://github.com/lingvanex-mt/php-api-translator
- Swift: https://github.com/lingvanex-mt/swift-api-translator
- Python: https://github.com/lingvanex-mt/python-translation-api
- C#: https://github.com/lingvanex-mt/csharp-translation-api
- GO: https://github.com/lingvanex-mt/lingvanex-mt-go-pkg
- R: https://github.com/lingvanex-mt/lingvanex-r-pkg
- Translator for MacOS that uses the Lingvanex API.
- Translator for Windows that uses the Lingvanex API.
- Lingvanex Translator is an Android and iOS apps available on the Play Store and available on the App Store that uses the Lingvanex API.
- Phone Call Translator is an Android and iOS apps available on the Play Store and available on the App Store that uses the Lingvanex API.
- Translator for Browser is a web extension with integrated Lingvanex support.
- Translator for Slack is a bot for Slack with integrated Lingvanex support.
This project is licensed under the MIT License.
If you have any questions, just email info@lingvanex.com