> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://murf.ai/api/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://murf.ai/api/docs/_mcp/server.

# Synthesize or non-streaming (Gen2)

Synthesize (Gen 2) sends the full text in one request and returns a file URL when generation finishes. Use it for studio voiceover: ads, narration, e-learning, and other offline playback where you need styles, pause tags, audio duration, or variations.

> **Note**
>
> Pass `modelVersion: "GEN2"` in the request. Host is `https://api.murf.ai`.
> Do not send Synthesize calls to the streaming host.

Use [HTTP streaming](/api/docs/text-to-speech/streaming) when you need audio chunks in real time, or [WebSocket](/api/docs/text-to-speech/web-sockets) when text arrives in pieces.

#### [Streaming (Falcon 2.1)](/api/docs/text-to-speech/streaming)

Send the complete utterance in one request and play audio as Falcon 2.1
generates it.

## Quickstart

Generate an audio file from text with `POST /v1/speech/generate`. The response includes a link to the file. The file remains available for 72 hours.

#### Getting Started

Generate an API key [here](https://murf.ai/api/dashboard?utm_source=murf_api_docs). Store the key in a secure location, as you'll need it to authenticate your requests. You can optionally save the key as an environment variable in your terminal.

**`macOS / Linux`**

```bash title="macOS / Linux"
# Export an environment variable on macOS or Linux systems
export MURF_API_KEY="your_api_key_here"
```

**`Windows`**

```bash title="Windows"
# Export an environment variable in PowerShell
setx MURF_API_KEY "your_api_key_here"
```

#### Initiating a Synthesize Request

#### Python SDK

### Install the Python SDK

```bash
pip install murf
```

### Make the API call

**`Python SDK`**

```python title="Python SDK"
from murf import Murf

client = Murf()
res = client.text_to_speech.generate(
    text="There is much to be said",
    voice_id="Terrell",
    locale="en-US",
    model_version="GEN2",
)
print(res.audio_file)
```

#### JavaScript

**`JavaScript`**

```javascript title="JavaScript"
import axios from "axios";

const data = {
  text: "There is much to be said",
  voiceId: "Terrell",
  locale: "en-US",
  modelVersion: "GEN2",
};

axios
  .post("https://api.murf.ai/v1/speech/generate", data, {
    headers: {
      "Content-Type": "application/json",
      Accept: "application/json",
      "api-key": process.env.MURF_API_KEY,
    },
  })
  .then((response) => {
    console.log(response.data.audioFile);
  })
  .catch((error) => {
    console.error("Error:", error);
  });
```

#### curl

**`curl`**

```curl title="curl"
curl -X POST https://api.murf.ai/v1/speech/generate \
     -H "api-key: $MURF_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
  "text": "There is much to be said",
  "voiceId": "Terrell",
  "locale": "en-US",
  "modelVersion": "GEN2"
}'
```

A link to the audio file is returned in the response. Download it and use it wherever you need it. The file is available for 72 hours after generation.

## Voices

Pick a voice from the [Gen 2 list in the Voice Library](/api/docs/voices-styles/voice-library#gen2-supported-voices). Gen 2 has 150+ voices and 20+ speaking styles. Gen 2 voices are for studio voiceover.

## Endpoint

```
https://api.murf.ai/v1/speech/generate
```

Each in-flight generate request counts toward [Synthesize (Gen 2) concurrency](/api/docs/resources/rate-limits#concurrency-for-synthesize-gen-2). A request can include up to 3,000 characters. Split longer scripts across multiple calls.

The machine-readable request and response are in the [Synthesize Speech API reference](/api/docs/api-reference/text-to-speech/generate).

## Speech customization

Voice, locale, speed, and pitch are available. Style control, custom pause tags, audio duration, and variations are Synthesize (Gen 2) only. Set pronunciations with `pronunciationDictionary`.

See [Speech Customization](/api/docs/text-to-speech/speech-customization) for ranges and samples.

## Supported output formats

The default output format is **WAV**. Set `format`, `channelType`, and `sampleRate` in the request. The API supports stereo and mono, and sample rates of 8000, 24000, 44100, and 48000 Hz.

| Format   | Description                                                |
| -------- | ---------------------------------------------------------- |
| **WAV**  | Uncompressed audio, useful when you want to skip decoding. |
| **MP3**  | Compressed audio, widely supported when file size matters. |
| **FLAC** | Lossless compressed audio.                                 |
| **ALAW** | Telephony format.                                          |
| **ULAW** | Telephony format.                                          |
| **OGG**  | Compressed format for web playback.                        |
| **PCM**  | Raw, uncompressed samples.                                 |

**`Python SDK`**

```python title="Python SDK"
from murf import Murf

client = Murf()
res = client.text_to_speech.generate(
    text="Hi, How are you doing today?",
    voice_id="Julia",
    locale="en-US",
    model_version="GEN2",
    format="MP3",
    channel_type="STEREO",
    sample_rate=44100,
)
print(res.audio_file)
```

**`JavaScript`**

```javascript title="JavaScript"
import axios from "axios";

const data = {
  text: "Hi, How are you doing today?",
  voiceId: "Natalie",
  locale: "en-US",
  modelVersion: "GEN2",
  format: "MP3",
  channelType: "MONO",
  sampleRate: 44100,
};
axios
  .post("https://api.murf.ai/v1/speech/generate", data, {
    headers: {
      "Content-Type": "application/json",
      Accept: "application/json",
      "api-key": process.env.MURF_API_KEY,
    },
  })
  .then((response) => {
    console.log(response.data.audioFile);
  });
```

**`curl`**

```curl title="curl"
curl -X POST https://api.murf.ai/v1/speech/generate \
     -H "api-key: $MURF_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "locale": "en-US",
  "modelVersion": "GEN2",
  "format": "MP3",
  "channelType": "MONO",
  "sampleRate": 44100
}'
```

> **Warning**
>
> ULAW and ALAW formats only support mono channel type and a sample rate of 8000
> Hz. If you specify a different channel type or sample rate, the API will
> default to the supported values.

### Base64 encoding

Base64 encoding is Synthesize (Gen 2) only. Set `encodeAsBase64` to `true` to receive the audio inline instead of a file URL. That also enables zero retention of audio data on Murf's servers.

**`Python SDK`**

```python title="Python SDK"
from murf import Murf

client = Murf()
res = client.text_to_speech.generate(
    text="Hi, How are you doing today?",
    voice_id="Julia",
    model_version="GEN2",
    encode_as_base_64=True,
)
print(res.encoded_audio)
```

**`JavaScript`**

```javascript title="JavaScript"
import axios from "axios";

const data = {
  text: "Hi, How are you doing today?",
  voiceId: "Natalie",
  modelVersion: "GEN2",
  encodeAsBase64: true,
};
axios
  .post("https://api.murf.ai/v1/speech/generate", data, {
    headers: {
      "Content-Type": "application/json",
      Accept: "application/json",
      "api-key": process.env.MURF_API_KEY,
    },
  })
  .then((response) => {
    console.log(response.data.encodedAudio);
  });
```

**`curl`**

```curl title="curl"
curl -X POST https://api.murf.ai/v1/speech/generate \
     -H "api-key: $MURF_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "modelVersion": "GEN2",
  "encodeAsBase64": true
}'
```

The response includes the audio encoded in Base64:

**`Response`**

```json title="Response"
{
  ...,
  "encodedAudio": "U29tZSB0ZXh0IHNob3cgd2l0aCB0aGF0Lg==...",
  ...
}
```

### gzip

gzip is Synthesize (Gen 2) only. Include `gzip` in the `accept-encoding` header. This is especially useful with Base64 audio.

**`Python SDK`**

```python title="Python SDK"
from murf import Murf

client = Murf()

client.text_to_speech.generate(
    text="Hi, How are you doing today?",
    voice_id="Natalie",
    model_version="GEN2",
    encode_as_base_64=True,
    request_options={
        "additional_headers": {
            "accept-encoding": "gzip"
        }
    },
)
```

**`JavaScript`**

```javascript title="JavaScript"
import axios from "axios";

const data = {
  text: "Hi, How are you doing today?",
  voiceId: "Natalie",
  modelVersion: "GEN2",
};

axios
  .post("https://api.murf.ai/v1/speech/generate", data, {
    headers: {
      "api-key": process.env.MURF_API_KEY,
      "Content-Type": "application/json",
      "accept-encoding": "gzip",
    },
  })
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error("Error:", error);
  });
```

**`curl`**

```curl title="curl"
curl -X POST https://api.murf.ai/v1/speech/generate \
     -H "api-key: $MURF_API_KEY" \
     -H "Content-Type: application/json" \
     -H "accept-encoding: gzip" \
     -d '{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "modelVersion": "GEN2"
}'
```

## Next Steps

#### [Speech Customization](/api/docs/text-to-speech/speech-customization)

Set voice, locale, style, pauses, duration, and pronunciation.

#### [Voice Library](/api/docs/voices-styles/voice-library#gen2-supported-voices)

Pick a Gen 2 voice ID for studio voiceover.

#### [API Reference](/api/docs/api-reference/text-to-speech/generate)

Full request and response schema for Synthesize Speech.

#### [Rate Limits & Concurrency](/api/docs/resources/rate-limits#concurrency-for-synthesize-gen-2)

Concurrency for Synthesize (Gen 2).

## FAQs

#### What is Gen 2?

Gen 2 is Murf's studio text-to-speech model. It returns a file URL from
[Synthesize Speech](/api/docs/api-reference/text-to-speech/generate) and
supports 150+ voices and 20+ speaking styles. See the
[Gen 2 model page](/api/docs/text-to-speech-models/gen-2).

#### Who should use Synthesize (Gen 2)?

Use Synthesize when you want a finished file for ads, narration, e-learning,
or other offline playback, and when you need styles, pause tags, audio
duration, or variations. Use [HTTP streaming](/api/docs/text-to-speech/streaming)
or [WebSocket](/api/docs/text-to-speech/web-sockets) for realtime agents.

#### How do I enable Gen 2?

Pass `modelVersion: "GEN2"` (Python SDK: `model_version="GEN2"`) on
`POST /v1/speech/generate`.

#### What features are supported?

Voice, locale, speed, and pitch are available, plus styles, custom pause
tags, audio duration, variations, and `pronunciationDictionary`. See
[Speech Customization](/api/docs/text-to-speech/speech-customization).

#### What audio format will this support?

Synthesize returns **MP3**, **FLAC**, **WAV**, **ALAW**, **ULAW**, **OGG**,
or **PCM**. Inline Base64 audio and gzip are Synthesize only.

#### How long is the audio file available?

The returned URL stays available for 72 hours after generation. Use Base64
encoding if you need the audio inline with no object-storage retention.