Qper
12/12/2025, 8:24 PMQper
12/12/2025, 8:25 PMChiranjeet Mishra
12/26/2025, 4:54 PMpreviousChatId from the last response to maintain context and avoid extra charges. This way, you can keep the conversation within the same chat session.
Here's a code snippet for your API request using the `previousChatId`:
js
await fetch('https://api.vapi.ai/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
assistantId: 'your-assistant-id',
input: 'Your message here',
previousChatId: 'last-chat-id'
})
});
This approach will help decrease costs by linking all messages to the initial chat session.
For further details, you can refer to the [Vapi session management documentation](https://docs.vapi.ai/chat/session-management).