TTS
TTS quickstart
Learn how to make your first Inworld TTS API request
Use the TTS Playground to try Inworld’s Text-to-Speech models, compare voices, adjust parameters, and preview instant voice clones. To build a real-time application, use the API for advanced features and integration options.
This quickstart shows how to make your first Text-to-Speech API request and generate high-quality, realistic speech from text.
These examples run locally or on your server. INWORLD_API_KEY contains the complete copied Base64 credential. Direct HTTP requests use Basic. Browser and mobile apps should use the backend token flow. For auth errors, see recovery steps.
Make your first streaming TTS API request
This quickstart walks through making your first streaming API request, which we recommend for realtime, low-latency applications.
For batch audio generation, pre-rendered content, and anywhere latency isn't critical, see Make a non-streaming request below.
Create an API key
Create an Inworld account.
In Inworld Portal, open Manage > API Keys and click Generate new key. Choose Standard, click Generate, then copy Basic (Base64) as-is; do not encode it again. Use a Standard key for direct TTS calls; Voice and Router write permissions are not needed for synthesis.


Set your API key as an environment variable.
export INWORLD_API_KEY='your-base64-api-key-here'setx INWORLD_API_KEY "your-base64-api-key-here"Prepare your first streaming request
Create a new file called inworld_stream_quickstart.py or inworld_stream_quickstart.js, confirm INWORLD_API_KEY is set in your environment, and copy the code below into the file. This example uses the WAV encoding so you can write the streamed chunks directly into a single .wav file. The WAV header arrives on the first chunk. The rest are raw PCM samples.
import { InworldTTS } from '@inworld/tts';
import fs from 'fs';
const tts = InworldTTS();
const chunks = [];
for await (const chunk of tts.stream({
text: "What a wonderful day to be a text-to-speech model! I'm super excited to show you how streaming works.",
voice: 'Ashley',
encoding: 'WAV',
sampleRate: 48000,
})) {
chunks.push(chunk);
console.log(`Received ${chunk.length} bytes`);
}
fs.writeFileSync('output_stream.wav', Buffer.concat(chunks));
console.log('Audio saved to output_stream.wav');import asyncio
from inworld_tts import InworldTTS
async def main():
tts = InworldTTS()
chunks = []
async for chunk in tts.stream(
text="What a wonderful day to be a text-to-speech model! I'm super excited to show you how streaming works.",
voice="Ashley",
encoding="WAV",
sample_rate=48000,
):
chunks.append(chunk)
print(f"Received {len(chunk)} bytes")
with open("output_stream.wav", "wb") as f:
f.write(b"".join(chunks))
print("Audio saved to output_stream.wav")
asyncio.run(main())This example uses WAV: the first chunk carries one WAV header, and the rest carry raw PCM samples. Concatenating them directly produces a valid .wav file. With LINEAR16, every chunk is a complete WAV file, so direct concatenation produces audible clicks at chunk boundaries. Strip the per-chunk RIFF headers yourself, or use WAV for direct .wav output. PCM is raw headerless sample data. Use it only if your client handles containerization or playback, such as by adding a WAV header or feeding the samples to an audio API. See Generating Audio for the full format reference.
Run the code
Run the code for Python or JavaScript. The console will print out as streamed bytes are written to the audio file.
node inworld_stream_quickstart.jspython inworld_stream_quickstart.pyYou should see a saved file called output_stream.wav. You can play this file with any audio player.
Make a non-streaming request
The synchronous endpoint is the simplest way to try Inworld TTS and works well for batch audio generation, pre-rendered content, and anywhere latency isn't critical. Assuming you've already set up your API key and installed the SDK:
Prepare your first request
For Python or JavaScript, create a new file called inworld_quickstart.py or inworld_quickstart.js. Copy the corresponding code into the file.
import { InworldTTS } from '@inworld/tts';
import fs from 'fs';
const tts = InworldTTS();
const audio = await tts.generate({
text: 'What a wonderful day to be a text-to-speech model!',
voice: 'Ashley',
});
fs.writeFileSync('output.mp3', audio);
console.log('Audio saved to output.mp3');from inworld_tts import InworldTTS
tts = InworldTTS()
tts.generate(
text="What a wonderful day to be a text-to-speech model!",
voice="Ashley",
output_file="output.mp3",
)
print("Audio saved to output.mp3")Next Steps
Now that you've tried out the TTS API, you can explore more TTS capabilities.