Skip to main content
A
Docs

API Reference

Complete API reference for Anar Voice speech intelligence endpoints.

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

GET
/api/v1/health

Health check — returns service status

POST
/api/v1/transcribe

Transcribe an audio file using Groq Whisper

GET
/api/v1/transcriptions

List transcription history with pagination

GET
/api/v1/analytics

Aggregated call analytics and statistics

POST
/api/v1/voice/chat

Voice 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

ParameterLocationTypeRequiredDescription
filebodyfileYesAudio file (flac, mp3, mp4, wav, webm, ogg, etc.)
languagequerystringNoLanguage hint — auto, ar, en. Default: auto
modelquerystringNoWhisper 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.

ParameterLocationTypeRequiredDescription
pagequeryintegerNoPage number. Default: 1
page_sizequeryintegerNoResults 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

ParameterLocationTypeRequiredDescription
filebodyfileYesAudio file
languagequerystringNoLanguage hint. Default: auto
system_promptquerystringNoCustom system prompt for the LLM
conversation_idquerystringNoContinue 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

VariableDefaultDescription
GROQ_API_KEYGroq API key (required)
DATABASE_URLsqlite+aiosqlite:///./anar_voice.dbDatabase connection string
STT_MODELwhisper-large-v3Primary Whisper model
STT_MODEL_TURBOwhisper-large-v3-turboFast Whisper model
LLM_MODELllama-3.3-70b-versatileGeneral LLM for voice agents
LLM_ARABIC_MODELallam-2-7bArabic-specific LLM
MAX_FILE_SIZE_MB25Maximum upload file size
DEBUGfalseEnable 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.