Flush syntax
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:
- Detection: VAPI scans LLM output for flush syntax using regex pattern
- Split: Text is divided at the flush position
- Immediate Send: Content before flush is sent instantly to voice provider
- Continue: Remaining text follows normal buffering
Syntax formats
VAPI supports three flush formats with case-insensitive matching:
All formats use regex pattern /<\s*flush\s*\/?>|<\s*\/\s*flush\s*>/i
allowing whitespace variations.
Configuration requirements
Flush syntax requires proper voice configuration:
Flush will NOT work when chunkPlan.enabled: false
. The tags will appear in
voice output instead of being processed.
Usage examples
Basic acknowledgment
Tool processing feedback
Conversation flow
Custom LLM integration
Best practices
When to use flush
Immediately confirm you’ve received and understood the user’s request
Provide feedback during tool calls or processing that takes time
Create conversation breaks at logical points
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
- Place at natural boundaries - Use between complete thoughts or sentences
- Test with your voice provider - Effectiveness varies by provider
- Monitor conversation quality - Ensure audio remains smooth and natural
- Document usage - Include in code comments for team understanding
Advanced usage
Dynamic insertion
System prompt integration
Nested handling
Troubleshooting
Flush tags appear in voice output
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
Syntax not recognized
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
Audio sounds choppy or fragmented
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:
- Voice formatting plan: Control voice output formatting and timing
- Background messages: Send messages during conversations
- Custom tools: Build tools that benefit from flush syntax feedback