PyAI Text To Speech (Speak) API
Text-to-speech, stock voices, and prompt-to-voice design
Text-to-speech, stock voices, and prompt-to-voice design
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/pyai-com:pyai-com-text-to-speech-speak-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: PyAI Text To Speech (Speak) API
version: 2.14.0
description: 'Telephony-native Voice AI behind one bearer key:
- **Hear**, speech-to-text · `POST /v1/audio/transcriptions` (streaming + batch)
- **Speak**, text-to-speech · `POST /v1/audio/speech`, `GET /v1/voices`
- **Clone**, custom voices from a short clip · `/v1/voice/clones`
- **Cast**, auto-directed expressive voiceovers · `/v1/cast`
- **Dub**, asynchronous audio and video dubbing · `POST /v1/dub` (guide)
- **Cue configuration frames (reserved)**; Hear streams skip knowledge-base retrieval by default
- **Omni**, full-duplex agentic voice (speech-to-speech, grounded in your knowledge bases + tools) · `/v1/omni`
- **Knowledge Bases**, hosted grounding for Omni: create bases, add documents (file, URL, or text), crawl a public website, bind to agents or org defaults · `/v1/knowledgebases`
- **AMD API**, answering-machine detection: know *who or what* answered a call (human, voicemail, IVR, iPhone/Google screening, dead number) with the reason it decided · `wss …/v1/amd/stream` (Twilio Media Streams drop-in), `POST /v1/amd/config`, `GET /v1/amd/calls/{id}`
- **Agents Beta**, the live console feature to create, configure, test, and connect Omni voice agents without code. Beta features and limits may change. ## Identity, billing and authentication
- Before any generation or transcription, call GET /v1/me (MCP: whoami). Verify org_id, project_id, environment, scopes, limits and billing/credit context against the intended project. Do not infer identity or free usage from a key prefix or tool name. Stop on a mismatch or unknown budget; never switch to a live project automatically. - Test usage has enforced limits; live usage is billed. Current meters and rates: https://pyai.com/pricing. Agree a bounded input/request count before generating, and do not retry uncertain billable submissions blindly. Create a key in the console (it is shown once) and send it as a bearer token:
```
Authorization: Bearer pyai_live_... ```
Keys are environment-scoped: `pyai_live_...` (production) and `pyai_test_...` (sandbox). `POST /v1/sandbox/keys` creates an instant, short-lived test key without login or billing. Account signup also creates a sandbox key. Live keys consume prepaid credit; phone verification may unlock promotional credit under graduated-signup rules, but credit is not guaranteed at signup. Keys are self-validating signed tokens: they work on every PyAI surface the instant they are created, no activation or propagation delay. Treat them as opaque strings (up to 512 chars) and never parse their contents. Keep long-lived keys on trusted servers. For Omni browsers, mint an origin-locked short-lived token on your backend with POST /v1/omni/sessions; never expose a live or test API key in browser code. Offer the protocol marker and session token:
```
Sec-WebSocket-Protocol: pyai.v1, pyai-key. ```
(server-side clients may instead append `?api_key=...` to the URL). Your key is authenticated on the upgrade and never reaches the model. ## Quickstart, Hear (speech-to-text)
```
curl https://api.pyai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $PYAI_API_KEY" \
-F file=@audio.wav -F model=pyai-hear
# -> { "text": "..." }
```
## Quickstart, Speak (text-to-speech)
```
curl https://api.pyai.com/v1/audio/speech \
-H "Authorization: Bearer $PYAI_API_KEY" \
-H "Content-Type: application/json" \
-d ''{"model":"pyai-speak","input":"Hello from PyAI.","voice":"voice_abc"}'' \
--output speech.wav
```
`voice` is a stock voice id from `GET /v1/voices` (the curated prebuilt catalog with personas and avatars) or a cloned voice id from `/v1/voice/clones`. Omit it to use the platform default voice (`stock_dorit_en_us`).'
contact:
name: PyAI
url: https://pyai.com
servers:
- url: https://api.pyai.com
description: Production
security:
- apiKey: []
- xApiKey: []
tags:
- name: Text To Speech (Speak)
description: Text-to-speech, stock voices, and prompt-to-voice design
paths:
/v1/audio/speech:
post:
tags:
- Text To Speech (Speak)
summary: Synthesize speech
description: 'OpenAI-compatible text-to-speech. Returns audio bytes. The serving adapter defaults to incremental delivery from the streaming lane. Set `stream: false` when you require a complete buffered body with `Content-Length`. Requires the `speak:synthesize` scope.'
operationId: createSpeech
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- input
properties:
model:
type: string
default: pyai-speak
description: Use `pyai-speak`. The OpenAI `tts-1` and `tts-1-hd` aliases remain accepted for drop-in compatibility.
input:
type: string
maxLength: 2000
description: Text to synthesize. Maximum 2000 characters; longer text answers `400 input_too_long` naming the limit and the length you sent. Split longer scripts into several requests.
voice:
type: string
description: A stock voice id from `GET /v1/voices` (e.g. `stock_dorit_en_us`) or a cloned voice id (e.g. `voice_abc`) created via `/v1/voice/clones`. Omit to use the platform default voice (`stock_dorit_en_us`). For drop-in OpenAI compatibility, the preset names `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer` are also accepted and map to PyAI stock voices.
response_format:
type: string
enum:
- wav
- mp3
- opus
- aac
- flac
- pcm
- g711_ulaw
- g711_alaw
default: wav
description: Output audio format. The response `Content-Type` varies by format (`audio/wav`, `audio/mpeg`, `audio/ogg`, `audio/aac`, `audio/flac`, `audio/pcm`, `audio/basic`). `pcm` returns raw, headerless 16-bit little-endian mono samples (no container) at `sample_rate`, the format voice-agent orchestrators (e.g. Vapi custom-voice, LiveKit/Pipecat) feed directly into their pipelines. `g711_ulaw`/`g711_alaw` return raw, headerless G.711 telephony audio at a fixed 8 kHz mono (for Twilio/Plivo/FreeSWITCH); `sample_rate` does not apply and is rejected unless set to `8000`.
sample_rate:
type: integer
minimum: 8000
maximum: 48000
description: 'Optional output sample rate in Hz (8000-48000), e.g. `8000`/`16000` for telephony or `24000` for wideband. Omit to use the native 24 kHz. Most relevant with `response_format: pcm`. Does not apply to `g711_ulaw`/`g711_alaw`, which are always 8 kHz mono (a conflicting value is rejected).'
speed:
type: number
description: Reserved but not active on Speak. Sending this field currently returns `400 unsupported_parameter`.
emotion:
type: string
enum:
- neutral
- happy
- sad
- angry
- fearful
- surprised
description: Optional named delivery direction, rendered in the same voice in streaming or buffered mode. Inspect the voice's `speak_emotions` in `GET /v1/voices`; an empty or absent list means directed emotion is unavailable. Unsupported voice/emotion combinations return `400 unsupported_parameter`. `neutral` preserves ordinary delivery on every voice. An unavailable emotional rendering returns an error instead of a neutral replacement. Intensity and free-form `instructions` are not supported on Speak; supplying either returns `400 unsupported_parameter`.
stream:
type: boolean
default: true
description: 'Use incremental audio delivery. The default is `true`: the adapter forwards validated chunks as they arrive. Set `false` to use the blocking lane and receive a complete buffered body with a `Content-Length`. Every catalog voice accepts both values. A voice whose serving fleet has no streaming lane is rendered on the blocking lane and the response carries `x-pyai-stream: buffered` — same body, same format, higher time-to-first-byte.'
speech_session_id:
type: string
minLength: 1
maxLength: 128
description: 'Call-stable voice recovery (enabled organizations and supported stock voices only). Send the same unique call ID and voice on every utterance and retry. The engine is selected before the first audio response and cannot change for this call. Sessions last at most 24 hours; never reuse a call ID. A backup voice may differ from the requested stock voice, but stays fixed for the whole call. Recovery audio is buffered and reports x-pyai-speech-profile: recovery. Omit this field for ordinary synthesis without external voice recovery. Directed emotions and custom/cloned voices are not eligible.'
seed:
type: integer
description: Reserved but not active on Speak. Sending this field currently returns `400 unsupported_parameter`.
temperature:
type: number
description: Reserved but not active on Speak. Sending this field currently returns `400 unsupported_parameter`.
responses:
'200':
description: 'Audio bytes. Bytes are delivered incrementally by default; `stream: false` returns a complete buffered body. The `Content-Type` varies by `response_format`: `audio/wav` (wav), `audio/mpeg` (mp3), `audio/ogg` (opus), `audio/aac` (aac), `audio/flac` (flac), `audio/pcm` (pcm, raw/headerless), and `audio/basic` (g711_ulaw/g711_alaw, raw/headerless G.711 at 8 kHz mono).'
content:
audio/wav:
schema:
type: string
format: binary
audio/mpeg:
schema:
type: string
format: binary
audio/ogg:
schema:
type: string
format: binary
audio/aac:
schema:
type: string
format: binary
audio/flac:
schema:
type: string
format: binary
audio/pcm:
schema:
type: string
format: binary
audio/basic:
schema:
type: string
format: binary
'401':
$ref: '#/components/responses/Unauthorized'
'402':
$ref: '#/components/responses/PaymentRequired'
'403':
$ref: '#/components/responses/Forbidden'
'409':
description: 'A cloned voice that is `ready` but has not yet reached the render tier (`code: voice_propagating`): honour `Retry-After` (60 s). Call voice recovery also returns 409 for a mismatched voice, expired session, or concurrent first-request selection conflict. Retry a selection conflict with the same speech_session_id; never change the ID mid-call.'
'429':
$ref: '#/components/responses/RateLimited'
/v1/voices:
get:
tags:
- Text To Speech (Speak)
summary: List voices
description: 'Your unified voice library: the prebuilt PyAI catalog (with presentation metadata; some entries include an avatar or pre-generated audio preview) merged with your saved **designed** voices, each tagged by `source` (`stock` | `design`). Any active key may read it (no specific scope). Inspect `available_on` before using a stock voice with Speak or Omni, and inspect `synthesis_modes` before choosing streaming or async Speak delivery. `tier` is the customer-facing quality tier. `pricing` reports only the voice-specific amount on top of that product''s base rate. `aliases` are permanent convenience inputs on the advertised surfaces; responses report the canonical `voice_id`. Cloned voices are listed separately via `GET /v1/voice/clones`.'
operationId: listVoices
parameters:
- name: gender
in: query
required: false
schema:
type: string
enum:
- M
- F
- m
- f
- male
- female
description: Filter stock voices by gender (case-insensitive; M/male or F/female).
- name: region
in: query
required: false
schema:
type: string
description: Filter stock voices by region/accent (case-insensitive substring match, e.g. `us`, `india`, `scotland`) or locale (e.g. `en_us`, `en-US`, `en_gb`). Locale filters match language and accent metadata.
- name: language
in: query
required: false
schema:
type: string
enum:
- bn
- de
- en
- en-CA
- en-GB
- en-US
- en-ZA
- es
- fr
- gu
- hi
- it
- ja
- kn
- ko
- pa
- pt
- ru
- te
- ur
- zh
description: Filter stock voices by stable language code from the customer catalog. Inspect available_on for each voice’s supported products.
- name: tier
in: query
required: false
schema:
type: string
enum:
- standard
- natural
description: Filter stock voices by customer-facing quality tier.
- name: q
in: query
required: false
schema:
type: string
description: Rank stock voices by matching tokens across name, aliases, accent, language, age band, pitch, tone, use cases, and search tags.
- name: source
in: query
required: false
schema:
type: string
enum:
- stock
- design
description: Return only one kind of voice. Omit for the merged library.
responses:
'200':
description: Voice library (stock + designed)
content:
application/json:
schema:
$ref: '#/components/schemas/StockVoiceList'
'401':
$ref: '#/components/responses/Unauthorized'
/v1/voices/{id}:
get:
tags:
- Text To Speech (Speak)
summary: Get a stock voice
operationId: getVoice
parameters:
- name: id
in: path
required: true
schema:
type: string
description: Canonical stock voice id or permanent alias. Alias lookups return the canonical `voice_id`.
responses:
'200':
description: Stock voice
content:
application/json:
schema:
$ref: '#/components/schemas/StockVoice'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: No such stock voice
delete:
tags:
- Text To Speech (Speak)
summary: Delete a designed voice
description: Delete a saved designed (prompt-to-voice) voice from synthesis and the library, freeing a library-cap slot only after synthesis deletion is confirmed. Retrying a deletion of your own voice is safe. A temporary deletion failure returns 503; retry the request. Tenant-isolated, you can only delete your own (otherwise `404`). Stock voices can't be deleted; cloned voices delete via `DELETE /v1/voice/clones/{id}`.
operationId: deleteVoice
parameters:
- name: id
in: path
required: true
schema:
type: string
description: Designed voice id, e.g. `vd_7h16k`.
responses:
'200':
description: Deleted
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: No such designed voice for this tenant
'503':
description: Synthesis deletion could not be confirmed. Retry the deletion request.
/v1/voice/design:
post:
tags:
- Text To Speech (Speak)
summary: Design a voice from a prompt
description: 'Generate a brand-new **synthetic** voice from a text description (distinct from cloning, which copies a real person). Async: returns `202` with a `design_id`; poll `GET /v1/voice/design/{id}` for candidate previews, then `POST /v1/voice/design/{id}/save` to keep one. Send a stable `Idempotency-Key` when retrying create: the same organization and key receive the original response without another job or billable unit. Requires the `speak:design` scope.'
operationId: createDesign
parameters:
- name: Idempotency-Key
in: header
required: false
schema:
type: string
minLength: 1
maxLength: 255
pattern: ^[^\s]+$
description: Customer-stable retry token. Reuse it only for retries of the same create request.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- prompt
properties:
prompt:
type: string
description: Natural-language description of the voice.
candidates:
type: integer
default: 3
minimum: 1
maximum: 4
description: How many candidate voices to generate.
sample_text:
type: string
description: Optional line the previews speak.
language:
type: string
enum:
- en
- zh
- ja
- ko
- de
- fr
- ru
- pt
- es
- it
default: en
description: Language spoken by the preview. Other languages are not supported for voice design.
attributes:
type: object
description: Optional structured hints folded into the prompt.
properties:
gender:
type: string
age:
type: string
accent:
type: string
pace:
type: number
energy:
type: number
responses:
'202':
description: Design job accepted
content:
application/json:
schema:
type: object
properties:
design_id:
type: string
example: dsn_a1b2c3
status:
type: string
example: queued
candidates:
type: integer
example: 3
estimated_seconds:
type: integer
example: 25
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'429':
description: Design queue saturated, retry after the `Retry-After` delay.
/v1/voice/design/{id}:
get:
tags:
- Text To Speech (Speak)
summary: Get design candidates
description: Poll a design job. When `status` is `completed`, `candidates` carries signed preview URLs (24h TTL). Candidates below the quality gate are omitted. Requires the `speak:design` scope.
operationId: getDesign
parameters:
- name: id
in: path
required: true
schema:
type: string
description: Design id.
responses:
'200':
description: Design status + candidates
content:
application/json:
schema:
type: object
properties:
design_id:
type: string
example: dsn_a1b2c3
status:
type: string
enum:
- queued
- running
- completed
- failed
candidates:
type: array
items:
type: object
properties:
candidate_id:
type: string
example: c1
preview_url:
type: string
format: uri
quality:
type: object
properties:
intelligibility:
type: number
example: 1
duration_s:
type: number
example: 3.4
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: No such design for this tenant
/v1/voice/design/{id}/preview/{candidate_id}:
get:
tags:
- Text To Speech (Speak)
summary: Preview a designed-voice candidate
description: Fetch a short-lived audio preview for a candidate owned by the authenticated organization. Cross-organization and malformed lookups return the same not-found response. Requires the `speak:design` scope.
operationId: previewDesignCandidate
parameters:
- name: id
in: path
required: true
schema:
type: string
description: Design job id.
- name: candidate_id
in: path
required: true
schema:
type: string
description: Candidate id returned by the completed job.
responses:
'200':
description: Candidate preview audio.
content:
audio/wav:
schema:
type: string
format: binary
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: No such design candidate for this tenant
/v1/voice/design/{id}/save:
post:
tags:
- Text To Speech (Speak)
summary: Save a designed voice
description: 'Enroll the chosen candidate as a permanent `voice_id`, usable immediately in `POST /v1/audio/speech` (`voice: vd_…`) and in Omni agents. Requires the `speak:design` scope.'
operationId: saveDesign
parameters:
- name: id
in: path
required: true
schema:
type: string
description: Design id.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- candidate_id
- name
properties:
candidate_id:
type: string
example: c1
name:
type: string
example: Support, Nova
metadata:
type: object
additionalProperties: true
responses:
'201':
description: Saved voice
content:
application/json:
schema:
type: object
properties:
voice_id:
type: string
example: vd_7h16k
name:
type: string
example: Support, Nova
source:
type: string
example: design
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
description: No such design / candidate for this tenant
components:
responses:
RateLimited:
description: 'Too many requests or too many concurrent realtime sessions; see Retry-After header (`code: rate_limit_exceeded | concurrency_limit_exceeded | daily_cap_exceeded`)'
headers:
Retry-After:
schema:
type: integer
description: Seconds to wait.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Forbidden:
description: 'Key lacks the required scope or the origin is not allow-listed (`code: forbidden | origin_not_allowed`)'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
PaymentRequired:
description: 'Billing gate: org out of prepaid credit, per-key budget hit, or plan quota exhausted (`code: credit_exhausted | key_budget_exceeded | insufficient_quota`). Do not retry; add credit or raise the limit. A brand-new key may see this on its first call until the account is funded.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unauthorized:
description: 'Missing or invalid API key (`code: unauthorized`)'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
ErrorCode:
type: string
description: Stable, machine-readable error code. Branch on this rather than the human `message`.
enum:
- invalid_request_error
- invalid_session_label
- unauthorized
- forbidden
- origin_not_allowed
- credit_exhausted
- key_budget_exceeded
- child_budget_exceeded
- insufficient_quota
- rate_limit_exceeded
- concurrency_limit_exceeded
- daily_cap_exceeded
StockVoice:
type: object
properties:
object:
type: string
example: voice
voice_id:
type: string
example: stock_dorit_en_us
name:
type: string
example: Imogen
gender:
type: string
enum:
- M
- F
region:
type: string
example: UK (England / RP)
description: Accent / regional flavor.
age:
type: string
example: '32'
tone:
type: string
example: polished, reassuring
bio:
type: string
example: Calm, articulate London front-desk.
language:
type: string
example: en
avatar_url:
type: string
format: uri
description: Voice-matched avatar image (PNG).
preview_url:
type: string
format: uri
description: Optional pre-generated audio preview (MP3). If absent, synthesize a short sample with this `voice_id`.
accent:
type: string
description: Normalized accent label used for matching.
age_band:
type: string
description: Normalized age band, e.g. 25-34.
pitch_band:
type: string
description: Normalized pitch band, e.g. low-medium.
pace:
type: string
description: Normalized speaking pace.
use_cases:
type: array
items:
type: string
description: Recommended Agent and content use cases.
search_tags:
type: array
items:
type: string
description: Search and auto-suggest tags.
aliases:
type: array
items:
type: string
description: Permanent convenience identifiers accepted on the voice's advertised surfaces. API responses report the canonical `voice_id`.
available_on:
type: array
items:
type: string
enum:
- speak
- omni
description: Product surfaces on which this stock voice can be selected.
speak_emotions:
type: array
items:
type: string
enum:
- neutral
- happy
- sad
- angry
- fearful
- surprised
description: Verified named delivery controls on Speak for this voice. An empty or absent list means directed emotion is unavailable. These controls apply to streaming and buffered speech; intensity is not supported.
synthesis_modes:
type: array
items:
type: string
enum:
- streaming
- async
description: 'Delivery modes accepted for this voice on `POST /v1/audio/speech`. Every Speak-available voice accepts both; a voice served from a blocking-only fleet answers a streaming request with `x-pyai-stream: buffered`. An empty list means the voice has no Speak surface at all (check `available_on`).'
tier:
type: string
enum:
- standard
- natural
description: Customer-facing voice quality tier. The public catalog includes Standard and Natural voices; inspect `available_on` and `synthesis_modes` before use.
example: standard
pricing:
type: object
required:
- included_in_base_price
- additional_price_usd_per_minute
description: Voice-specific pricing on top of the selected product's base rate.
properties:
included_in_base_price:
type: boolean
example: true
additional_price_usd_per_minute:
type: number
minimum: 0
example: 0
source_dataset:
type: string
description: Source dataset attribution.
license:
type: string
description: Source voice license identifier.
StockVoiceList:
type: object
properties:
object:
type: string
example: list
data:
type: array
items:
$ref: '#/components/schemas/StockVoice'
Error:
type: object
description: OpenAI-compatible error envelope returned by the gateway data plane (401/402/403/429). Control-plane request/resource errors use Problem (application/problem+json) instead.
required:
- error
properties:
error:
type: object
required:
- message
properties:
message:
type: string
description: Human-readable explanation.
type:
type: string
description: Error category, e.g. rate_limit_error.
code:
$ref: '#/components/schemas/ErrorCode'
param:
type: string
nullable: true
description: Offending parameter when applicable, else null.
securitySchemes:
interpretationUpload:
type: http
scheme: bearer
description: Short-lived write-only upload_capability returned by POST /v1/audio/interpretations/recordings. Never use it for reads.
sessionCookie:
type: apiKey
in: cookie
name: pyai_session
description: Console session cookie. PyAI-admin routes also require the configured platform-admin email allowlist.
apiKey:
type: http
scheme: bearer
description: 'Use `Authorization: Bearer pyai_live_...` (or `pyai_test_...`).'
xApiKey:
type: apiKey
in: header
name: x-api-key
description: Header alias for bearer auth on HTTP endpoints. WebSocket auth uses the subprotocol pair `pyai.v1, pyai-key.<API_KEY>`.
x-pyai-agent-notes:
guide: https://pyai.com/agents/speech-calling.md
omni_frames: https://api.pyai.com/omni-frames.json
discovery: Inspect live operation schemas; preserve IDs and required Idempotency-Key headers. SDK-first for realtime. Never infer a simulated PSTN call endpoint.