Running Free OpenSource Translate API With Docker

Recently I need to translate a lot of text from Chinese to English (I found some awesome Chinese GitHub repo and want to translate).

My first thought was Google Translate. They have good API and second-to-none translation quality. However, imagining going through their setup, I refrained 🙂

So, in search of an opensource translation solution, I found LibreTranslate and was able to setup a docker API to power my translation. The quality of the basic text translation is good so far.

If you are in need of an opensource translation API, give this project a try.

Run LibreTranslate with Docker

Running LibreTranslate with Docker is quite simple. However, there are some caveats:

  • The API will not be available instantly because it needs to download the language models (you need to check the docker log to see this)
  • By default, the container will start downloading all language models (that’s a lot and may take a long time). It’s best you specified the models you want

So, as I only need the English-Chinese pair, here is the command I ran:

 docker run -dit -p 5000:5000 -e LT_FRONTEND_LANGUAGE_SOURCE=cn -e LT_FRONTEND_LANGUAGE_TARGET=en -e LT_LOAD_ONLY=en,zh libretranslate/libretranslate

As you can see, by setting LT_LOAD_ONLY to en and zh, the container only download two models:

LibreTranslate download the models
LibreTranslate download the models

Still, it takes around 5 minutes to download these two models. Imagine how long it takes to download all 56.

One side note, Chinese is zh, not cn :D.

The API is ready when you see the last line: Running on HTTP://

LibreTranslate API test run

Now you can send POST request to translate your text. Here, I tried to translate a Chinese message to English:

LibreTranslate API via POST
LibreTranslate API via POST

I don’t know enough Chinese to judge the quality of this translation but the English text kind of make sense :v.


I’m very grateful for LibreTranslate. It’s quite simple to set up a translation API for free. Give it a try! You can check out their project on Github here

Leave a Reply

Your email address will not be published. Required fields are marked *