Skip to main content

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.

On this page