How to Install and Use the AudioStack Javascript SDK

Get started and generate your first audio πŸš€

This guide is aimed at developers who want to get up and running with AudioStack as quickly as possible. By the end of this Quick Start, you will have generated your first audio using our Javascript SDK, and know how to change voices, sound templates and mastering presets.

Step 1 - Make sure you have Node installed

For Mac/ Linux:

  • If you don't have homebrew installed already, you might need to do this too.

/bin/bash -c "$(curl -fsSL"

  • Note: If you have issues doing this in the Terminal, you can download the installer here.

brew install node

For Windows:

  • Download the installer here

Step 2 - Install AudioStack Javascript SDK

npm install @aflr/audiostack

Step 4 - Create your Javascript File

touch MyFirstAudio.js

Step 5 - Copy and Paste the Quick Start Code

Copy and paste this example code into your Javascript file, replacing the API key with your personal API key. You can access your API key from our Platform.

 * Audiostack Hello World Example
 * Add your API key on line 12 and run
 * node example.js

// Import the library
const { Audiostack } = require('@aflr/audiostack');

// Provide your api key from the Audiostack Platform
const apiKey = 'APIKEY';

 * This example demonstrates how to produce and download a file using the Audiostack API.
const example = async () => {
  // Create a new instance of Audiostack
  const AS = new Audiostack(apiKey);

  // Create a script asset with our hello text
  const script = await AS.Content.Script.create({
      'Congratulations on creating your first ever generated audio file with the AudioStack Javascript SDK.',

  // Create a speech asset using our script and the voice "sara"
  const tts = await AS.Speech.Tts.create({
    scriptId: script.scriptId,
    voice: 'sara',

  // Create a mix with our speech asset
  const mix = await AS.Production.Mix.create({
    speechId: tts.speechId,

  // Encode the file to high quality mp3
  const encode = await AS.Delivery.Encoder.encodeMix({
    productionId: mix.productionId,
    preset: 'mp3_high',

  // Download the file to the project directory
  const path = await;

  // Print the path to the file
  console.log(`File downloaded to: ${path}`);

// Run the example


Want to try a low cost voice to test out how the API works?

We keep one of our Retro voices available for this purpose - try using "Rollingthunder" to reduce the number of credits you use up for this test.


Keep your API key safe

Remember, your API key is like a password, so you should keep it safe and avoid sharing it with anyone, including in shared or public repositories.

Step 6 - Run your code

node myFirstAudio.js



You just generated your first audio asset using AudioStack.

What’s Next