# Mastra.getGateway() Retrieves a gateway by its registration key (the key used when adding the gateway to Mastra). ## Usage example ```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' ``` ## Parameters **key:** (`string`): The registration key of the gateway ## Returns **gateway:** (`MastraModelGateway`): The gateway instance ## Throws Throws an error if no gateway is found with the specified key. ## Related - [Mastra.getGatewayById()](https://mastra.ai/reference/core/getGatewayById) - Get gateway by ID - [Mastra.listGateways()](https://mastra.ai/reference/core/listGateways) - List all gateways - [Mastra.addGateway()](https://mastra.ai/reference/core/addGateway) - Add a gateway - [MastraModelGateway](https://mastra.ai/reference/core/mastra-model-gateway) - Gateway base class - [Custom Gateways Guide](https://mastra.ai/models/gateways/custom-gateways) - Creating custom gateways