Stream speech from text (Lightning V3.1)
curl --request POST \
--url https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"voice_id": "<string>",
"sample_rate": 44100,
"speed": 1,
"language": "auto",
"output_format": "pcm",
"pronunciation_dicts": [
"<string>"
]
}
'import requests
url = "https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream"
payload = {
"text": "<string>",
"voice_id": "<string>",
"sample_rate": 44100,
"speed": 1,
"language": "auto",
"output_format": "pcm",
"pronunciation_dicts": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
voice_id: '<string>',
sample_rate: 44100,
speed: 1,
language: 'auto',
output_format: 'pcm',
pronunciation_dicts: ['<string>']
})
};
fetch('https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'voice_id' => '<string>',
'sample_rate' => 44100,
'speed' => 1,
'language' => 'auto',
'output_format' => 'pcm',
'pronunciation_dicts' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"voice_id\": \"<string>\",\n \"sample_rate\": 44100,\n \"speed\": 1,\n \"language\": \"auto\",\n \"output_format\": \"pcm\",\n \"pronunciation_dicts\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"voice_id\": \"<string>\",\n \"sample_rate\": 44100,\n \"speed\": 1,\n \"language\": \"auto\",\n \"output_format\": \"pcm\",\n \"pronunciation_dicts\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"voice_id\": \"<string>\",\n \"sample_rate\": 44100,\n \"speed\": 1,\n \"language\": \"auto\",\n \"output_format\": \"pcm\",\n \"pronunciation_dicts\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": "event: chunk\ndata: <WAV_DATA>\ndone: false\n"
}{
"error": "InvalidRequest",
"message": "The 'text' field is required."
}{
"error": "Unauthorized",
"message": "Bearer token is missing or invalid."
}{
"error": "InternalServerError",
"message": "An unexpected error occurred."
}Text to Speech
Lightning v3.1 SSE
Stream speech for given text using the Lightning v3.1 SSE API
POST
/
api
/
v1
/
lightning-v3.1
/
stream
Stream speech from text (Lightning V3.1)
curl --request POST \
--url https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"voice_id": "<string>",
"sample_rate": 44100,
"speed": 1,
"language": "auto",
"output_format": "pcm",
"pronunciation_dicts": [
"<string>"
]
}
'import requests
url = "https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream"
payload = {
"text": "<string>",
"voice_id": "<string>",
"sample_rate": 44100,
"speed": 1,
"language": "auto",
"output_format": "pcm",
"pronunciation_dicts": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
voice_id: '<string>',
sample_rate: 44100,
speed: 1,
language: 'auto',
output_format: 'pcm',
pronunciation_dicts: ['<string>']
})
};
fetch('https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'voice_id' => '<string>',
'sample_rate' => 44100,
'speed' => 1,
'language' => 'auto',
'output_format' => 'pcm',
'pronunciation_dicts' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"voice_id\": \"<string>\",\n \"sample_rate\": 44100,\n \"speed\": 1,\n \"language\": \"auto\",\n \"output_format\": \"pcm\",\n \"pronunciation_dicts\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"voice_id\": \"<string>\",\n \"sample_rate\": 44100,\n \"speed\": 1,\n \"language\": \"auto\",\n \"output_format\": \"pcm\",\n \"pronunciation_dicts\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://waves-api.smallest.ai/api/v1/lightning-v3.1/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"voice_id\": \"<string>\",\n \"sample_rate\": 44100,\n \"speed\": 1,\n \"language\": \"auto\",\n \"output_format\": \"pcm\",\n \"pronunciation_dicts\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": "event: chunk\ndata: <WAV_DATA>\ndone: false\n"
}{
"error": "InvalidRequest",
"message": "The 'text' field is required."
}{
"error": "Unauthorized",
"message": "Bearer token is missing or invalid."
}{
"error": "InternalServerError",
"message": "An unexpected error occurred."
}Overview
The Lightning v3.1 SSE API provides real-time text-to-speech streaming capabilities with natural, expressive voice synthesis. This API uses Server-Sent Events (SSE) to deliver audio chunks as they’re generated, enabling low-latency audio playback without waiting for the entire audio file to process. Lightning v3.1 is a 44 kHz model that produces natural, expressive, and realistic speech, with support for voice cloning.When to Use
- Interactive Applications: Perfect for chatbots, virtual assistants, and other applications requiring immediate voice responses
- Long-Form Content: Efficiently stream audio for articles, stories, or other long-form content without buffering delays
- Voice User Interfaces: Create natural-sounding voice interfaces with minimal perceived latency
- Accessibility Solutions: Provide real-time audio versions of written content for users with visual impairments
How It Works
- Make a POST Request: Send your text and voice settings to the API endpoint
- Receive Audio Chunks: The API processes your text and streams audio back as base64-encoded chunks with 1024 byte size
- Process the Stream: Handle the SSE events to decode and play audio chunks sequentially
- End of Stream: The API sends a completion event when all audio has been delivered
Authorizations
Bearer authentication header of the form Bearer <api_key>, where <api_key> is your api key.
Body
application/json
The text to convert to speech.
The voice identifier to use for speech generation.
The sample rate for the generated audio.
Available options:
8000, 16000, 24000, 44100 The speed of the generated speech.
Required range:
0.5 <= x <= 2Language code for text normalization (e.g., how numbers, dates, and abbreviations are spelled out). Set to 'auto' for automatic language detection, or specify a language code like 'en' or 'hi'.
Available options:
auto, en, hi, ta, es The format of the output audio.
Available options:
pcm, mp3, wav, mulaw The IDs of the pronunciation dictionaries to use for speech generation.
The ID of the pronunciation dictionary to use for speech generation.
Response
Synthesized speech retrieved successfully.

