> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # voice.addInstructions() `addInstructions()` 方法會為語音 Provider 加入指示,以引導模型在即時互動期間的行為。這對能在對話中持續保留脈絡的即時語音 Provider 特別實用。 ## 用法範例 ```typescript import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime' import { Agent } from '@mastra/core/agent' // Initialize a real-time voice provider const voice = new OpenAIRealtimeVoice({ realtimeConfig: { model: 'gpt-5.1-realtime', apiKey: process.env.OPENAI_API_KEY, }, }) // Create an agent with the voice provider const agent = new Agent({ id: 'customer-support-agent', name: 'Customer Support Agent', instructions: 'You are a helpful customer support agent for a software company.', model: 'openai/gpt-5.6-sol', voice, }) // Add additional instructions to the voice provider voice.addInstructions(` When speaking to customers: - Always introduce yourself as the customer support agent - Speak clearly and concisely - Ask clarifying questions when needed - Summarize the conversation at the end `) // Connect to the real-time service await voice.connect() ``` ## 參數 **instructions** (`string`): 用於引導語音模型行為的指示 ## 回傳值 此方法不會回傳值。 ## 注意事項 - 指示內容清楚、具體且與語音互動相關時,效果最佳 - 此方法主要用於會保留對話脈絡的即時語音 Provider - 若對不支援指示的語音 Provider 呼叫此方法,系統會記錄警告且不執行任何操作 - 使用此方法加入的指示,通常會與關聯 Agent 所提供的任何指示合併 - 為獲得最佳結果,請在開始對話前(呼叫 `connect()` 前)加入指示 - 視 Provider 實作而定,多次呼叫 `addInstructions()` 可能會取代現有指示,或附加至現有指示