Resources · Voice API

Voice API Documentation

Production-grade reference for realtime voice execution, streaming events, interrupt flow, headers, and error semantics.

Endpoints

POST /api/v1/voice/chat/meta
POST /api/v1/voice/chat
POST /api/v1/voice/interrupt/{session_id}
WS /api/v1/voice/ws

Required Headers

  • Authorization: Bearer [token] or API key auth
  • Content-Type: application/json
  • X-Scope-Type: personal | workspace
  • X-Workspace-ID: required when scope is workspace

Request Body

{
  "message": "Book a follow-up call tomorrow",
  "session_id": "sess_123",
  "stream": true,
  "voice": {
    "input_format": "wav",
    "output_format": "wav",
    "sample_rate": 16000
  },
  "metadata": {
    "lang": "en",
    "client": "web"
  }
}

Response Body

{
  "success": true,
  "session_id": "sess_123",
  "content": "Sure — I scheduled a follow-up for tomorrow.",
  "provider": "openai",
  "usage": {
    "input_tokens": 210,
    "output_tokens": 96
  },
  "metadata": {
    "latency_ms": 842
  }
}

Streaming Events

  • session.started — voice session initialized
  • stt.partial — partial transcription chunk
  • llm.delta — incremental model text tokens
  • tts.chunk — audio chunk produced
  • session.completed — final response + usage

Interrupt Flow

Interrupt stops in-flight voice generation for a specific session and releases the active execution path safely.

POST /api/v1/voice/interrupt/{session_id}

{
  "reason": "user_barge_in"
}

Audio Formats

  • Recommended input: WAV (PCM16, mono, 16kHz).
  • Non-WAV input can be converted before STT.
  • Output format depends on provider and runtime settings.
  • Large payloads may return 413.

Metadata Headers

X-Trace-IDX-Session-IDX-STT-Time-MSX-LLM-Time-MSX-TTS-Time-MS

Error Models

400

Invalid request payload or missing fields.

401

Missing or invalid authentication.

403

Scope/permission not allowed.

409

Session already processing (lock conflict).

413

Audio payload too large.

415

Unsupported media/content type.

422

Validation failure in body or headers.

429

Rate limit exceeded.

503

Provider unavailable or system overload.

Examples

curl -X POST "/api/v1/voice/chat" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "X-Scope-Type: personal" \
  -d '{
    "message":"Summarize this call",
    "session_id":"sess_123",
    "stream":false
  }'