POST
POST /v1/sound-generation — ElevenLabs API
ElevenLabs APISound Generation
- Base URL
- https://api.elevenlabs.io
- Auth
- xi-api-key: <ELEVENLABS_API_KEY>
- Last verified
- 2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 220 tokens · Vary: Accept
→ 220 tokens · Vary: Accept
Critical gotchas
Authentication uses the non-standard xi-api-key header, not Authorization: Bearer. Sending a Bearer token returns HTTP 401.
Text-to-speech responses are raw binary audio, not JSON. Write the body to a file (--output speech.mp3) rather than parsing it.
cURL
curl -X POST 'https://api.elevenlabs.io/v1/sound-generation?output_format=mp3_44100_128&enable_logging=true' \ -H "xi-api-key: $ELEVENLABS_API_KEY" \ -H 'Content-Type: application/json' \ -d '{ "text": "example-text", "loop": false, "duration_seconds": 0, "prompt_influence": 0.3, "model_id": "eleven_text_to_sound_v2"}'
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| output_format | query | string | No | Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM and WAV formats with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. |
| enable_logging | query | boolean | No | When enable_logging is set to false zero retention mode will be used for the request. Zero retention mode may only be used by enterprise customers. |
| text | body | string | Yes | The text that will get converted into a sound effect. |
| loop | body | boolean | No | Whether to create a sound effect that loops smoothly. Only available for the 'eleven_text_to_sound_v2 model'. |
| duration_seconds | body | number | No | The duration of the sound which will be generated in seconds. Must be at least 0.5 and at most 30. If set to None we will guess the optimal duration using the prompt. Defaults to None. |
| prompt_influence | body | number | No | A higher prompt influence makes your generation follow the prompt more closely while also making generations less variable. Must be a value between 0 and 1. Defaults to 0.3. |
| model_id | body | string | No | Request body field model_id. |
Response 200 OK
"binary"Get a free ElevenLabs API key → sponsored
Affiliate link - we may earn a commission, at no extra cost to you.