|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > 1. Key Management > AIG. - AI Google Gemini Integration |
MiniRobotLanguage (MRL)
AIG.Get Key
Retrieve the Current Google Generative AI API Key
Intention
GetKey Command: Accessing Your API Key
The GetKey Command retrieves the currently active Google Generative AI API key from your script�s session.
This is useful for verification, debugging, or custom key management within your workflow.
It�s part of the API Key Management suite within AIG.
The GetKey Command fetches the value stored in the AIG_APIKey global variable, set previously by AIG.Set Key.
You can store the retrieved key in a variable or, if unspecified, it�s placed on the Top of Stack (TOS).
Retrieving the API key is valuable for:
�Verification: Confirm the key set by AIG.Set Key matches your intent.
�Debugging: Check if the correct key is active before API calls.
�Customization: Use the key in script logic or logging.
Call this Command after setting the key with AIG.Set Key to retrieve it.
If no key has been set, it returns an empty string.
Example Usage
' Set the key and retrieve it to a variable
AIG.Set Key|gsk-xyz1234567890abcdef
AIG.Get Key|$$KEY
DBP.Current API Key: $$KEY
' Retrieve the key to the stack
AIG.Set Key|from_File
AIG.Get Key
POP.$$KEY
DBP.Key from Stack: $$KEY
The first example stores the key in a variable, while the second uses the stack.
Illustration
+-----------------------------+
� Retrieved API Key � � � � � �
+-----------------------------�
� gsk-xyz1234567890abcdef � � �
+-----------------------------+
Example output after setting a key directly.
Syntax
AIG.GetKey[|P1]
AIG.Get Key[|P1]
Parameter Explanation
P1 - (Optional) The variable to store the retrieved API key. If omitted, the key is placed on the Top of Stack (TOS).
Example
' Set and retrieve the key for verification
AIG.Set Key|gsk-xyz1234567890abcdef
AIG.Get Key|$$KEY
DBP.Verified Key: $$KEY
AIG.Ask|What time is it?|$$RET
DBP.Response: $$RET
ENR.
Remarks
- Returns an empty string if no key has been set via AIG.Set Key .
- Does not fetch keys from files directly; reflects only the current session�s key.
Limitations
- Does not validate the key�s authenticity or usability.
- Limited to the key set in the current script session.
See also:
? AIG.Ask