跳到主要内容

Mastra.listGateways()

返回以注册键为索引的所有已注册 gateway 的记录。

使用示例
使用示例的直接链接

import { Mastra } from '@mastra/core'

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

const gateways = mastra.listGateways()
console.log(Object.keys(gateways)) // ['myGateway', 'anotherGateway']

// Iterate over all gateways
for (const [key, gateway] of Object.entries(gateways)) {
console.log(`${key}: ${gateway.name}`)
}

参数
参数的直接链接

无。

返回值
返回值的直接链接

gateways:

Record<string, MastraModelGateway>
以注册键为索引的 gateway 实例记录