Add voice to chat agent
Overview
Voice Engine lets you easily add full voice capabilities to any chat agent, even those built outside the ElevenAgents platform. The voice engine contains everything needed to add voice conversations to your agent including turn taking, interruption detection and optimizations for the userโs language.
To use your custom agent, it must expose text based APIs that align with one of the following OpenAI-compatible request/response structures:
- Chat Completions API (
/v1/chat/completions) - Responses API (
/v1/responses)
The Responses API is OpenAIโs newer API format that supports additional features. Both API formats are fully supported for custom LLM integration.
Youโll learn how to:
- Store your OpenAI API key in ElevenLabs
- Host a server that replicates OpenAIโs Chat Completions or Responses endpoint
- Direct ElevenLabs to your custom endpoint
- Pass extra parameters to your LLM as needed
Configure Voice Engine
How-to guide ยท Assumes you have completed the Agents quickstart.
First step is to create an empty agent to hold the Voice Engine config. Follow the quickstart guide linked above to create an empty agent.
Next, set up a compatible server endpoint using OpenAIโs style. You can implement either the Chat Completions API (/v1/chat/completions) or the Responses API (/v1/responses).
Both endpoints must return responses in SSE (Server-Sent Events) format with Content-Type: text/event-stream.
Chat Completions API
Responses API
The Chat Completions API uses the /v1/chat/completions endpoint.
Each chunk must be formatted as data: {json}\n\n and the stream must end with data: [DONE]\n\n.
Hereโs an example server implementation:
Run the code to start your Voice Engine server.

Setting up a public URL for your server
To make your server accessible, create a public URL using a tunneling tool like ngrok:

Configuring ElevenLabs Voice Engine
Next, update your agent settings in the ElevenLabs dashboard to point to your custom LLM server.

Direct your server URL to ngrok endpoint and set โLimit token usageโ to 5000.
You can now start interacting with your agent with your own Voice Engine server.
Optimizing for slow processing LLMs
If your custom LLM has slow processing times (perhaps due to agentic reasoning or pre-processing requirements) you can improve the conversational flow by implementing buffer words in your streaming responses. This technique helps maintain natural speech prosody while your LLM generates the complete response.
Buffer words
When your LLM needs more time to process the full response, return an initial response ending with "... " (ellipsis followed by a space). This allows the Text to Speech system to maintain natural flow while keeping the conversation feeling dynamic.
This creates natural pauses that flow well into subsequent content that the LLM can reason longer about. The extra space is crucial to ensure that the subsequent content is not appended to the โโฆโ which can lead to audio distortions.
Implementation
Hereโs how to modify your custom LLM server to implement buffer words:
System tools integration
Your custom LLM can trigger system tools to control conversation flow and state. These tools are automatically included in the tools parameter of your chat completion requests when configured in your agent.
How system tools work
- LLM Decision: Your custom LLM decides when to call these tools based on conversation context
- Tool Response: The LLM responds with function calls in standard OpenAI format
- Backend Processing: ElevenLabs processes the tool calls and updates conversation state
For more information on system tools, please refer to the system tools guide.
Available system tools
End call
Purpose: Automatically terminate conversations when appropriate conditions are met.
Trigger conditions: The LLM should call this tool when:
- The main task has been completed and user is satisfied
- The conversation reached natural conclusion with mutual agreement
- The user explicitly indicates they want to end the conversation
Parameters:
reason(string, required): The reason for ending the callmessage(string, optional): A farewell message to send to the user before ending the call
Function call format:
Implementation: Configure as a system tool in your agent settings. The LLM will receive detailed instructions about when to call this function.
Learn more about the end call tool.
Language detection
Purpose: Automatically switch to the userโs detected language during conversations.
Trigger conditions: The LLM should call this tool when:
- User speaks in a different language than the current conversation language
- User explicitly requests to switch languages
- Multi-language support is needed for the conversation
Parameters:
reason(string, required): The reason for the language switchlanguage(string, required): The language code to switch to (must be in supported languages list)
Function call format:
Implementation: Configure supported languages in agent settings and add the language detection system tool. The agent will automatically switch voice and responses to match detected languages.
Learn more about the language detection tool.
Skip turn
Purpose: Allow the agent to pause and wait for user input without speaking.
Trigger conditions: The LLM should call this tool when:
- User indicates they need a moment (โGive me a secondโ, โLet me thinkโ)
- User requests pause in conversation flow
- Agent detects user needs time to process information
Parameters:
reason(string, optional): Free-form reason explaining why the pause is needed
Function call format:
Implementation: No additional configuration needed. The tool simply signals the agent to remain silent until the user speaks again.
Learn more about the skip turn tool.
Example Request with System Tools
When system tools are configured, your custom LLM will receive requests that include the tools in the standard OpenAI format:
Your custom LLM must support function calling to use system tools. Ensure your model can generate proper function call responses in OpenAI format.
Additional Features
Custom LLM Parameters
You may pass additional parameters to your custom LLM implementation.