跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Mastra.getGateway()

Retrieves a gateway by its registration key (the key used when adding the gateway to Mastra).

Usage example
Usage example的直接链接

import { Mastra } from '@mastra/core'

const mastra = new Mastra({
gateways: {
myGateway: new MyCustomGateway(),
},
})

const gateway = mastra.getGateway('myGateway')
console.log(gateway.name) // 'My Custom Gateway'

Parameters
Parameters的直接链接

key:

string
The registration key of the gateway

Returns
Returns的直接链接

gateway:

MastraModelGateway
The gateway instance

Throws
Throws的直接链接

Throws an error if no gateway is found with the specified key.

On this page