Mastra.getGateway()
Retrieves a gateway by its registration key (the key used when adding the gateway to Mastra).
Usage exampleUsage 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'
ParametersParameters的直接链接
key:
string
The registration key of the gateway
ReturnsReturns的直接链接
gateway:
MastraModelGateway
The gateway instance
ThrowsThrows的直接链接
Throws an error if no gateway is found with the specified key.
RelatedRelated的直接链接
- 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