Description
A few days ago, the DeeplTranslator started failing with an AuthorizationException, even when using a valid API Key.
Traceback
Query error: The program has returned exit code 1.
Traceback (most recent call last):
File "translate_deepl.py", line 31, in <module>
result = translator.translate(args.text)
File "deep_translator\deepl.py", line 87, in translate
raise AuthorizationException(self.api_key)
deep_translator.exceptions.AuthorizationException: Unauthorized access with the api key ...
Cause
This issue is caused by the DeepL API breaking changes (effective March 2025) which have deprecated:
- GET requests for translation (now requires POST).
- The
auth_key query parameter (now requires Authorization header).
Reference
DeepL Breaking Changes Notice
Proposed Solution
The DeeplTranslator.translate method needs to be updated to use requests.post and send the API key via the Authorization: DeepL-Auth-Key [KEY] header.