Skip to main content

Mastra.listGateways()

Returns a record of all registered gateways, indexed by their registration keys.

Usage example

import { Mastra } from '@mastra/core';

const mastra = new Mastra({
gateways: {
myGateway: new MyCustomGateway(),
anotherGateway: new AnotherGateway(),
},
});

const gateways = mastra.listGateways();
console.log(Object.keys(gateways)); // ['myGateway', 'anotherGateway']

// Iterate over all gateways
for (const [key, gateway] of Object.entries(gateways)) {
console.log(`${key}: ${gateway.name}`);
}

Parameters

None.

Returns

gateways:

Record<string, MastraModelGateway>
A record of gateway instances indexed by registration key

On this page