Sound effects
Batch Generate Sound Effects with SFX v3 and Python
Download Python and CSV examples for the direct ElevenLabs API. Preview batches, cap requests and duration, protect files and handle uncertain submissions.
Batch generation is useful after you have approved a small set of prompts. This tutorial provides a downloadable Python example that sends one request at a time to the direct ElevenLabs SFX v3 API. It uses an ElevenLabs key and account billing, not this website’s user key or credits.
The script defaults to a local preview. No paid generation was performed to create this article, and the sample CSV is a plan rather than an audio demonstration. For the distinction between the direct and platform APIs, start with the API guide.
Download the example and CSV
Save these files into the same local directory:
Use Python 3; the example uses only its standard library. You do not need to install an SDK or paste a key into the source code. Read the script before executing it, and provide ELEVENLABS_API_KEY through your server environment only when you intend to submit requests.
Prepare the input before calling the API
The example CSV contains three original prompt suggestions:
id,prompt,duration_seconds
drawer_close_01,"A small wooden drawer closes once with a soft dry tap.",3
gravel_step_01,"One firm boot step into loose gravel, followed by a few small stones settling.",4
ui_confirm_01,"A tiny muted click followed by one soft rounded bell tone with a quick decay.",3
Use a unique ID containing letters, digits, underscores or hyphens; it becomes the filename. IDs are checked without case sensitivity so names remain distinct on common filesystems. Quote CSV fields that contain commas. Keep each prompt focused on a sound you can evaluate.
The example requires an explicit duration for every row and validates the current direct endpoint’s 0.5–30 second range. It fixes the model to eleven_text_to_sound_v3 and requests MP3 output. Provider information was checked on November 9, 2026.
Preview the entire batch
From the directory containing the two downloads, run:
python3 batch_generate.py prompts.csv --max-requests 3 --max-seconds 12
This prints three planned requests totaling ten specified seconds. It does not read an API key, send network requests or create output files. The script validates all rows, duplicate IDs, duration totals and conflicting result files before it starts a batch.
The default caps are ten requests and sixty specified seconds. These are workload limits, not a monetary ceiling or a price quote. Check your actual provider pricing, allowance and account conditions before choosing a larger cap. Do not replace them with an assumption that every generated file will be useful.
Submit only after reviewing the plan
When your ElevenLabs environment key is configured and you have reviewed the possible cost, add the execution flag:
python3 batch_generate.py prompts.csv --out sfx-output \
--max-requests 3 --max-seconds 12 --execute
The script sends requests sequentially. Before each POST, it creates an exclusive ID.submitted.json receipt containing the requested parameters. Successful audio is saved as ID.mp3, and the receipt is marked complete. The key is not written to the receipt or printed.
It accepts an audio response before writing a result file. A missing key, invalid CSV or pre-existing result/receipt prevents execution; an HTTP failure, network problem or unexpected response stops the batch. There are no automatic POST retries.
Handle interruption and continue deliberately
A timeout does not prove that the provider rejected the request or charged nothing. Keep the receipt and inspect the provider’s request history before deciding to try again. The script does not claim provider-level idempotency or automatic reconciliation.
Re-running the original CSV against the same output directory stops if any listed ID already has a result or receipt. It does not silently overwrite or skip files. To continue after reviewing an interrupted run, prepare a new CSV containing only untouched jobs. Do not remove a submission marker merely to force an uncertain request through again.
For a deliberate additional variation, assign a new ID and budget it as a new request. If the provider returns a limit or busy response, review its guidance and wait before any later attempt; this example does not launch parallel retries.
Review outputs before scaling up
Audition the first small batch in the target project. Record whether events are recognizable, tails fit and editing is still needed. Preserve sources and receipts locally; they contain prompt text and should not be published if the brief is private.
Keep approval separate from file creation. A valid audio response is not proof of creative quality or release permission. Use the game workflow, video workflow and commercial-use guide before delivery.
If you later use this website’s task API, do not point this script at it: that API returns JSON tasks and uses a different contract. Follow the API guide and open the audio workspace. For turning a script into an approved batch, continue with the AI workflow guide.