You can update a VAPI assistant's system prompt using the API. Here are several ways to do it:
// Update just the system prompt
const response = await fetch('/api/vapi/assistants/YOUR_ASSISTANT_ID', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: {
systemPrompt: "Your new system prompt here"
}
})
});
const updatedAssistant = await response.json();// Update system prompt along with other properties
const response = await fetch('/api/vapi/assistants/YOUR_ASSISTANT_ID', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: "Updated Assistant Name",
firstMessage: "New welcome message",
model: {
systemPrompt: "Updated system prompt with new instructions",
temperature: 0.8,
maxTokens: 200
},
voice: {
provider: "openai",
model: "tts-1",
voiceId: "nova" // Change voice to nova
}
})
});# Using curl to update directly
curl -X PATCH https://api.vapi.ai/assistant/YOUR_ASSISTANT_ID \
-H "Authorization: Bearer YOUR_VAPI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": {
"systemPrompt": "Your new system prompt"
}
}'// Include conversation history in system prompt
const conversationHistory = await fetchUserConversations(userId);
const contextualPrompt = `
${baseSystemPrompt}
PREVIOUS CONVERSATIONS:
${conversationHistory}
Remember to reference past interactions when relevant.
`;
const response = await fetch('/api/vapi/assistants/YOUR_ASSISTANT_ID', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: {
systemPrompt: contextualPrompt
}
})
});You can update any of these fields on a VAPI assistant:
{
// Basic Info
name: string,
firstMessage: string,
// Model Configuration
model: {
provider: "openai" | "anthropic" | "groq" | "deepgram",
model: string, // e.g., "gpt-4", "claude-3-5-sonnet"
systemPrompt: string,
temperature: number, // 0-2
maxTokens: number,
emotionRecognitionEnabled: boolean,
numFastTurns: number
},
// Voice Configuration
voice: {
provider: "openai" | "elevenlabs" | "deepgram",
model: string,
voiceId: string,
speed: number,
stability: number, // For ElevenLabs
similarityBoost: number // For ElevenLabs
},
// Conversation Settings
silenceTimeoutSeconds: number,
responseDelaySeconds: number,
llmRequestDelaySeconds: number,
// Advanced Features
functions: Array,
serverUrl: string,
serverUrlSecret: string,
// Analysis
analysisPlan: {
summaryPrompt: string,
structuredDataSchema: object
}
}When you update an agent in your dashboard, it automatically updates the VAPI assistant if the system prompt changes:
// This happens automatically in /api/agents/[id]/route.ts
const updateAgent = async (agentId, updates) => {
// Update in database
const response = await fetch(`/api/agents/${agentId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
system_prompt: "New enhanced prompt",
// ... other updates
})
});
// VAPI assistant is automatically updated if system_prompt changed
};- Get current assistant configuration:
const response = await fetch('/api/vapi/assistants/YOUR_ASSISTANT_ID');
const assistant = await response.json();
console.log('Current prompt:', assistant.model.systemPrompt);- Update the system prompt:
await fetch('/api/vapi/assistants/YOUR_ASSISTANT_ID', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: {
systemPrompt: "Updated prompt with new capabilities"
}
})
});- Verify the update:
const updated = await fetch('/api/vapi/assistants/YOUR_ASSISTANT_ID');
const result = await updated.json();
console.log('Updated prompt:', result.model.systemPrompt);- Updates are immediate and affect ongoing calls
- Always test prompt changes before deploying
- Keep prompts concise for better performance
- Include clear instructions for function calling
- Consider token limits when adding context