DeepLcom / deepl-python

Official Python library for the DeepL language translation API.
MIT License
1.06k stars 75 forks source link

Error for basic translation using auth_key. #62

Closed hbshrestha closed 1 year ago

hbshrestha commented 1 year ago

I have professional version of DeepL translation.

I installed the deepl package using pip, and tried to run the following script for basic translation.

import deepl
auth_key = {
'host' : "https://api.deepl.com/v2/translate?",
'auth_key': "xxxxxxxxxxx"}  #hidden 
translator = deepl.Translator(auth_key)
result = translator.translate_text("hello world", target_lang = "FR")
print (result.text)

However, I get the following error:

auth_key_is_free_account
    return auth_key.endswith(":fx")
AttributeError: 'dict' object has no attribute 'endswith'

I tried simply by replacing auth_key in following way:

auth_key = "xxxxxxxxxxxxxxxxxxxxxxxx" #hidden

Then, I get the following error:

AuthorizationException(
deepl.exceptions.AuthorizationException: Authorization failure, check auth_key, message: Wrong endpoint. Use https://api.deepl.com

How can this be fixed?

daniel-jones-deepl commented 1 year ago

Hi @hbshrestha Himalaya, thanks for creating this issue.

Your auth_key should be a string, as in your second example.

This error may be caused due to your DeepL account type. Do you use a DeepL API account (both Free or Pro are fine), or do you use another kind of DeepL account?

hbshrestha commented 1 year ago

Thanks @daniel-jones-deepl. I have DeepL pro Ultimate for teams account. When I try to sign up for a free API account image

, it says I cannot sign up for a free account. Does that mean I need to pay separately for using API while having a pro ultimate for teams account? image

daniel-jones-deepl commented 1 year ago

That's correct -- you cannot use the DeepL API with a DeepL Pro Ultimate (non-API) account.

You can sign out of your DeepL Pro Ultimate for teams account and create a DeepL API Free account; you will not be charged for the DeepL API Free account.