AID. - Artificial Intelligence DeepSeek Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AID. - DeepSeek > !Key Management >

AID. - Artificial Intelligence DeepSeek Utility

AID.GetKey

Previous Top Next


MiniRobotLanguage (MRL)

 

AID.Get Key
Retrieve the Current DeepSeek API Key

 

Intention

 

GetKey Command: Access Your DeepSeek API Key
 
The GetKey command retrieves the currently set DeepSeek API key, allowing you to verify or utilize it within your script. This is particularly useful for debugging, logging, or dynamically managing API authentication.

It complements AID.Set Key by providing visibility into the key currently in use, ensuring seamless integration with DeepSeek’s cloud services.

This command is part of the AID - DeepSeek API suite.

 

What is the GetKey Command?

 

The GetKey command fetches the value of the global AID_Key variable, which holds the DeepSeek API key set via AID.Set Key. You can store this value in a variable or, if no variable is specified, it’s placed on the Top of Stack (TOS).

If no key has been set, it returns an empty string or triggers an error, depending on the script’s error handling.

 

Why Do You Need It?

 

Retrieving the API key serves several purposes:

Verification: Confirm the key currently in use matches your expectations (e.g., sk-ds1234567890abcdef).

Debugging: Diagnose authentication issues if API calls fail.

Dynamic Use: Pass the key to other functions or log it for auditing (with caution due to security risks).

 

How to Use the GetKey Command?

 

Call the command with an optional variable to store the retrieved key. If no variable is provided, the key is pushed onto the stack, requiring a POP. command to retrieve it.

The key must first be set using AID.Set Key, either directly or from a file.

 

Example Usage

 

' Set the key first

$$KEY=sk-ds1234567890abcdef

AID.Set Key|$$KEY

' Retrieve it to a variable

AID.Get Key|$$RET

DBP.Current Key: $$RET

' Retrieve it to the stack

AID.Get Key

POP.$$RET

DBP.Key from Stack: $$RET

ENR.

This outputs the key (e.g., sk-ds1234567890abcdef) if set, or an empty string if not.

 

Illustration

 

┌────────────────────┐

│ AID_Key            │

├────────────────────┤

│ sk-ds1234567890... │

└───── GetKey ───────┘

Retrieving the stored API key for use or verification.

 

Syntax

 

AID.GetKey[|P1]

AID.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

 

' Load key from file and verify it

AID.Set Key|fromFile

AID.Get Key|$$KEY

DBP.Retrieved Key: $$KEY

ENR.

 

Remarks

 

- Returns an empty string if no key is set.

- The retrieved key is the full string as set by AID.Set Key, including any formatting (e.g., sk-ds...).

- Handle the key with care—avoid logging or displaying it publicly to prevent exposure.

 

Limitations

 

- Does not validate the key’s authenticity; it only returns the stored value.

- Cannot retrieve keys from encrypted files directly; it reflects the in-memory AID_Key variable.

 

See also:

 

AID.Set Key

AID.Save Key

Key Management