|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIX. - Grok / X - API > !Setup and Configuration > AIX. - Artificial Intelligence Extended Utility |
MiniRobotLanguage (MRL)
AIX.Get Key
Retrieve the Encrypted Grok API Key
Intention
Get Key Command: Access the Saved API Key
The AIX.Get Key command retrieves the encrypted Grok API key previously saved using AIX.Save Key.
This allows secure access to the key for use in AIX scripts, ensuring it remains protected while enabling seamless integration with the xAI ecosystem as of March 18, 2025.
The AIX.Get Key command reads the encrypted Grok API key from a specified or default file (e.g., AIX_License_Key.dat) and returns it in a decrypted form.
The key is typically stored by AIX.Save Key at ?exeloc\AIX_License_Key.dat unless a custom path was provided.
The retrieved key can be stored in a variable or pushed to the Top of Stack (TOS) for immediate use in commands like AIX.Set Key.
Retrieving the API key is useful for:
•Convenience: Quickly load the key into scripts without re-entering it.
•Security: Access the key without exposing it in plain text within the script.
•Flexibility: Retrieve the key from a custom or default location for multi-script environments.
Invoke the command with an optional file path parameter to specify the location of the encrypted key file.
If no path is provided, it defaults to ?exeloc\AIX_License_Key.dat.
The command decrypts the key and stores it in an optional variable or pushes it to the Top of Stack (TOS).
This key can then be used with AIX.Set Key for API calls.
No additional API costs are incurred as of March 18, 2025, since this is a local file operation.
Example Usage
' Save a key first (from previous example)
$$KEY=gsk-abcdefghijklmnopqrstuvwxyz123456
AIX.Save_Key|$$KEY
' Retrieve the key into a variable
AIX.Get_Key|$$KEY
AIX.Set_Key|$$KEY
AIX.Ask|What is the time?|$$ANS
DBP.Answer: $$ANS
Retrieves the key from the default file and uses it for an API call.
' Retrieve from a custom path
AIX.Get_Key|C:\Secure\Custom_Key.dat|$$CUSTOM_KEY
AIX.Set_Key|$$CUSTOM_KEY
AIX.Ask|Describe the universe|$$UNI
DBP.Universe: $$UNI
ENR.
Retrieves the key from a custom file and uses it for a query.
Illustration
┌──────────────┬──────────────┬──────────────────────────────────────────────────────────────┐
│ File Path │ Action │ Outcome │
├──────────────┼──────────────┼──────────────────────────────────────────────────────────────┤
│ Omitted │ Uses default │ Key from ?exeloc\AIX_License_Key.dat │
├──────────────┼──────────────┼──────────────────────────────────────────────────────────────┤
│ Custom │ Uses path │ Key from specified file (e.g., C:\Secure\Custom_Key.dat) │
└──────────────┴──────────────┴──────────────────────────────────────────────────────────────┘
Illustration of file path behavior.
Syntax
AIX.GetKey[|P1[|P2]]
AIX.Get_Key[|P1[|P2]]
AIX.Gtk[|P1[|P2]]
Parameter Explanation
P1 - (Optional) The file path of the encrypted key file (e.g., "C:\Secure\Custom_Key.dat"). If omitted, defaults to "?exeloc\AIX_License_Key.dat".
P2 - (Optional) The variable to store the retrieved key. If omitted, the key is pushed to the Top of Stack (TOS).
Example
' Save a key first
$$KEY=gsk-abcdefghijklmnopqrstuvwxyz123456
AIX.Save_Key|$$KEY
' Retrieve using default path
AIX.Get_Key||$$RET_KEY
AIX.Set_Key|$$RET_KEY
AIX.Ask|What is Grok?|$$ANS
DBP.Grok Info: $$ANS
Retrieves the key from the default file into $$RET_KEY and uses it.
' Retrieve from custom path with stack
AIX.Save_Key|$$KEY|C:\Secure\Custom_Key.dat
AIX.Get_Key|C:\Secure\Custom_Key.dat
POP.$$STACK_KEY
AIX.Set_Key|$$STACK_KEY
AIX.Ask|Explain xAI|$$XAI
DBP.xAI Info: $$XAI
ENR.
Retrieves the key from a custom file using the stack.
Remarks
- The command assumes the file was created by AIX.Save Key and uses the same encryption method.
- If the file is missing or corrupted, an error is logged, and the command may fail unless handled by ERR.Handle.
Limitations
- Accepts zero, one, or two parameters; additional parameters may cause an error depending on the interpreter.
- Requires a valid encrypted file; cannot generate a key if none exists.
See also:
• AIX.Ask