> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # voice.addTools() `addTools()` メソッドは、リアルタイムの対話中にモデルが呼び出せる Tool(関数)を Voice Provider に設定します。Voice アシスタントは、情報の検索や計算、外部システムとの連携にこれらの Tool を使用できます。 ## 使用例 ```typescript import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime' import { createTool } from '@mastra/core/tools' import { z } from 'zod' // Define tools const weatherTool = createTool({ id: 'getWeather', description: 'Get the current weather for a location', inputSchema: z.object({ location: z.string().describe('The city and state, e.g. San Francisco, CA'), }), outputSchema: z.object({ message: z.string(), }), execute: async inputData => { // Fetch weather data from an API const response = await fetch( `https://api.weather.com?location=${encodeURIComponent(inputData.location)}`, ) const data = await response.json() return { message: `The current temperature in ${inputData.location} is ${data.temperature}°F with ${data.conditions}.`, } }, }) // Initialize a real-time voice provider const voice = new OpenAIRealtimeVoice({ realtimeConfig: { model: 'gpt-5.1-realtime', apiKey: process.env.OPENAI_API_KEY, }, }) // Add tools to the voice provider voice.addTools({ getWeather: weatherTool, }) // Connect to the real-time service await voice.connect() ``` ## パラメーター **tools** (`ToolsInput`): Voice モデルが呼び出せる Tool 定義を含むオブジェクト ## 戻り値 このメソッドは値を返しません。 ## 注意事項 - Tool は、名前、説明、入力スキーマ、実行関数を含む Mastra Tool 形式に従う必要があります - 主に、関数呼び出しをサポートするリアルタイム Voice Provider で使用します - Tool をサポートしない Voice Provider で呼び出すと、警告を記録して何も実行しません - このメソッドで追加した Tool は、通常、関連付けられた Agent の Tool と組み合わされます - 最良の結果を得るには、会話を開始する前(`connect()` の呼び出し前)に Tool を追加してください - モデルが Tool の使用を決定すると、Voice Provider が Tool ハンドラーの呼び出しを自動処理します - `addTools()` を複数回呼び出した場合、既存の Tool を置換するか統合するかは Provider の実装によって異なります