Flush syntax

Control voice transmission timing for responsive conversations

Overview

The flush syntax is a VAPI audio control token that forces immediate transmission of LLM output to voice providers, eliminating buffering delays for real-time voice interactions.

When to use flush syntax:

  • Acknowledge user requests immediately during processing
  • Provide feedback during long-running tool executions
  • Create natural conversation pauses
  • Support custom LLM integrations with processing delays

Use flush strategically—overuse can cause audio fragmentation and degrade conversation quality.

How it works

The flush syntax bypasses normal buffering to provide immediate audio feedback:

  1. Detection: VAPI scans LLM output for flush syntax using regex pattern
  2. Split: Text is divided at the flush position
  3. Immediate Send: Content before flush is sent instantly to voice provider
  4. Continue: Remaining text follows normal buffering
1const { sendToTTS, flush, remainingBuffer } = ttsBuffer(buffer, voice);
2if (sendToTTS.length > 0) {
3 pushBuffer(sendToTTS, flush); // flush=true triggers immediate send
4 buffer = remainingBuffer;
5}

Syntax formats

VAPI supports three flush formats with case-insensitive matching:

Self-closing (Recommended)
1<flush />
2``` ```html title="Opening tag"
3<flush>``` ```html title="Closing tag"</flush>

All formats use regex pattern /<\s*flush\s*\/?>|<\s*\/\s*flush\s*>/i allowing whitespace variations.

Configuration requirements

Flush syntax requires proper voice configuration:

1{
2 "voice": {
3 "chunkPlan": {
4 "enabled": true // Required for flush to work
5 }
6 }
7}

Flush will NOT work when chunkPlan.enabled: false. The tags will appear in voice output instead of being processed.

Usage examples

Basic acknowledgment

1"I'm processing your request... <flush /> Let me check that for you.";

Tool processing feedback

1"Looking up that information... <flush /> This may take a moment.";

Conversation flow

1"That's a great question. <flush /> Based on the data I have...";

Custom LLM integration

1"Here's your answer: 42. <flush /> Would you like an explanation?";

Best practices

When to use flush

Acknowledge requests

Immediately confirm you’ve received and understood the user’s request

Long operations

Provide feedback during tool calls or processing that takes time

Natural pauses

Create conversation breaks at logical points

Custom delays

Support external LLM integrations with processing delays

When to avoid flush

  • Every response - Causes audio fragmentation
  • Mid-sentence - Breaks natural speech flow
  • Short responses - Normal buffering is sufficient
  • Multiple per response - Can create choppy audio

Implementation guidelines

  1. Place at natural boundaries - Use between complete thoughts or sentences
  2. Test with your voice provider - Effectiveness varies by provider
  3. Monitor conversation quality - Ensure audio remains smooth and natural
  4. Document usage - Include in code comments for team understanding

Advanced usage

Dynamic insertion

1const acknowledgment = "I understand your request";
2const detailedResponse = await processRequest(userInput);
3const responseWithFlush = `${acknowledgment} <flush /> ${detailedResponse}`;

System prompt integration

1const systemPrompt = `When providing lengthy responses, use <flush /> after acknowledging the user's request to provide immediate feedback.`;

Nested handling

1"Starting process... <flush> Step 1 complete </flush> Moving to step 2...";

Troubleshooting

Cause: chunkPlan.enabled is set to false or missing Solution: - Verify chunkPlan.enabled: true in voice configuration - Check assistant configuration in dashboard or API calls - Test with a minimal configuration to isolate the issue

Cause: Malformed flush syntax or typos Solution: - Use exact formats: <flush /> , <flush>, or </flush> - Avoid extra parameters or attributes - Check for typos in tag spelling

Cause: Overuse of flush syntax Solution:

  • Reduce flush frequency in responses
  • Place only at sentence boundaries
  • Test with real users to validate experience

Technical considerations

Provider compatibility

  • Effectiveness varies by voice provider
  • Test thoroughly with your chosen provider
  • Monitor performance impact on response times

Cost implications

  • Increased API calls to voice provider
  • Higher usage on usage-based pricing
  • Monitor billing if using flush frequently

VAPI-only feature

  • Platform exclusive - not available on other voice platforms
  • Configuration dependent - requires chunking enabled
  • Version specific - ensure using compatible VAPI version

Next steps

Now that you understand flush syntax: