Obtaining API keys#
Anthropic#
Sign up / login to the API console
Click on ‘Get API Keys’
Click on ‘Create Key’ and name it
Copy it and you’re good to go!
The API key is something like: sk_1234567890abcdef1234567890abcdef
You can export it as an environment variable like so:
export ANTHROPIC_API_KEY="your_api_key"
And pass it as an argument to the set_credentials function:
easytl.set_credentials("anthropic", os.environ["ANTHROPIC_API_KEY"])
Azure#
Sign in to your Azure account
Search for the service Translator, at Azure AI Services
Click on Create
Fill the form (choose Subscription, Resource group, Region, name and Tier)
To to the resource when it finishes deploying
Click on Keys and Endpoint
Copy one of the keys, the region and the endpoint for Text Translation
The API key is something like: ‘1234567890abcdef1234567890abcdef’ The region is something like: ‘eastus’ The endpoint is normally: ‘https://api.cognitive.microsofttranslator.com/’
You can export them as environment vars like so:
export AZURE_API_KEY="your_api_key"
export AZURE_REGION="your_region"
export AZURE_ENDPOINT="your_endpoint"
And pass the key as an argument to the set_credentials function:
easytl.set_credentials(api_key=os.environ["AZURE_API_KEY"])
Warning
Make sure that you pass the region and the endpoint to the translate function:
easytl.azure_translate("Hello, world!", "en", "es", region=os.environ["AZURE_REGION"], endpoint=os.environ["AZURE_ENDPOINT"])
DeepL#
Sign up / login to your DeepL account
Navigate to ‘API Keys’ section
Click on ‘Create API Key’ and name it
Copy the generated API key
The API key is something like: 12345678-1234-1234-1234-1234567890ab
You can export it as an environment variable like so:
export DEEPL_API_KEY="your_api_key"
Or you can pass it as an argument to the set_credentials function:
easytl.set_credentials("deepl", os.environ["DEEPL_API_KEY"])
Gemini and Google translate#
Gemini and Google Translate have some common steps
Sign up / login to your Google Cloud account
Create a new project or select an existing one
Now, for Gemini:
Click on ‘Get API Key’
Select your project from the dropdown
Copy the key!
It looks something like: AIzaSyA_1234567890abcdefakubgkuae
You can export it as an environment variable like so:
export GEMINI_API_KEY="your_api_key"
And pass it as an argument to the set_credentials function:
easytl.set_credentials("gemini", os.environ["GEMINI_API_KEY"])
For Google Translate:
From https://console.cloud.google.com/, go to the APIs & Services section
Click on Enable APIs and Services
Search for Cloud Translation API and enable it
Go to Credentials and click on Create credentials
Select Service account
Fill the form and click on Done
Click on the service account you just created
Under the page Keys, click on Add Key and select JSON
Store securely the JSON file
For using the translation service, you pass the path to the JSON file as an argument to the set_credentials function:
easytl.set_credentials("google translate", "path/to/your/credentials.json")
OpenAI#
Sign up / login to your OpenAI account
Navigate to the ‘API Keys’ section
Click on ‘Create new secret key’
Copy the generated API key
The API key is something like: sk-1234567890abcdef1234567890abcdef
You can export it as an environment variable like so:
export OPENAI_API_KEY="your_api_key"
And pass it as an argument to the set_credentials function:
easytl.set_credentials("openai", os.environ["OPENAI_API_KEY"])