OmniVoice External API

Phase 06 API Productization: docs + examples + OpenAPI export + quickstart.

10-Minute Quickstart

Target: get first audio file from external API within 10 minutes.

  1. Set environment values: BASE_URL, ADMIN_KEY, API_KEY.
  2. Create API key (admin).
  3. Run one of the example clients (curl / Python / JavaScript).
  4. Export OpenAPI for client SDK generation.

Step 1: Create API Key

curl -X POST "${BASE_URL}/api/auth/keys" \
  -H "Content-Type: application/json" \
  -H "X-Admin-Key: ${ADMIN_KEY}" \
  -d @examples/create-key.json

Template file: /examples/create-key.json

Step 2: Generate First Audio

curl

curl -X POST "${BASE_URL}/v1/audio/speech" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: ${API_KEY}" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "สวัสดีครับ นี่คือ quickstart ของ OmniVoice",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  --output hello.mp3

Script: /examples/curl-openai-speech.sh

Python

BASE_URL="http://127.0.0.1:8015" \
API_KEY="YOUR_API_KEY" \
OUT_FILE="hello-python.mp3" \
python examples/python-openai-speech.py

Script: /examples/python-openai-speech.py

JavaScript (Node.js)

BASE_URL="http://127.0.0.1:8015" \
API_KEY="YOUR_API_KEY" \
OUT_FILE="hello-js.mp3" \
node examples/javascript-openai-speech.mjs

Script: /examples/javascript-openai-speech.mjs

Step 3: OpenAPI Export

# JSON download
curl "${BASE_URL}/api/openapi/export?format=json&download=true" -o omnivoice_openapi.json

# YAML export (requires PyYAML in server environment)
curl "${BASE_URL}/api/openapi/export?format=yaml&download=true" -o omnivoice_openapi.yaml
Endpoint: GET /api/openapi/export

Core Endpoints

Endpoint Auth Purpose
POST /v1/audio/speech X-API-Key OpenAI-compatible speech generation
POST /api/jobs/tts X-API-Key Queue TTS job
GET /api/jobs/{job_id} X-API-Key Job status (owner-scoped)
GET /api/jobs/{job_id}/audio X-API-Key Download output WAV when completed
GET /api/usage/cost-dashboard X-Admin-Key Cost and quota-stage aggregates