Mastra.getGateway()
Retrieves a gateway by its registration key (the key used when adding the gateway to Mastra).
Usage example
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() - Get gateway by ID
- Mastra.listGateways() - List all gateways
- Mastra.addGateway() - Add a gateway
- MastraModelGateway - Gateway base class
- Custom Gateways Guide - Creating custom gateways