Availability
Gateway Services are available to plugins that run on an Edge Gateway.
Gateway Services read the local database of the Edge Gateway through
ctx.Services.Gateway(). They are available when ctx.Runtime == plugin_sdk.RuntimeGateway. Each call returns interface{}. Type assert the result to the response type in the microgateway_management package (gwmgmt in the examples). To send data from an edge plugin to AI Studio, refer to Edge-to-Control Communication.
Get App
*gwmgmt.GetAppResponse.
Example:
List Apps
isActive is a *bool. Pass nil to list active and inactive Apps. Type assert to *gwmgmt.ListAppsResponse.
Get LLM
*gwmgmt.GetLLMResponse.
List LLMs
vendor and a nil isActive to list all LLMs. Type assert to *gwmgmt.ListLLMsResponse.
Get Budget Status
llmID is an optional *uint32. Set it to get the budget of one LLM, or pass nil. Type assert to *gwmgmt.GetBudgetStatusResponse.
Example:
Expandable
Get Model Price
*gwmgmt.GetModelPriceResponse.
List Model Prices
vendor to list all prices. Type assert to *gwmgmt.ListModelPricesResponse.
Validate Credential
*gwmgmt.ValidateCredentialResponse. The response also gives the AppId of the credential.
Example:
Store App
From v2.1.0, gateway plugins can write an App into the local Edge Gateway database. Auth plugins use this to provision Apps without waiting for the next configuration sync. For example, the OAuth2 client-credentials plugin stores an App that AI Studio created for a new client. Requires:apps.write scope. Gateway only. The stored App gets the LLMs, tools, and data sources that the plugin sets, so grant apps.write only to plugins that you trust. The Studio runtime returns an error, so multi-runtime plugins must check ctx.Runtime.
StoreApp creates the App if it does not exist, and updates it if it exists. On update, it replaces the tool and data source associations in one transaction.