|
<< Click to Display Table of Contents >> Navigation: »No topics above this level« AIN. - AnythingLLM AI |
MiniRobotLanguage (MRL)
AIN.VerifyAuth
Verify the Authentication of the AnythingLLM API Key
Intention
VerifyAuth Command: Validate Your API Key
The VerifyAuth command checks if your API key is valid by querying the AnythingLLM authentication endpoint.
This ensures your key is authorized for API operations, providing confidence before executing other commands.
It’s part of the AIN - AnythingLLM AI suite.
The VerifyAuth command sends a request to the AnythingLLM /v1/auth endpoint to confirm the validity of the API key.
It returns a status (1 for valid, 0 for invalid) and the raw response, which can be stored in variables or placed on the stack.
Verifying your API key is essential for:
•Security: Confirms your key is authorized before making API calls.
•Troubleshooting: Identifies invalid keys early, preventing failed operations.
•Automation: Allows scripts to adapt based on key validity.
Use the command with an optional API key and variables to store results. If no key is provided, it uses the current AIN_Key.
The default endpoint is http://localhost:3001/v1/auth unless modified.
Example Usage
AIN.SetKey|your_api_key_here
AIN.VerifyAuth||$$RES|$$STA
DBP.Status: $$STA, Response: $$RES
This checks the key and stores the status in $$STA and response in $$RES.
Illustration
┌───────────────┐
│ API Key Check │
├───────────────┤
│ Status: 1/0 │
└───────────────┘
Validates the API key and returns its status.
Syntax
AIN.VerifyAuth[|P1][|P2][|P3]
AIN.VAK[|P1][|P2][|P3]
Parameter Explanation
P1 - (Optional) The API key to verify; defaults to the current AIN_Key if omitted.
P2 - (Optional) Variable to store the raw response; defaults to TOS if omitted.
P3 - (Optional) Variable to store the authentication status (1 = valid, 0 = invalid); defaults to TOS if omitted.
Example
AIN.VerifyAuth|$$KEY|$$RES|$$STA
IVV.$$STA=1
DBP.Valid Key: $$RES
ELS.
DBP.Invalid Key: $$RES
EIF.
ENR.
Remarks
- Requires a prior call to AIN.SetKey if no key is provided.
- Stores the raw response in AIN_Raw_Return for later retrieval.
Limitations
- Requires network access to the AnythingLLM server.
- Limited to verifying keys; does not modify key settings.
See also: