> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Mastra.addGateway() Mastra インスタンスに Gateway を動的に追加します。初期化中にも、初期化後にも使用できます。 ## 使用例 ```typescript import { Mastra } from '@mastra/core' const mastra = new Mastra() // Add with explicit key mastra.addGateway(new MyCustomGateway(), 'myGateway') // Add using gateway's ID as the key mastra.addGateway(new MyCustomGateway()) // Stored with key 'my-custom-gateway' (the gateway's id) ``` ## パラメータ **gateway** (`MastraModelGateway`): 追加する Gateway インスタンス **key** (`string`): 任意の登録キー。指定しない場合は gateway.getId() を使用します ## 戻り値 なし。Gateway が内部レジストリに追加されます。 ## 動作 - 同じキーの Gateway がすでに存在する場合、追加はスキップされます - 開発モード(`MASTRA_DEV=true`)では、カスタム Gateway の型生成が自動的に開始されます - Gateway はモデル解決にすぐ使用できるようになります ## 関連項目 - [Mastra.getGateway()](https://mastra.zisheng.pro/ja/reference/core/getGateway): 登録キーで Gateway を取得 - [Mastra.getGatewayById()](https://mastra.zisheng.pro/ja/reference/core/getGatewayById): ID で Gateway を取得 - [Mastra.listGateways()](https://mastra.zisheng.pro/ja/reference/core/listGateways): すべての Gateway を一覧表示 - [MastraModelGateway](https://mastra.zisheng.pro/ja/reference/core/mastra-model-gateway): Gateway の基底クラス - [カスタム Gateway ガイド](https://mastra.zisheng.pro/ja/models/gateways/custom-gateways): カスタム Gateway の作成方法