JavaScript Text to Speech API Quickstart
Integrate high-speed voice synthesis powered by Aura and Rapid models into web applications and server environments with production-ready security patterns.
Never hardcode or expose your X-API-Key in public browser bundles or frontend JavaScript. Anyone inspecting client-side requests via Browser DevTools can copy your key. Always proxy client requests through a secure backend route (e.g. Next.js API Route or Node.js Express server) where your key is safely stored in environment variables (process.env.YOURVOIC_API_KEY).
1. Getting Started & Authentication
All requests require a valid API Key in the X-API-Key header. Generate your key from your account console:
2. Secure Backend Proxy Route (Next.js / Express)
Create a server-side route handler that securely attaches your X-API-Key from server environment variables before calling the official REST endpoint.
Client-Side Browser Fetching
Your frontend browser JavaScript calls your internal /api/speech route to retrieve audio streams safely.
3. Node.js Server-Side Integration (`axios` & `fs`)
For backend scripts, CLI tools, or batch processing jobs executing directly in Node.js server environments:
4. JavaScript API Options
| Key | Type | Details |
|---|---|---|
| text | string | Plain text string for speech generation. |
| model | string | Model: rapid-flash, aura-lite, rapid-max, aura-prime, aura-max. |
| voice | string | Target voice name (e.g. Peter, Kylie, Rahul, Deepika). |
| format | string | Audio format: mp3 or wav. |
Check Other Code Examples & Full Specs
View Python code snippets or read detailed REST API documentation.