|
<< Click to Display Table of Contents >> Navigation: »No topics above this level« AIN. - AnythingLLM AI |
MiniRobotLanguage (MRL)
AIN.GetKey
Get the Currently Used API Key
Intention
GetKey Command: Retrieve API Key
The AIN.GetKey command retrieves the currently active API key used for authenticating requests to the AnythingLLM API, storing it in a specified variable.
This is crucial for verifying or reusing the key in scripts, part of the AIN - AnythingLLM AI suite.
The AIN.GetKey command returns the API key currently set via AIN.SetKey or a default configuration, used for authorizing API calls (e.g., to http://localhost:3001/api/chat).
It accesses the stored value (e.g., AIN_Key) maintained by the AIN system.
This command is useful for:
•Verification: Confirm the active API key before making requests.
•Scripting: Reuse the key in custom API calls or logging.
•Debugging: Troubleshoot authentication issues.
Call AIN.GetKey with a variable to store the current API key. It works after AIN.SetKey or with a default key if set.
Example Usage
AIN.SetKey|my_secret_key_123
AIN.GetKey|$$KEY
DBP.Current API Key: $$KEY
Retrieves the API key into $$KEY (e.g., "my_secret_key_123").
Syntax
AIN.GetKey|P1
Parameter Explanation
P1 - Variable to store the API key (required), e.g., "$$KEY".
Example
AIN.SetKey|abc123xyz
AIN.GetKey|$$API
DBP.API Key: $$API
ENR.
Stores "abc123xyz" in $$API and displays it.
Remarks
- Returns an empty string if no key is set.
- Reflects the key used in the last API request if dynamically updated.
Limitations
- Only retrieves the key stored in the AIN system, not external configurations.
- Does not validate the key’s authenticity.
See also:
• AIN.Ask
• AIN.AskV