This sample explains in detail how an App for Google Sheets can be built to integrate DeepL translations into Google Sheets. This also works quite similarly for Google Docs!

GitHub - DeepLcom/google-sheets-example: Example using DeepL API in Google Sheets scripts

Google Sheet Example on Github