Voice Agents

Voice Agents API

The Voice Agents API enables you to create and manage voice-enabled AI agents with text-to-speech (TTS) and speech-to-text (STT) capabilities. Voice agents can handle real-time voice conversations using ElevenLabs voices and LiveKit for WebRTC communication.

Base URL

https://api.aloochat.ai/api/public

Authentication

All requests require an API key in the x-api-key header:

x-api-key: your_api_key_here

Endpoints Overview

MethodEndpointDescription
GET/voice-agentsList all voice agents
POST/voice-agentsCreate a new voice agent
PUT/voice-agents/{id}Update a voice agent
DELETE/voice-agents/{id}Delete a voice agent
GET/voice-agents/arabicGet curated Arabic voices
GET/voice-agents/englishGet curated English voices
GET/voice-agents/multilingualGet multilingual voices
POST/voice-agents/elevenlabs/voices/{voiceId}/ttsText-to-speech
POST/voice-agents/sttSpeech-to-text

Voice Agent Properties

PropertyTypeDescription
idstringUnique voice agent identifier (UUID)
namestringVoice agent name
descriptionstringDescription of the voice agent
voice_idstringElevenLabs voice ID
voice_namestringHuman-readable voice name
languagestringPrimary language code
model_idstringElevenLabs model ID (default: “eleven_turbo_v2_5”)
activebooleanWhether the voice agent is active
temperaturenumberResponse creativity (0.0-1.0)
voice_speednumberSpeech speed percentage (100 = normal)
voice_stabilitynumberVoice stability (0.0-1.0)
voice_similarity_boostnumberVoice similarity boost (0.0-1.0)
voice_stylenumberStyle exaggeration (0.0-1.0)
output_formatstringAudio format (e.g., “mp3_44100_128”)
company_idstringAssociated company ID
main_agent_idstringLinked main agent ID

List Voice Agents

Retrieve all voice agents for your company.

Endpoint: GET /voice-agents

curl -X GET "https://api.aloochat.ai/api/public/voice-agents" \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json"

Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Sarah - Customer Support",
    "description": "Friendly female voice for customer support",
    "voice_id": "EXAVITQu4vr4xnSDxMaL",
    "voice_name": "Sarah",
    "language": "en",
    "model_id": "eleven_turbo_v2_5",
    "active": true,
    "temperature": 0.7,
    "voice_speed": 100.0,
    "voice_stability": 0.5,
    "voice_similarity_boost": 0.5,
    "voice_style": 0.0,
    "output_format": "mp3_44100_128",
    "company_id": "123e4567-e89b-12d3-a456-426614174000",
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
]

Create Voice Agent

Create a new voice agent with custom voice settings.

Endpoint: POST /voice-agents

Request Body

FieldTypeRequiredDescription
namestringYesVoice agent name
voice_idstringYesElevenLabs voice ID
descriptionstringNoDescription
voice_namestringNoHuman-readable voice name
languagestringNoLanguage code (e.g., “en”, “ar”)
model_idstringNoElevenLabs model ID
activebooleanNoWhether active (default: false)
temperaturenumberNoCreativity level (default: 0.7)
voice_speednumberNoSpeed percentage (default: 100)
voice_stabilitynumberNoStability (default: 0.5)
voice_similarity_boostnumberNoSimilarity boost (default: 0.5)
voice_stylenumberNoStyle exaggeration (default: 0.0)
main_agent_idstringNoLink to main agent
curl -X POST "https://api.aloochat.ai/api/public/voice-agents" \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Customer Support Voice",
    "voice_id": "EXAVITQu4vr4xnSDxMaL",
    "voice_name": "Sarah",
    "description": "Friendly female voice for customer support",
    "language": "en",
    "model_id": "eleven_turbo_v2_5",
    "active": true,
    "temperature": 0.7,
    "voice_speed": 100.0,
    "voice_stability": 0.5,
    "voice_similarity_boost": 0.75,
    "voice_style": 0.0,
    "output_format": "mp3_44100_128"
  }'

Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Customer Support Voice",
  "description": "Friendly female voice for customer support",
  "voice_id": "EXAVITQu4vr4xnSDxMaL",
  "voice_name": "Sarah",
  "language": "en",
  "model_id": "eleven_turbo_v2_5",
  "active": true,
  "temperature": 0.7,
  "voice_speed": 100.0,
  "voice_stability": 0.5,
  "voice_similarity_boost": 0.75,
  "voice_style": 0.0,
  "output_format": "mp3_44100_128",
  "company_id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z"
}

Update Voice Agent

Update an existing voice agent’s settings.

Endpoint: PUT /voice-agents/{id}

curl -X PUT "https://api.aloochat.ai/api/public/voice-agents/550e8400-e29b-41d4-a716-446655440000" \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Voice Agent",
    "voice_stability": 0.7,
    "voice_speed": 110.0,
    "active": true
  }'

Delete Voice Agent

Delete a voice agent.

Endpoint: DELETE /voice-agents/{id}

curl -X DELETE "https://api.aloochat.ai/api/public/voice-agents/550e8400-e29b-41d4-a716-446655440000" \
  -H "x-api-key: your_api_key_here"

Get Available Voices

Arabic Voices

Get curated Arabic voices from ElevenLabs.

Endpoint: GET /voice-agents/arabic

Query Parameters:

ParameterTypeDescription
genderstringFilter by gender (“male” or “female”)
curl -X GET "https://api.aloochat.ai/api/public/voice-agents/arabic?gender=female" \
  -H "x-api-key: your_api_key_here"

English Voices

Get curated English voices from ElevenLabs.

Endpoint: GET /voice-agents/english

Query Parameters:

ParameterTypeDescription
genderstringFilter by gender
categorystringFilter by category
accentstringFilter by accent
featured_onlybooleanOnly featured voices
max_voicesintegerMaximum voices to return (default: 100)

Multilingual Voices

Get voices that support multiple languages (Arabic and English).

Endpoint: GET /voice-agents/multilingual


Text-to-Speech (TTS)

Convert text to speech using a specific voice.

Endpoint: POST /voice-agents/elevenlabs/voices/{voiceId}/tts

Request Body

FieldTypeRequiredDescription
textstringYesText to convert to speech
model_idstringNoElevenLabs model ID
language_codestringNoLanguage code (e.g., “en”, “ar”)
voice_speednumberNoSpeed percentage
voice_stabilitynumberNoStability (0.0-1.0)
voice_similarity_boostnumberNoSimilarity boost (0.0-1.0)
voice_stylenumberNoStyle exaggeration (0.0-1.0)
output_formatstringNoAudio format
curl -X POST "https://api.aloochat.ai/api/public/voice-agents/elevenlabs/voices/EXAVITQu4vr4xnSDxMaL/tts" \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello! Welcome to our customer support. How can I help you today?",
    "model_id": "eleven_turbo_v2_5",
    "language_code": "en",
    "voice_stability": 0.5,
    "voice_similarity_boost": 0.75
  }' \
  --output audio.mp3

Speech-to-Text (STT)

Convert speech audio to text.

Endpoint: POST /voice-agents/stt

Content-Type: multipart/form-data

Request Body

FieldTypeRequiredDescription
filefileYesAudio file to transcribe
curl -X POST "https://api.aloochat.ai/api/public/voice-agents/stt" \
  -H "x-api-key: your_api_key_here" \
  -F "file=@audio.mp3"

Response

{
  "text": "Hello, I need help with my order."
}

Error Responses

Status CodeDescription
400Bad Request - Invalid input data
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Voice agent not found
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error Response Format

{
  "detail": "Voice agent not found"
}