> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # Mastra.getGateway() 按登錄鍵(將閘道加入 Mastra 時所使用的鍵)擷取閘道。 ## 使用範例 ```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** (`MastraModelGateway`): 閘道實例 ## 擲回錯誤 如果找不到使用指定鍵的閘道,則會擲回錯誤。 ## 相關內容 - [Mastra.getGatewayById()](https://mastra.zisheng.pro/zh-HK/reference/core/getGatewayById):按 ID 取得閘道 - [Mastra.listGateways()](https://mastra.zisheng.pro/zh-HK/reference/core/listGateways):列出所有閘道 - [Mastra.addGateway()](https://mastra.zisheng.pro/zh-HK/reference/core/addGateway):加入閘道 - [MastraModelGateway](https://mastra.zisheng.pro/zh-HK/reference/core/mastra-model-gateway):閘道基礎類別 - [自訂閘道指南](https://mastra.zisheng.pro/zh-HK/models/gateways/custom-gateways):建立自訂閘道