LibreTranslate: API Dịch Thuật Tự Host 14.4K+ Stars
LibreTranslate (LT) là API dịch máy mã nguồn mở miễn phí dựa trên Argos Translate. Hỗ trợ Docker, CUDA GPU, 30+ ngôn ngữ và triển khai offline. Bao gồm cài đặt, benchmark hiệu suất, giám sát và tích hợp với OpenAI Whisper, Coqui TTS, Argos Translate.
- AGPL-3.0
- Cập nhật 2026-05-19
apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: libretranslate-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: libretranslate minReplicas: 2 maxReplicas: 10 metrics:
- type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70
Deploy:
```b
a
s
h
kubectl apply -f libretranslate-deployment.yaml
Backup Strategy #
Language models can be re-downloaded, but the SQLite database with API keys and logs should be backed up:
a
s
h
#!/bin/bash
# backup.sh - Daily backup cron job
BACKUP_DIR="/backups/libretranslate"
DATE=$(date +%Y%m%d)
# Backup database
docker cp libretranslate:/app/db "$BACKUP_DIR/db_$DATE.sqlite"
# Sync models (optional - can be re-downloaded)
rsync -av /var/lib/docker/volumes/lt-models/_data/ "$BACKUP_DIR/models/"
# Keep only 7 days of backups
find "$BACKUP_DIR" -name "db_*.sqlite" -mtime +7 -delete
Add to crontab:
a
s
h
0 2 * * * /path/to/backup.sh
Comparison with Alternatives #
| Feature | LibreTranslate | Argos Translate | Google Translate API | DeepL API |
|---|---|---|---|---|
| License | AGPL-3.0 | MIT | Proprietary | Proprietary |
| Self-Hosted | Yes | Yes (CLI) | No | No |
| Offline Capable | Yes | Yes | No | No |
| Languages Supported | 30+ | 30+ | 130+ | 30+ |
| Cost (1M chars/mo) | ~$10 VPS | ~$10 VPS | $20 | $6.99+ |
| Translation Quality | Good | Good | Excellent | Excellent |
| REST API | Yes | No | Yes | Yes |
| Web UI | Yes | No | Yes | Yes |
| GPU Acceleration | Yes (CUDA) | CPU only | Cloud-only | Cloud-only |
| Privacy | Full (data stays local) | Full | Data sent to Google | Data sent to DeepL |
| Rate Limits | Configurable | N/A | Quota-based | Quota-based |
| Setup Complexity | Medium (Docker) | Low (pip) | Low (API key) | Low (API key) |
LibreTranslate fills a specific niche: it is the only option that combines a REST API, web UI, GPU acceleration, and full offline capability under an open-source license. Argos Translate offers the same translation engine but lacks the API layer. Google and DeepL offer superior quality and broader language support, but at the cost of privacy, recurring fees, and external dependency.
Limitations / Honest Assessment #
LibreTranslate is not a universal replacement for commercial translation APIs. Understanding its limitations is essential for making an informed adoption decision.
Translation quality gap: On the WMT14 benchmark, LibreTranslate trails DeepL by approximately 5.7 BLEU points and Google Translate by 4.4 points. This gap is most noticeable for: (1) less common language pairs like English to Swahili or Finnish to Vietnamese, (2) domain-specific terminology in legal, medical, or technical texts, and (3) creative or idiomatic content where context and nuance matter.
Resource intensity: Each loaded language pair consumes 300-600MB of RAM. A full 30-language deployment requires 8GB+ of memory. This makes LibreTranslate unsuitable for resource-constrained environments like Raspberry Pi (unless loading only 2-3 languages) or small VPS instances.
Language coverage: With 30+ languages, LibreTranslate covers the most common language pairs but falls far short of Google Translate’s 130+ languages. If your use case requires translation for minority or endangered languages, LibreTranslate is not sufficient.
No real-time streaming: LibreTranslate processes complete text segments. It does not support streaming translation or real-time speech-to-text translation, which limits its applicability in live conversation scenarios.
AGPL-3.0 license implications: The AGPL-3.0 license requires that any network use of the software (including via API) triggers the share-alike requirement. Organizations building proprietary products on top of LibreTranslate should consult legal counsel regarding license compliance.
Maintenance burden: Self-hosting means you are responsible for updates, security patches, model updates, and infrastructure monitoring. Factor in operational overhead when comparing costs against managed APIs.
Frequently Asked Questions #
How does LibreTranslate compare to running Argos Translate directly? #
LibreTranslate is essentially a REST API wrapper around Argos Translate. If you only need command-line translation, Argos Translate has lower overhead. If you need an HTTP API, web interface, or multi-user access, LibreTranslate adds those layers. Both share identical translation models and produce identical output.
Can LibreTranslate run on a Raspberry Pi? #
Yes, with constraints. The ARM Docker image is optimized for ARM64 systems. Load only 2-3 language pairs to keep memory usage under 2GB. Expect translation latency of 800ms-1.5s per request on a Raspberry Pi 4 with 4GB RAM. For production use, a minimum of 4GB RAM is recommended.
How do I update language models without restarting the container? #
Set the LT_UPDATE_MODELS=true environment variable. LibreTranslate checks for model updates on startup. For rolling updates in a Kubernetes deployment, use a rolling restart strategy: update the deployment with the new image version, and Kubernetes replaces pods incrementally.
What is the maximum text length per translation request? #
The default maximum is configurable via the --char-limit flag or LT_CHAR_LIMIT environment variable. The built-in default is 10,000 characters per request. For longer documents, split the text into chunks and make sequential API calls.
Is LibreTranslate suitable for HIPAA or GDPR compliance? #
LibreTranslate’s self-hosted nature means no data leaves your infrastructure, which simplifies compliance. However, compliance is a system-level property, not just a software property. You must also secure the host OS, network, backups, and access controls. Consult your compliance officer for a full assessment.
How do I add a custom language model? #
LibreTranslate supports models in the Argos Translate format (OpenNMT CTranslate2 models). Place custom .argosmodel files in the models directory and restart the container. Custom models are useful for domain-specific terminology or languages not covered by the default model set.
Can I use LibreTranslate with a frontend framework like React or Vue? #
Yes. The /translate endpoint accepts JSON and supports CORS when configured. Example React hook:
i
p
t
// useTranslation.ts
import { useState, useCallback } from "react";
export function useTranslation() {
const [translating, setTranslating] = useState(false);
const translate = useCallback(async (text: string, source: string, target: string) => {
setTranslating(true);
try {
const res = await fetch("http://localhost:5000/translate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ q: text, source, target }),
});
const data = await res.json();
return data.translatedText;
} finally {
setTranslating(false);
}
}, []);
return { translate, translating };
}
What are the network requirements for an offline deployment? #
For fully offline operation, build the Docker image with --build-arg with_models=true to embed language models during the build. The resulting image contains all necessary files and requires no internet connection at runtime. Image size increases by approximately 2-3GB depending on the number of included languages.
Conclusion #
LibreTranslate delivers on its core promise: a capable, self-hosted translation API with zero per-request costs and complete data privacy. With 14,400+ GitHub stars, active maintenance, and v1.9.5 delivering stability improvements, it is production-ready for teams that prioritize control over absolute translation quality.
The ideal LibreTranslate adopter is a team with: (1) consistent translation volume that makes per-character pricing painful, (2) strict data residency requirements, (3) DevOps capacity to manage infrastructure, and (4) tolerance for a measurable but acceptable quality gap versus commercial alternatives.
If that describes your situation, start with the Docker Compose setup in this guide, load 5 languages, and measure translation quality against your specific content. Most teams find the quality adequate for internal tools, product catalogs, and user-generated content.
For teams that need the absolute highest translation quality or support for 100+ languages, commercial APIs remain the pragmatic choice. For everyone else, LibreTranslate eliminates a recurring line item from your cloud bill.
Join the LibreTranslate Telegram group for community support, or follow the project on GitHub for release updates.
Recommended Hosting & Infrastructure #
Before you deploy any of the tools above into production, you’ll need solid infrastructure. Two options dibi8 actually uses and recommends:
- DigitalOcean — $200 free credit for 60 days across 14+ global regions. The default option for indie devs running open-source AI tools.
- HTStack — Hong Kong VPS with low-latency access from mainland China. This is the same IDC that hosts dibi8.com — battle-tested in production.
Affiliate links — they don’t cost you extra and they help keep dibi8.com running.
Sources & Further Reading #
- LibreTranslate GitHub Repository
- LibreTranslate Official Documentation
- Argos Translate GitHub Repository
- LibreTranslate Docker Hub
- OpenNMT Framework Documentation
- AGPL-3.0 License Summary
- DigitalOcean Docker Deployment Guide
- NVIDIA CUDA Docker Setup
- LibreTranslate Kubernetes Examples
Disclosure: This article contains affiliate links. If you sign up for DigitalOcean using the referral link in this guide, we may receive a commission at no additional cost to you. Affiliate links help support the ongoing maintenance of open-source documentation projects like this one.
💬 Bình luận & Thảo luận