> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # Mastra.getGateway() 按注册键(将 gateway 添加到 Mastra 时使用的键)获取 gateway。 ## 使用示例 ```typescript 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' ``` ## 参数 **key** (`string`): gateway 的注册键 ## 返回值 **gateway** (`MastraModelGateway`): 该 gateway 实例 ## 抛出错误 如果找不到具有指定键的 gateway,则抛出错误。 ## 相关内容 - [Mastra.getGatewayById()](https://mastra.zisheng.pro/reference/core/getGatewayById): 按 ID 获取 gateway - [Mastra.listGateways()](https://mastra.zisheng.pro/reference/core/listGateways): 列出所有 gateway - [Mastra.addGateway()](https://mastra.zisheng.pro/reference/core/addGateway): 添加 gateway - [MastraModelGateway](https://mastra.zisheng.pro/reference/core/mastra-model-gateway): Gateway 基类 - [自定义 Gateway 指南](https://mastra.zisheng.pro/models/gateways/custom-gateways): 创建自定义 gateway