Mastra.getGatewayById()
一意の ID(Gateway インスタンスの id プロパティ)で Gateway を取得します。登録キーではなく Gateway 固有の識別子で検索する必要がある場合に便利です。
使用例使用例への直接リンク
import { Mastra } from '@mastra/core'
const mastra = new Mastra({
gateways: {
customKey: new MyCustomGateway(), // id = 'my-custom-gateway'
},
})
// Retrieve by ID (not registration key)
const gateway = mastra.getGatewayById('my-custom-gateway')
console.log(gateway.name) // 'My Custom Gateway'
ユースケースユースケースへの直接リンク
- Gateway のバージョン管理: バージョンごとに一意の ID(
'gateway-v1'、'gateway-v2')を使用 - 登録キーが不明な場合の Gateway 検索
- 異なる Mastra インスタンス間での Gateway の識別
パラメーターパラメーターへの直接リンク
id:
string
Gateway の一意の ID(gateway.id プロパティ)
戻り値戻り値への直接リンク
gateway:
MastraModelGateway | undefined
Gateway インスタンス。見つからない場合は undefined
関連項目関連項目への直接リンク
- Mastra.getGateway(): 登録キーで Gateway を取得
- Mastra.listGateways(): すべての Gateway を一覧表示
- Mastra.addGateway(): Gateway を追加
- MastraModelGateway: Gateway の基底クラス
- カスタム Gateway ガイド: カスタム Gateway の作成方法