Skip to main content

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

Returns the App configuration. Type assert to *gwmgmt.GetAppResponse. Example:

List Apps

Returns the Apps in the local database. isActive is a *bool. Pass nil to list active and inactive Apps. Type assert to *gwmgmt.ListAppsResponse.

Get LLM

Returns the LLM configuration. Type assert to *gwmgmt.GetLLMResponse.

List LLMs

Returns the LLMs in the local database. Pass an empty vendor and a nil isActive to list all LLMs. Type assert to *gwmgmt.ListLLMsResponse.

Get Budget Status

Returns the current budget status of an App. 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

Returns the price of one model. Type assert to *gwmgmt.GetModelPriceResponse.

List Model Prices

Returns the model prices in the local database. Pass an empty vendor to list all prices. Type assert to *gwmgmt.ListModelPricesResponse.

Validate Credential

Validates a credential secret. Type assert to *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.