POST /api/voice/token
Get an ElevenLabs ConvAI conversation token for voice interaction. Authentication: RequiredRequest Body
Custom ElevenLabs agent ID (overrides ELEVENLABS_AGENT_ID)
Custom ElevenLabs API key (overrides ELEVENLABS_API_KEY)
Response
Whether voice is available
ElevenLabs conversation token (if allowed)
ElevenLabs agent ID used (if allowed)
Error message if not allowed
Example: Using Default Configuration
Example: Using Custom Agent
Error Response
Errors
400- Invalid request body or ElevenLabs API key not configured500- Failed to create agent or get token from ElevenLabs
Configuration
Voice functionality requires ElevenLabs configuration:Environment Variables
Agent Auto-Creation
IfELEVENLABS_AGENT_ID is not set, the hub will:
- Search for an existing “Hapi Voice Assistant” agent
- If not found, create a new agent automatically
- Cache the agent ID for future requests
- Name: “Hapi Voice Assistant”
- Voice: Professional assistant voice
- Behavior: Help with coding tasks
Custom Agent Configuration
You can use a custom agent by:- Creating an agent in the ElevenLabs dashboard
- Passing
customAgentIdandcustomApiKeyin the request
- Setting
ELEVENLABS_AGENT_IDenvironment variable
Using the Token
Once you have a conversation token, use it with the ElevenLabs ConvAI SDK:Token Lifetime
ElevenLabs conversation tokens are short-lived and should be:- Requested when starting a voice session
- Not cached or stored long-term
- Refreshed if the session expires
Voice Assistant Features
The Hapi Voice Assistant can help with:- Explaining code in your sessions
- Answering questions about your project
- Providing coding guidance
- Reading session summaries aloud
Integration with Sessions
The voice assistant has access to:- Session metadata
- Recent messages
- Project context
- Git status