docs/src/content/en/reference/voice/voice.addInstructions.mdx
The addInstructions() method equips a voice provider with instructions that guide the model's behavior during real-time interactions. This is particularly useful for real-time voice providers that maintain context across a conversation.
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({
name: 'Customer Support Agent',
instructions: 'You are a helpful customer support agent for a software company.',
model: 'openai/gpt-5.4',
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()
<PropertiesTable content={[ { name: 'instructions', type: 'string', description: "Instructions to guide the voice model's behavior", isOptional: false, }, ]} />
This method doesn't return a value.
connect())addInstructions() may either replace or append to existing instructions, depending on the provider implementation