To use the deepl-cli tool, you need a valid DeepL API key. This key allows the tool to authenticate with the DeepL API and perform translations.
If you don't already have one, you can obtain a DeepL API key by signing up for the DeepL API Free plan or a paid plan on the official DeepL website.
The deepl-cli tool reads its configuration from a file named .deepl.toml located in a .deepl directory within your user's home directory. The exact path varies by operating system:
~/.deepl/.deepl.toml (e.g., /home/youruser/.deepl/.deepl.toml)%USERPROFILE%\.deepl\.deepl.toml (e.g., C:\Users\youruser\.deepl\.deepl.toml)If the .deepl directory or the .deepl.toml file does not exist, you need to create them manually.
1. Create the .deepl directory:
mkdir -p ~/.deepl
2. Create the .deepl.toml file:
Open a text editor and create a file named .deepl.toml inside the ~/.deepl/ directory. Add the following content, replacing YOUR_DEEPL_API_KEY with your actual DeepL API key:
api_key = "YOUR_DEEPL_API_KEY"
target_lang = "en" # Default target language (e.g., "en" for English, "fr" for French)
# source_lang = "fr" # Optional: default source language (can be auto-detected)
Important: The api_key and target_lang fields are mandatory. If source_lang is not provided, the tool will attempt to auto-detect the source language.
Here's an example of a complete .deepl.toml file:
api_key = "aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890"
target_lang = "es" # Translate to Spanish by default
source_lang = "en" # Optional: if not set, source language will be auto-detected
Once the configuration file is set up, deepl-cli will automatically use your API key and default language settings for translations.