That's possible too, but my concern is more about if text is ie in Romanian and you want to translate into Arabic, that may not be supported by DeepL. Plugin only cares about target language, as it expect source to be always english.
Anyway, you can give it a try.
require_once osc_plugins_path() . osc_plugin_folder(__FILE__) . 'src/deepl/vendor/autoload.php';
$text = 'abcd';
$target_lang_code = 'de';
$source_lang_code = 'sk';
$translator = new DeepL\Translator(trd_param('api_key'));
$options = array(
'tag_handling' => 'html', // html, xml
'formality' => 'prefer_less',
// 'split_sentences' => 'nonewlines', // off, on, nonewlines
'max_retries' => 1, // default 5
'timeout' => 3, // default 10
'enable_beta_languages' => 1
);
$result = $translator->translateText($text, $source_lang_code, $target_lang_code, $options);
echo ($result->text ?? '');