For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
WebsiteStatusSupportDashboard
DocumentationAPI ReferenceMCPSDKsCLI (new)What's New?
DocumentationAPI ReferenceMCPSDKsCLI (new)What's New?
  • Get started
    • Introduction
    • Phone calls
    • Web calls
    • Vapi Guides
    • Composer
    • CLI quickstart
  • Assistants
    • Quickstart
      • Variables
      • Multilingual support
      • Personalization with user information
      • Voice formatting plan
      • Flush syntax
      • Background messages
      • Idle messages
      • Assistant hooks
      • Background speech denoising
      • Pronunciation dictionaries
      • Email address reading
    • Tools
    • Custom keywords
    • Custom voices
    • Custom transcriber
    • Custom TTS
  • Observability
    • Boards
  • Squads
    • Quickstart
    • Overview
    • Handoff tool
    • Passing data between assistants
  • Best practices
    • Prompting guide
    • Debugging voice agents
    • Enterprise environments (DEV/UAT/PROD)
    • IVR navigation
  • Phone numbers
    • Free Vapi number
    • Inbound SMS
    • Phone Number Hooks
  • Calls
    • Call end reasons
    • Troubleshoot call errors
  • Outbound Campaigns
    • Quickstart
    • Overview
  • Chat
    • Quickstart
    • Streaming
    • Non-streaming
    • OpenAI compatibility
    • Session management
    • Variable substitution
    • SMS chat
    • Web widget
    • Webhooks
  • Workflows
    • Quickstart
    • Overview
LogoLogo
WebsiteStatusSupportDashboard
On this page
  • Overview
  • How it works
  • Syntax formats
  • Configuration requirements
  • Usage examples
  • Basic acknowledgment
  • Tool processing feedback
  • Conversation flow
  • Custom LLM integration
  • Best practices
  • When to use flush
  • When to avoid flush
  • Implementation guidelines
  • Advanced usage
  • Dynamic insertion
  • System prompt integration
  • Nested handling
  • Troubleshooting
  • Technical considerations
  • Provider compatibility
  • Cost implications
  • VAPI-only feature
  • Next steps
AssistantsConversation behavior

Flush syntax

Control voice transmission timing for responsive conversations
Was this page helpful?
Edit this page
Previous

Background messages

Silently update chat history with background messages
Next
Built with

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:

1<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

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