|
<< 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 |
MiniRobotLanguage (MRL)
AIX.SetEndpoint
Set the API Endpoint URL
Intention
SetEndpoint Command: Configure the API Endpoint
The SetEndpoint command allows users to specify the URL of the API endpoint used by the AIX framework to communicate with the Grok API.
This is essential for directing API requests to the correct server, such as production, staging, or custom endpoints, and supports flexibility in deployment scenarios.
It is part of the AIX - Grok / X - API suite.
The SetEndpoint command updates the AIX_Endpoint global variable with a new API endpoint URL, which is then used by functions like HTP_CallGrokAPI to send requests to the Grok API.
The endpoint URL must be a valid string (e.g., "https://api.xai.com/v1/chat/completions"), and if invalid or omitted, it reverts to the default endpoint set during Initiallize (e.g., the xAI production endpoint). This command enables customization for testing, local development, or third-party API integrations.
Setting the API endpoint is crucial for:
•Customization: Use a specific endpoint for testing or integration with custom servers.
•Development: Switch between production, staging, or local environments during development cycles.
•Resilience: Redirect requests to a backup or alternative endpoint in case of primary server issues.
Provide an optional string parameter specifying the new endpoint URL.
The URL is validated internally; if invalid (e.g., malformed or empty), the command reverts to the default endpoint. This setting affects all subsequent API calls made via AIX.Ask or AIX.AskVision through HTP_CallGrokAPI. No additional API costs are incurred for setting the endpoint as of March 18, 2025, though invalid endpoints may lead to failed requests.
Example Usage
AIX.SetEndpoint|https://staging.xai.com/v1/chat/completions
AIX.Ask|What’s the weather?|$$WEA
DBP.Weather (staging): $$WEA
Sets the endpoint to a staging server and queries the weather.
AIX.SetEndpoint|
AIX.GetEndpoint|$$END
DBP.Default Endpoint: $$END ; Reverts to default (e.g., production endpoint)
ENR.
Omitting a valid URL reverts to the default endpoint, which is then retrieved.
Illustration
┌──────────────┬────────────────────┐
│ Endpoint Set │ Result │
├──────────────┼────────────────────┤
│ Valid URL │ Uses new endpoint │
├──────────────┼────────────────────┤
│ Invalid/Empty│ Reverts to default │
└──────────────┴────────────────────┘
Illustration of endpoint setting behavior.
Syntax
AIX.SetEndpoint[|P1]
AIX.Set_Endpoint[|P1]
Parameter Explanation
P1 - (Optional) A string representing the API endpoint URL (e.g., "https://api.xai.com/v1/chat/completions"). If omitted or invalid, reverts to the default endpoint.
Example
AIX.SetEndpoint|https://localhost:8080/grok/api
AIX.Ask|Hello|$$HEL
DBP.Local Response: $$HEL
AIX.SetEndpoint|invalid-url
DBP.Endpoint reverted to default
ENR.
Remarks
- The endpoint is included in the API request via HTP_CallGrokAPI and must support the Grok API schema.
- Changes take effect on the next API call; existing connections or responses are unaffected.
Limitations
- Accepts zero or one parameter; extra parameters may cause an error depending on the interpreter.
- Invalid URLs trigger a revert to the default endpoint without explicit error notification unless handled by ERR.Handle.
See also:
• AIX.Ask