API Key
GoogleApiKey
This class provides methods to get and set the Google AI platform API key.
Source code in peter_explains/api_key.py
clear()
This function clears the API key from the keyring.
Returns:
Type | Description |
---|---|
None |
get()
Retrieves the API key from the specified file.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The API key. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the API key file does not exist. |
Source code in peter_explains/api_key.py
set(api_key)
Sets the API key for the application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key |
str
|
The API key to be set. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the length of the API key is less than 30 or greater than 50. |
Returns:
Type | Description |
---|---|
None |