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
相关Direct link to 相关
🌐 Related
- Mastra.getGateway() - 通过注册密钥获取网关
- Mastra.getGatewayById() - 通过ID获取网关
- Mastra.addGateway() - 添加网关
- MastraModelGateway - 网关基类
- 自定义网关指南 - 创建自定义网关