Python implementation of DeepLX, providing a FastAPI-based translation service using DeepL.
This repo only implemented the Free Endpoint
.
- FastAPI-based Async REST API: WSGI version provided for reference
- Docker and Compose support
- Token-based authentication
- Support for both plain text and rich text translation
- Proxy support via environment variables
docker run -d -p 8000:8000 -e TOKEN=your,tokens,here cnbeining/deeplx-python:latest
- Clone the repository:
git clone https://github.com/cnbeining/DeepLX-Python.git
cd DeepLX-Python
- Build and run locally:
docker build -t deeplx-python .
docker run -d -p 8000:8000 -e TOKEN=your,tokens,here deeplx-python
- Clone the repository:
git clone https://github.com/cnbeining/DeepLX-Python.git
cd DeepLX-Python
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run the application:
python app/app.py
TOKEN
: Comma-separated list of valid authentication tokensPROXY
: Proxy URL (optional)
Example:
export TOKEN=token1,token2,token3
export PROXY=http://proxy.example.com:8080
Include your token either as:
- Query parameter:
?token=your_token
- Authorization header:
Authorization: Bearer your_token
orAuthorization: DeepL-Auth-Key your_token
curl -X POST "http://localhost:8000/translate" \
-H "Authorization: Bearer your_token" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world!",
"source_lang": "auto",
"target_lang": "es"
}'
text
: String or array of strings to translatesource_lang
: Source language code (default: "auto")target_lang
: Target language code (default: "en")tag_handling
: Optional parameter for handling HTML/XML tags. Will be automatically detected if not set.
{
"alternatives": ["translated alternatives"],
"code": 200,
"data": "translated text",
"id": 123456,
"method": "Free",
"source_lang": "detected_language",
"target_lang": "target_language"
}
This project is licensed under the GNU AGPL 3.0 License - see the LICENSE file for details.