AIX. - Artificial Intelligence Extended Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIX. - Grok / X - API > !Model and Endpoint Configuration >

AIX. - Artificial Intelligence Extended Utility

AIX.GetEndpoint

Previous Top Next


MiniRobotLanguage (MRL)

 

AIX.GetEndpoint
Retrieve the Current API Endpoint URL

 

Intention

 

GetEndpoint Command: Access the Current Endpoint
 
The GetEndpoint command retrieves the currently configured API endpoint URL used by the AIX framework for Grok API requests.

This is valuable for verifying the target server, logging configurations, or dynamically adjusting workflows based on the endpoint in use.

It is part of the AIX - Grok / X - API suite.

 

What is the GetEndpoint Command?

 

The GetEndpoint command fetches the current value of the AIX_Endpoint global variable, which stores the URL of the API endpoint used for Grok API communications.

This URL is set by AIX.SetEndpoint or defaults to the value initialized (e.g., "https://api.xai.com/v1/chat/completions"). The retrieved string can be stored in an optional variable or pushed to the Top of Stack (TOS) for further use.

 

Why Do You Need It?

 

Retrieving the endpoint URL is useful for:

Verification: Confirm the active endpoint to ensure requests are sent to the intended server.

Debugging: Log or display the endpoint to troubleshoot failed API calls or unexpected behavior.

Dynamic Configuration: Retrieve the endpoint to adapt scripts based on the current server environment (e.g., switch logic for production vs. staging).

 

How to Use the GetEndpoint Command?

 

Call the command with an optional variable to store the current endpoint URL; if omitted, the URL is pushed to the Top of Stack (TOS).

The endpoint URL is used by AIX.Ask and AIX.AskVision via HTP_CallGrokAPI to direct API requests. No additional API costs are incurred for retrieval as of March 18, 2025, making it a lightweight operation for monitoring.

 

Example Usage

 

AIX.SetEndpoint|https://staging.xai.com/v1/chat/completions

AIX.GetEndpoint|$$URL

DBP.Current Endpoint: $$URL ; Displays 'https://staging.xai.com/v1/chat/completions'

 

Sets a staging endpoint and retrieves it into $$URL for display.

 

AIX.GetEndpoint

POP.$$ENDP

DBP.Stack Endpoint: $$ENDP ; Retrieves from stack

ENR.

 

Retrieves the current endpoint using the stack into $$ENDP.

 

Illustration

 

┌──────────────┬────────────────────┐

│ Action       │ Retrieved Value    │

├──────────────┼────────────────────┤

│ After Set    │ Custom URL         │

├──────────────┼────────────────────┤

│ Default      │ Default URL        │

└──────────────┴────────────────────┘

Illustration of endpoint retrieval based on prior settings.

 

Syntax

 

AIX.GetEndpoint[|P1]

AIX.Get_Endpoint[|P1]

 

Parameter Explanation

 

P1 - (Optional) The variable where the current endpoint URL (STRING) is stored. If omitted, the value is placed on the Top of Stack (TOS).

 

Example

 

AIX.SetEndpoint|https://backup.xai.com/v1/chat/completions

AIX.GetEndpoint|$$EP

IF ($$EP = "https://backup.xai.com/v1/chat/completions")

 DBP.Using backup endpoint

ENDIF

ENR.

 

Sets a backup endpoint and verifies it with a conditional check.

 

Remarks

 

- The default endpoint is set at start and can be overridden by AIX.SetEndpoint.

- The endpoint must match the Grok API schema to ensure successful requests; mismatches may require ERR.Handle configuration.

 

Limitations

 

- Accepts zero or one parameter; extra parameters may cause an error depending on the interpreter.

- Only retrieves the current endpoint; does not provide a history of previous settings.

 

See also:

 

AIX.Set_Endpoint

AIX.Ask

AIX.Ask_Vision