# Spero & Odesa Voice AI — Complete Developer Documentation Generated from https://spero.audio/docs. # Spero API — Overview & Quickstart Base URL (REST): `https://api.spero.audio` Base URL (WebSocket): `wss://api.spero.audio` Authentication: `Authorization: Bearer sp_live_...` Data retention: Zero (`X-Data-Retention: zero`, `Cache-Control: no-store`) One API key and one prepaid balance cover: - **Odesa-1 Speech-to-Text**: `POST /v1/audio/transcriptions` (batch & SSE) and `WS /v1/audio/stream` (real-time 16 kHz PCM16 streaming, ~24 ms partials), across 36 languages + `auto` code-switching. - **Spero Text-to-Speech**: `POST /v1/audio/speech` (mp3, wav, flac, opus, pcm, 8 kHz G.711 ulaw) plus low-latency streaming on `spero-f1`. - **Kuroko Turn-Taking**: Open-weight 14.9M model (#1 on TurnBench) for end-of-turn and interruption vs. backchannel detection. ## Quickstart (OpenAI SDK drop-in, Python) ```python import os from openai import OpenAI client = OpenAI(base_url="https://api.spero.audio/v1", api_key=os.environ["SPERO_API_KEY"]) # Speech to text (Odesa-1) with open("call.wav", "rb") as audio: tx = client.audio.transcriptions.create( model="odesa-1-pro", file=audio, language="en", extra_body={"smart_format": True}, ) print(tx.text) # Text to speech (Spero) speech = client.audio.speech.create( model="spero-v1", voice="spero-f1", input="Your order ships on Tuesday.", ) speech.write_to_file("speech.mp3") ``` ## Onboarding 1. Sign up at https://spero.audio/signup and confirm your email ($2.00 free credit: 100,000 TTS chars, ~22 hr `odesa-1-pro`, or ~55 hr `odesa-1-mini`). 2. Create an API key (`sp_live_...`) at https://spero.audio/developers. Store it server-side only. 3. Send your first request using `curl`, `fetch`, or the official OpenAI SDK. --- # Models & Voices ## Speech-to-Text Models (Odesa-1) | Model | License | Rate (Batch & Live) | English MAIN-7 WER | English AA-PUB WER | Languages | Best For | |---|---|---:|---:|---:|---|---| | `odesa-1-pro` | Closed API | $0.09/hr | 4.29% | 2.37% | 36 + auto | Maximum accuracy on noisy calls, earnings, jargon, and 36 languages + auto | | `odesa-1-fast` | Apache-2.0 | $0.054/hr | 5.23% | 3.22% | 36 + auto | #1 Apache-2.0 on AA-PUB; balanced speed & accuracy | | `odesa-1-mini` | Apache-2.0 | $0.036/hr | 4.95% | 3.47% | 36 + auto | #1 Apache-2.0 on MAIN-7; compact, ultra-fast & lowest cost | ## Text-to-Speech Voices (`spero-v1`) Rate: **$20.00 / 1M characters** ($0.00002/char). Both voices are built from recordings of real people who agreed to this use. | Voice ID | Gender | Accent | Streaming (`stream: true`) | Formats | |---|---|---|---|---| | `spero-f1` | Female | US English | Yes (~330 ms TTFB, pcm/wav) | mp3, wav, flac, opus, pcm, ulaw | | `spero-m1` | Male | US English | Files only | mp3, wav, flac, opus, pcm, ulaw | ## Turn-Taking (Kuroko) - 14.9M parameters, open weights at https://huggingface.co/cloud0day3/kuroko - #1 on TurnBench test split: 98.3% end-of-turn recall (6.5% FPR), 98.9% interruption recall (7.4% FPR), 557 ms median interruption delay. ## Discovery Endpoints (No Auth Required) - `GET https://api.spero.audio/v1/models` - `GET https://api.spero.audio/v1/voices` - `GET https://api.spero.audio/v1/stt/health` - `GET https://api.spero.audio/health` --- # Transcribe Audio (REST & SSE) Endpoint: `POST https://api.spero.audio/v1/audio/transcriptions` Content-Type: `multipart/form-data` Auth: `Authorization: Bearer sp_live_...` Drop-in compatible with the OpenAI Audio Transcriptions API. Supports batch uploads up to **25 MiB** and **60 minutes** (WAV, FLAC, MP3, M4A, OGG, WEBM, MP4, Opus), plus Server-Sent Events (`stream=true`). ## Parameters | Field | Type | Default | Description | |---|---|---|---| | `file` | binary (required) | — | Audio file up to 25 MiB / 60 minutes. | | `model` | string | `odesa-1-pro` | `odesa-1-pro`, `odesa-1-fast`, or `odesa-1-mini`. | | `language` | string | `en` | Any of 36 supported ISO codes (`en`, `es`, `fr`, `de`, `zh`, `ja`, `ar`, `hi`, `tr`, ...) or `auto` for auto-detection and code-switching. | | `response_format` | string | `json` | `json`, `verbose_json` (includes `duration`, `segments`, and `meta`), or `text`. | | `smart_format` | boolean | `false` | When `true`, formats spoken times (`4:45 PM`), phone numbers (`555-0192`), currency, percentages, dates, emails, and digits. | | `transcription_mode` | string | `verbatim` | `verbatim` (keeps fillers), `clean` (aliases `non_verbatim`, `non-verbatim` — removes fillers & stutters), or `verbatim_latin`. | | `prompt` | string | `""` | Optional glossary / domain vocabulary hint (max 1,000 chars; zero retention). | | `temperature` | float | `0.0` | Sampling temperature from `0.0` to `1.0`. | | `stream` | boolean | `false` | Streams chunk deltas via `text/event-stream` (`response_format` must be `json` or omitted). | ## Response Formats ### `json` ```json { "text": "Hi, my callback number is 555-0192 at 4:45 PM." } ``` ### `verbose_json` ```json { "task": "transcribe", "language": "en", "duration": 4.82, "text": "Hi, my callback number is 555-0192 at 4:45 PM.", "segments": [ { "id": 0, "start": 0.0, "end": 4.82, "text": "Hi, my callback number is 555-0192 at 4:45 PM." } ], "meta": { "model": "odesa-1-pro", "transcription_mode": "verbatim", "smart_format": true, "elapsed_s": 0.78 } } ``` ### `stream=true` (Server-Sent Events) ```text data: {"type":"transcript.text.delta","chunk_id":0,"start":0.0,"end":28.5,"delta":"...","elapsed_s":0.81} data: {"type":"transcript.text.done","text":"...","duration":28.5,"elapsed_s":0.82} data: [DONE] ``` ## Response Headers - `X-Model`: Canonical Odesa-1 model ID - `X-Audio-Seconds`: Server-measured audio duration in seconds - `X-Cost-USD`: Exact charge in USD - `X-Request-Id`: Request ID shown in `/developers/requests` - `X-Data-Retention`: `zero` --- # Live Streaming Speech-to-Text (WebSocket) Endpoint: `wss://api.spero.audio/v1/audio/stream` Wire Audio Format: Raw binary frames of **16 kHz, mono, signed 16-bit little-endian PCM (`int16`)** (32,000 bytes/sec; send 100–200 ms chunks = 3,200–6,400 bytes). ## Authentication 1. **Server-side (API key):** HTTP upgrade header `Authorization: Bearer sp_live_...` 2. **Browser subprotocol (short-lived session JWT):** `new WebSocket(url, ["spero-auth", "bearer."])` 3. **First-frame JSON auth (within 5 seconds):** `{"type":"auth","token":""}` Never pass credentials in query parameters (`?api_key=` or `?token=`) — rejected immediately with close code `4401`. ## Query Parameters | Param | Default | Range / Values | Description | |---|---|---|---| | `model` | `odesa-1-pro` | `odesa-1-pro`, `odesa-1-fast`, `odesa-1-mini` | Target model (flat per-second pricing, zero streaming surcharge). | | `language` | `en` | Any of 36 ISO codes or `auto` | ISO language code or `auto`. Streams live partials as you speak and finalizes each turn on pauses. | | `transcription_mode` | `verbatim` | `verbatim`, `clean`, `verbatim_latin` | Filler/stutter handling on both partials and finals. | | `smart_format` | `false` | `true` / `false` | Apply ITN formatting to English partials and finals. | | `vad_silence_ms` | `600` | `200`–`3000` | Silence pause duration (ms) to commit a `final` turn. | | `partial_ms` | `320` | `150`–`2000` | Minimum interval (ms) between live `partial` events. | | `vad_rms` | `0.012` | `0.001`–`0.2` | Normalized RMS speech energy threshold. | | `max_turn_s` | `16.0` | `3.0`–`30.0` | Maximum turn length before forced finalization. | ## Client Control Frames (JSON Text) - `{"type":"flush"}` or `{"type":"end_turn"}`: Finalize the buffered speech turn immediately. - `{"type":"stop"}`: Finalize any pending turn, emit `session_summary`, settle remaining billing, and close cleanly. ## Server Events (JSON Text) - `ready`: `{"type":"ready","model":"odesa-1-pro","language":"en","transcription_mode":"verbatim","smart_format":true}` - `partial`: `{"type":"partial","text":"...","stable":"...","audio_s":1.8,"latency_ms":24.1}` (`stable` is the committed prefix unlikely to revise) - `final`: `{"type":"final","turn_id":1,"text":"...","audio_s":3.4,"total_audio_s":3.4,"latency_ms":640.0}` - `usage`: `{"type":"usage","audio_seconds":60.0,"cost_usd":"0.001500","total_audio_seconds":60.0,"total_cost_usd":"0.001500"}` - `session_summary`: `{"type":"session_summary","total_audio_s":142.4,"turns":12}` - `error`: `{"type":"error","code":"session_limit","message":"Maximum session length reached."}` ## Session & Billing Limits - Minimum 60 seconds of prepaid credit required at connect. - Settled every 60 seconds of PCM16 audio streamed and again on close. - Maximum 45 minutes per session; up to 4 concurrent live WebSocket streams per key/account. --- # Languages & Formatting (Odesa-1) Odesa-1 supports **36 languages plus `auto` (automatic language detection and code-switching)** across `POST /v1/audio/transcriptions` and `WS /v1/audio/stream`. Omitting `language` defaults to `en`. ## Supported Languages (36 + `auto`) - `en` — English (English) - `auto` — Auto / Code-Switch (Auto-detect) - `es` — Spanish (Español) - `fr` — French (Français) - `de` — German (Deutsch) - `it` — Italian (Italiano) - `pt` — Portuguese (Português) - `nl` — Dutch (Nederlands) - `pl` — Polish (Polski) - `ru` — Russian (Русский) - `zh` — Chinese (中文) - `ja` — Japanese (日本語) - `ko` — Korean (한국어) - `ar` — Arabic (العربية) [RTL] - `hi` — Hindi (हिन्दी) - `tr` — Turkish (Türkçe) - `vi` — Vietnamese (Tiếng Việt) - `bg` — Bulgarian (Български) - `hr` — Croatian (Hrvatski) - `cs` — Czech (Čeština) - `da` — Danish (Dansk) - `et` — Estonian (Eesti) - `fi` — Finnish (Suomi) - `el` — Greek (Ελληνικά) - `hu` — Hungarian (Magyar) - `lv` — Latvian (Latviešu) - `lt` — Lithuanian (Lietuvių) - `mt` — Maltese (Malti) - `ro` — Romanian (Română) - `sk` — Slovak (Slovenčina) - `sl` — Slovenian (Slovenščina) - `sv` — Swedish (Svenska) - `uk` — Ukrainian (Українська) - `yue` — Cantonese (粵語) - `id` — Indonesian (Bahasa Indonesia) - `th` — Thai (ไทย) - `ms` — Malay (Bahasa Melayu) ## Smart Formatting (`smart_format=true`) Default `smart_format=false` preserves spoken wording as heard. Opt into `smart_format=true` for display-ready inverse text normalization: - Times: `four forty-five p m` -> `4:45 PM` - Phone numbers & codes: `five five five zero one nine two` -> `555-0192` - Currency & percentages: `twenty five dollars and fifty cents` -> `$25.50`, `twelve point five percent` -> `12.5%` - Dates & emails: `march fifteenth twenty twenty six` -> `March 15, 2026` ## Transcription Modes (`transcription_mode`) - `verbatim` (default): Preserves fillers (`uh`, `um`, `mm-hmm`) and spoken repetitions. - `clean` (aliases `non_verbatim`, `non-verbatim`): Strips standalone fillers and 1-word accidental stutters for clean CRM notes and UI display. - `verbatim_latin`: Verbatim output transliterated to Latin script where applicable. ## Glossary Prompting (`prompt`) Pass up to 1,000 characters of proper nouns, patient/customer names, medication names, or acronyms via `prompt`. Prompts are never stored or logged. --- # Create Speech (Text-to-Speech) Endpoint: `POST https://api.spero.audio/v1/audio/speech` Content-Type: `application/json` Auth: `Authorization: Bearer sp_live_...` OpenAI-compatible English text-to-speech. Renders studio-quality audio files or low-latency chunked audio streams on `spero-f1` (~330 ms first audio). ## Parameters | Field | Type | Default | Description | |---|---|---|---| | `input` | string (required) | — | 1 to 2,000 characters (up to 12 paragraphs; max 100 chars per word). With `stream: true`, one paragraph of at most 600 characters. | | `model` | string | `spero-v1` | Model identifier. | | `voice` | string | `spero-f1` | `spero-f1` (female, US English, supports streaming) or `spero-m1` (male, US English, files only). | | `response_format` | string | `mp3` (`pcm` when streaming) | `mp3`, `wav`, `flac`, `opus`, `pcm` (16-bit LE mono), or `ulaw` (8 kHz G.711 mu-law, headerless, `audio/basic`). With `stream: true`, only `pcm` or `wav`. | | `speed` | float | `1.0` | Tempo from `0.9` to `1.1` (pitch preserved). Files only (cannot combine with `stream`). | | `sample_rate` | integer | `24000` | `8000`, `16000`, or `24000` Hz (for `wav`, `pcm`, `flac`, `mp3`; omit for `opus`; `8000` or omit for `ulaw`). Files only. | | `stream` | boolean | `false` | Streams raw 24 kHz PCM16 or streaming WAV as audio is generated (`spero-f1` only). | ## Streaming Best Practices - First audio arrives in ~330 ms (location-dependent). Pre-buffer ~100 ms before starting playback. - Reuse persistent HTTP keep-alive connections to save ~60 ms per subsequent turn. - If a stream drops mid-generation due to a server failure, the connection is cut without charging. ## Response Headers - `X-Model`, `X-Voice`, `X-Characters`, `X-Audio-Seconds` (files only), `X-Cost-USD`, `X-Queue-Wait-Ms`, `X-Request-Id`, `X-Disclosure: AI-generated audio`. --- # Voice Agents & Migration ## Drop-in OpenAI SDK Compatibility Point `openai` (Python or TypeScript/Node) at `base_url="https://api.spero.audio/v1"` with `api_key=os.environ["SPERO_API_KEY"]`. Both `client.audio.transcriptions.create(...)` and `client.audio.speech.create(...)` work without an extra SDK. ## Migration Cheat Sheet - **From OpenAI (`gpt-transcribe` / `whisper-1`):** Set `base_url="https://api.spero.audio/v1"`, set `model="odesa-1-pro"` (33% fewer errors on MAIN-7, $0.09/hr vs. $0.27/hr batch / $1.02/hr live). - **From ElevenLabs (`scribe_v3` / `scribe_v2`):** Replace `xi-api-key` with `Authorization: Bearer $SPERO_API_KEY`, call `POST https://api.spero.audio/v1/audio/transcriptions` with `model=odesa-1-pro` ($0.09/hr flat batch & live vs. $0.20–$0.22/hr). - **From Deepgram (`nova-3`):** Connect to `wss://api.spero.audio/v1/audio/stream?model=odesa-1-pro&smart_format=true&vad_silence_ms=600` with `Authorization: Bearer $SPERO_API_KEY` and send raw 16 kHz mono PCM16 frames. ## Real-Time Voice Agent Architecture 1. **Listen:** Stream 16 kHz PCM16 over `WS /v1/audio/stream` (~24 ms partials + VAD turn finals). 2. **Turn-Taking:** Run open-weight **Kuroko** (14.9M) locally to separate real barge-in interruptions from brief backchannels ("mhm", "yeah"). 3. **Think:** Pass committed `final` transcripts to your LLM over a persistent connection. 4. **Speak:** Stream replies from `POST /v1/audio/speech` with `voice: "spero-f1"`, `stream: true`, `response_format: "pcm"` (~330 ms TTFB; reuse keep-alive HTTP connections) or render `response_format: "ulaw"` for 8 kHz G.711 telephony. ## AI Coding Agents (`llms.txt`) - Concise index: https://spero.audio/llms.txt - Complete Markdown manual: https://spero.audio/llms-full.txt --- # Pricing & Billing One prepaid balance covers all Spero TTS and Odesa-1 STT usage. No subscriptions, no streaming surcharges, and no extra charges for `smart_format`, `prompt`, `speed`, `sample_rate`, or `ulaw`. ## Rates | Model | Modality | Rate | Unit Breakdown | |---|---|---:|---| | `spero-v1` | Text to speech | **$20.00 / 1M chars** | $0.00002 / character | | `odesa-1-pro` | Speech to text (batch & live) | **$0.09/hr** | $0.0015/min · $1.50 / 1k min (per second, 1 s min) | | `odesa-1-fast` | Speech to text (batch & live) | **$0.054/hr** | $0.0009/min · $0.90 / 1k min (per second, 1 s min) | | `odesa-1-mini` | Speech to text (batch & live) | **$0.036/hr** | $0.0006/min · $0.60 / 1k min (per second, 1 s min) | ## Free Signup Credit New confirmed accounts receive **$2.00** in free credit: enough for 100,000 TTS characters, ~22 hours of `odesa-1-pro`, ~37 hours of `odesa-1-fast`, or ~55 hours of `odesa-1-mini`. ## Billing Rules - **TTS:** Charged on completion (or when a stream finishes / client disconnects after audio begins). Failed requests or mid-stream server drops cost $0. - **STT uploads:** Server-measured audio duration rounded up to whole seconds (1 s minimum). Failed uploads cost $0. - **STT WebSockets:** Requires at least 60 s of balance at connect, bills exact PCM16 audio seconds streamed, settles every 60 s and on close, and closes with `4402` if balance runs out. - **Top-ups:** $10 to $5,000 via Stripe at https://spero.audio/dashboard/billing. --- # Errors, Limits & Security ## Error Envelope ```json { "error": { "code": "insufficient_balance", "message": "Your balance does not cover this request.", "type": "billing_error" } } ``` ## HTTP Status Codes - `400 invalid_request`: Fix the request parameter named in `error.message`. - `401 unauthorized`: Invalid or revoked API key (revocation propagates within 30 s). - `402 insufficient_balance`: Balance does not cover this request. Add credit. - `413 payload_too_large`: STT upload exceeds 25 MiB. - `429 rate_limited`: Wait for `Retry-After` seconds and retry with exponential backoff. - `503 unavailable`: Service temporarily at capacity or unavailable. Wait for `Retry-After` and retry. Failed requests are never charged. ## WebSocket Close Codes (`WS /v1/audio/stream`) - `4400`: Invalid query parameter or unknown model. - `4401`: Missing/invalid/expired auth, or credentials passed in the query string. - `4402`: Insufficient balance at connect or exhausted mid-stream. - `4429`: Rate limit or concurrent live-stream limit reached. - `4503`: Live streaming temporarily unavailable. ## Limits - **TTS input:** 2,000 chars per file (max 12 paragraphs, max 100 chars/word); 1 paragraph / 600 chars for `stream: true`. - **STT upload:** 25 MiB per file, up to 60 minutes. - **STT WebSocket:** 45 minutes max per session. - **Concurrency:** 4 TTS / 8 batch STT / 4 live STT WebSocket streams simultaneously per key and per account. - **Rate limit:** 120 requests/minute per key. - **API keys:** Up to 10 active keys per account. ## Zero Data Retention & Security - Spero and Odesa process audio, prompts, and transcripts strictly in memory and never log or store payload contents (`X-Data-Retention: zero`, `Cache-Control: no-store`). - Only billing metadata (model, counts/duration, cost, status, request ID) is recorded. - Never embed `sp_live_` keys in browser code; use short-lived session JWTs for browser WebSockets.