Skip to main content

Mastra.listGateways()

返回所有已注册网关的记录,并按其注册键进行索引。

🌐 Returns a record of all registered gateways, indexed by their registration keys.

使用示例
Direct link to 使用示例

🌐 Usage example

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}`);
}

参数
Direct link to 参数

🌐 Parameters

无。

🌐 None.

返回
Direct link to 返回

🌐 Returns

gateways:

Record<string, MastraModelGateway>
A record of gateway instances indexed by registration key

🌐 Related