---
updatedAt: 2026-03-04T12:47:21.000Z
agentTools:
  projectIndex: https://docs.audiostack.ai/llms.txt
---

# BETA: Building longform audio with the story endpoint - getting AI-recommended one-shot sound effects

```python Python
import requests
import json
from time import sleep

API_KEY = "Your API Key"


story = {
    "title": "Long way home",
    "voices": [
        {
            "speakerIdentifier": "narrator",
            "alias": "alyxander",
            "voicePreset": "expressive",
            "speed": 1.0,
        }
    ],
    "sounds": {
        "soundDesigns": [
            {
                "type": "asset",
                "alias": "bare_minimum",
                "soundDesignIdentifier": "dark_ambient",
            }
        ],
        "soundEffects": [{"type": "recommender", "effectType": "oneShot"}],
    },
    "production": {"mixingPreset": "story"},
    "delivery": {"loudnessPreset": "streaming", "encoderPreset": "mp3", "public": True},
    "chapters": [
        {
            "title": "PT1",
            "narratives": [
                {
                    "foreground": [
                        {
                            "speakerIdentifier": "narrator",
                            "text": "Bob always hated the quiet. The city had a way of humming at night—pipes clicking, neon buzzing, someone laughing three floors down. That hum died the moment the woman stepped out of the alley. Silence folded around her like a held breath. She smiled at Bob as if she already knew his name. “Lost?” she asked. Bob should’ve kept walking. He had a bag of takeout going cold in his hand, a podcast paused mid-sentence in his ear. Normal life. Microwave lights and unread emails. Instead, he pulled out an earbud and answered like an idiot. “Just… taking the long way home.” Her eyes caught the streetlight and reflected it wrong. Too bright. Like glass dipped in fire. She moved fast. Not running—arriving. One second the alley was five steps away, the next her fingers were on his wrist, cool as river stones. The takeout hit the pavement. The bag split. Soy sauce bled across concrete. “Wait—” Bob said, and then her teeth were in his neck. Pain exploded and then vanished. The world narrowed to a roaring warmth, like falling asleep in a hot bath. His knees buckled. She held him up effortlessly, whispering something he couldn’t understand—words that scraped at his brain, old and hungry. Bob felt his heart fighting. Each beat weaker than the last. Thump. Thump. Stop. Panic finally hit. He tried to scream, but all that came out was a breath. She pulled back too soon. Her lips were red now. Smiling again. “Not yet,” she said, almost fondly. She sliced her own palm with a nail. Dark blood welled up, thick and slow. She pressed it to his mouth. Every instinct screamed no. His body said yes. The first swallow was fire. The second was lightning. The third shattered him. Bob’s heart gave one final, stubborn beat—and quit. He died on the pavement with his cheek in soy sauce and his phone buzzing in his pocket.",
                        }
                    ],
                    "background_1": [{"soundDesignIdentifier": "dark_ambient"}],
                }
            ],
        }
    ],
}


print(f"Calling the story endpoint with the following story:")
print(json.dumps(story, indent=4))

r = requests.post(
    url="https://v2.api.audio/creator/story",
    json={
        "story": story,
    },
    headers={"x-api-key": API_KEY},
)

story_id = r.json()["data"]["storyId"]

print(
    f"The story endpoint builds your story into a batch of audioforms and returns a storyId which you can track\n"
)

count = 0
MAX_TRIES = 60
while count < MAX_TRIES:
    get_story_response = requests.get(
        url=f"https://v2.api.audio/creator/story/{story_id}",
        headers={"x-api-key": API_KEY},
    )
    if (
        get_story_response.status_code == 202
    ):
        print(f"Story `{story_id}` is still processing... {count}")
        sleep(3)
        count += 1
    elif (
        get_story_response.status_code == 200
    ):
        audioforms = get_story_response.json()["data"]["audioforms"]
        break
    elif count == MAX_TRIES - 1:
        print(f"Story `{story_id}` has timed out after 60 tries.")
    else:
        print(f"Story failed: {get_story_response.text}")
        break


print(f"The story endpoint returns an array of audioforms:\n")
print(json.dumps(audioforms, indent=4))

for idx, audioform in enumerate(audioforms):
    audio_url = audioform["delivery"]["uri"]
    print(f"\nListen to your chapter {idx+1} at : {audio_url}.")

```

```json Response Example
{"success":true}
```

# Setup

<!-- python@1-5 -->



# Define the story JSON

<!-- python@8-46 -->

The story JSON is a complete and scalable format for defining your longform audio production.

It covers the definition of voices, music and sound effects and the narrative of your story.

In this simple example, we start with a single voice story. We have selected the voice and background music from AudioStack's voice and sound libraries.

# Enable AI sound effects recommendations

<!-- python@26 -->

Here instead of selecting specific sound effects, we define a recommender which will read the story and find and place suitable sound effects throughout.

# Call the story endpoint

<!-- python@49-60 -->

We send the story JSON to the story endpoint. This endpoint validated the input, creates a batch of audioforms and submits them for processing. We get an audioform batch ID in the response.

# Poll the story

<!-- python@62-94 -->

You can track the progress of your story by polling with the storyId and checking if it is complete.

# Listen to the output audio

<!-- python@96-98 -->

Now let's listen to the final audio. Our sound effect recommender has picked and placed one-shot sound effects throughout our story - bring it to the next level.