Base URL
http://localhost:8003/api/v1
All endpoints require the GROQ_API_KEY environment variable to be set for Whisper and LLM access.
Endpoints
/api/v1/healthHealth check — returns service status
/api/v1/transcribeTranscribe an audio file using Groq Whisper
/api/v1/transcriptionsList transcription history with pagination
/api/v1/analyticsAggregated call analytics and statistics
/api/v1/voice/chatVoice chat agent — transcribe audio and get an LLM response
POST /api/v1/transcribe
Transcribe an audio file. Accepts multipart form data with the audio file and optional query parameters.
Request: multipart/form-data
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
file | body | file | Yes | Audio file (flac, mp3, mp4, wav, webm, ogg, etc.) |
language | query | string | No | Language hint — auto, ar, en. Default: auto |
model | query | string | No | Whisper model. Default: whisper-large-v3 |
curl -X POST http://localhost:8003/api/v1/transcribe \
-F "file=@recording.mp3" \
-G -d "language=ar"
Response:
{
"id": "tx-001",
"text": "مرحبا، أريد الاستفسار عن خدمات الحكومة",
"language": "ar",
"duration": 4.5,
"segments": [
{"start": 0.0, "end": 2.1, "text": "مرحبا"},
{"start": 2.1, "end": 4.5, "text": "أريد الاستفسار عن خدمات الحكومة"}
],
"model": "whisper-large-v3",
"created_at": "2024-01-15T10:30:00Z"
}
GET /api/v1/transcriptions
List all transcriptions with pagination.
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
page | query | integer | No | Page number. Default: 1 |
page_size | query | integer | No | Results per page. Default: 20 |
curl http://localhost:8003/api/v1/transcriptions?page=1&page_size=10
GET /api/v1/analytics
Returns aggregated statistics across all transcriptions — total count, language distribution, average duration, and processing metrics.
curl http://localhost:8003/api/v1/analytics
POST /api/v1/voice/chat
Send audio and receive a transcription plus an LLM-generated response in a single call. Supports multi-turn conversations via conversation_id.
Request: multipart/form-data
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
file | body | file | Yes | Audio file |
language | query | string | No | Language hint. Default: auto |
system_prompt | query | string | No | Custom system prompt for the LLM |
conversation_id | query | string | No | Continue an existing conversation |
curl -X POST http://localhost:8003/api/v1/voice/chat \
-F "file=@question.mp3" \
-G -d "language=ar" \
-G -d "conversation_id=conv-001"
Response:
{
"transcription": "What services does the government offer?",
"response": "The government offers a wide range of services...",
"language": "en",
"conversation_id": "conv-001",
"duration": 3.2
}
WebSocket: /api/v1/transcribe/stream
Real-time streaming transcription over WebSocket. Send raw audio bytes and receive JSON transcription results.
Authentication
WebSocket connections require a valid JWT token passed as a query parameter: ?token=eyJ...
Connect:
const ws = new WebSocket("ws://localhost:8003/api/v1/transcribe/stream?token=JWT_TOKEN");
Send: Raw audio bytes (binary frames)
Receive: JSON messages
{"status": "processing"}
{
"status": "completed",
"text": "السلام عليكم",
"language": "ar",
"duration": 2.1,
"segments": [
{"start": 0.0, "end": 2.1, "text": "السلام عليكم"}
]
}
Environment Variables
| Variable | Default | Description |
|---|---|---|
GROQ_API_KEY | — | Groq API key (required) |
DATABASE_URL | sqlite+aiosqlite:///./anar_voice.db | Database connection string |
STT_MODEL | whisper-large-v3 | Primary Whisper model |
STT_MODEL_TURBO | whisper-large-v3-turbo | Fast Whisper model |
LLM_MODEL | llama-3.3-70b-versatile | General LLM for voice agents |
LLM_ARABIC_MODEL | allam-2-7b | Arabic-specific LLM |
MAX_FILE_SIZE_MB | 25 | Maximum upload file size |
DEBUG | false | Enable debug logging |
MCP Server
Voice exposes a Model Context Protocol server at /mcp, enabling integration with AI assistants and development tools that support the MCP specification.