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

# Generate speech

POST https://api.narilabs.com/v1/audio/speech
Content-Type: application/json

Converts text to WAV or raw PCM audio.


Reference: https://docs.narilabs.com/api-reference/text-to-speech/speech/generate-speech

## Authentication

- `Authorization` header (bearer token, required) — A Nari API key created in the Dashboard.

## Request

### Body (application/json)

- `model` (enum, required) — Select Standard or Fast. Append `:free` for Free access.
  - Allowed values: `qwen3-tts`, `qwen3-tts-fast`, `qwen3-tts:free`, `qwen3-tts-fast:free`
- `input` (string, required) — Complete text. Surrounding whitespace is removed, then the result must contain 1–2,048 Unicode code points. Use [normal capitalization and punctuation](/generate-speech#prepare-your-text); all-lowercase or unpunctuated text can severely degrade speech quality.
- `voice` (enum, optional, default: english_female_professional) — The [voice](/voices) used to generate speech.
  - Allowed values: `english_female_articulate`, `english_female_professional`
- `language` (enum, optional, default: auto) — Language of the selected voice. Currently supports `en`. `auto` uses the voice’s language, rather than detecting the input language.
  - Allowed values: `auto`, `en`
- `stream` (boolean, optional, default: false) — `false` returns audio after generation finishes; `true` sends audio as it is generated. Send the complete text in one request in either mode.
- `response_format` (enum, optional, default: wav) — `wav` includes a WAV header; `pcm` returns raw audio samples. Both formats support streaming.
  - Allowed values: `wav`, `pcm`

## Response

### 200

Binary audio containing 24 kHz, signed 16-bit little-endian, mono samples. The content type is `audio/wav` for WAV or `audio/pcm` for raw PCM. Example response for `input: "Hello."` and `response_format: "wav"` (schematic): ```http HTTP/1.1 200 OK Content-Type: audio/wav x-request-id: 019c2e72-149f-733a-9579-67df595ba0f0 x-usage-input-characters: 6 [binary WAV audio] ``` Streamed WAV starts with an unknown-length header. See [Streaming audio](/streaming-audio) for playback details. A failure after streaming starts interrupts the audio without a JSON error; see [Interrupted streams](/errors#interrupted-streams).

- File download.

## Examples

### Generate speech

**Request**

```json
{
  "model": "qwen3-tts:free",
  "input": "Hello, welcome to Nari Labs.",
  "voice": "english_female_professional",
  "response_format": "wav"
}
```

**SDK Code**

```python Generate speech
import requests

url = "https://api.narilabs.com/v1/audio/speech"

payload = {
    "model": "qwen3-tts:free",
    "input": "Hello, welcome to Nari Labs.",
    "voice": "english_female_professional",
    "response_format": "wav"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Generate speech
const url = 'https://api.narilabs.com/v1/audio/speech';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"qwen3-tts:free","input":"Hello, welcome to Nari Labs.","voice":"english_female_professional","response_format":"wav"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Generate speech
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.narilabs.com/v1/audio/speech"

	payload := strings.NewReader("{\n  \"model\": \"qwen3-tts:free\",\n  \"input\": \"Hello, welcome to Nari Labs.\",\n  \"voice\": \"english_female_professional\",\n  \"response_format\": \"wav\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Generate speech
require 'uri'
require 'net/http'

url = URI("https://api.narilabs.com/v1/audio/speech")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"qwen3-tts:free\",\n  \"input\": \"Hello, welcome to Nari Labs.\",\n  \"voice\": \"english_female_professional\",\n  \"response_format\": \"wav\"\n}"

response = http.request(request)
puts response.read_body
```

```java Generate speech
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.narilabs.com/v1/audio/speech")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"qwen3-tts:free\",\n  \"input\": \"Hello, welcome to Nari Labs.\",\n  \"voice\": \"english_female_professional\",\n  \"response_format\": \"wav\"\n}")
  .asString();
```

```php Generate speech
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.narilabs.com/v1/audio/speech', [
  'body' => '{
  "model": "qwen3-tts:free",
  "input": "Hello, welcome to Nari Labs.",
  "voice": "english_female_professional",
  "response_format": "wav"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Generate speech
using RestSharp;

var client = new RestClient("https://api.narilabs.com/v1/audio/speech");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"qwen3-tts:free\",\n  \"input\": \"Hello, welcome to Nari Labs.\",\n  \"voice\": \"english_female_professional\",\n  \"response_format\": \"wav\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Generate speech
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "qwen3-tts:free",
  "input": "Hello, welcome to Nari Labs.",
  "voice": "english_female_professional",
  "response_format": "wav"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.narilabs.com/v1/audio/speech")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Stream raw PCM audio

**Request**

```json
{
  "model": "qwen3-tts-fast:free",
  "input": "Your order has shipped.",
  "voice": "english_female_articulate",
  "stream": true,
  "response_format": "pcm"
}
```

**SDK Code**

```python Stream raw PCM audio
import requests

url = "https://api.narilabs.com/v1/audio/speech"

payload = {
    "model": "qwen3-tts-fast:free",
    "input": "Your order has shipped.",
    "voice": "english_female_articulate",
    "stream": True,
    "response_format": "pcm"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Stream raw PCM audio
const url = 'https://api.narilabs.com/v1/audio/speech';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"qwen3-tts-fast:free","input":"Your order has shipped.","voice":"english_female_articulate","stream":true,"response_format":"pcm"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Stream raw PCM audio
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.narilabs.com/v1/audio/speech"

	payload := strings.NewReader("{\n  \"model\": \"qwen3-tts-fast:free\",\n  \"input\": \"Your order has shipped.\",\n  \"voice\": \"english_female_articulate\",\n  \"stream\": true,\n  \"response_format\": \"pcm\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Stream raw PCM audio
require 'uri'
require 'net/http'

url = URI("https://api.narilabs.com/v1/audio/speech")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"qwen3-tts-fast:free\",\n  \"input\": \"Your order has shipped.\",\n  \"voice\": \"english_female_articulate\",\n  \"stream\": true,\n  \"response_format\": \"pcm\"\n}"

response = http.request(request)
puts response.read_body
```

```java Stream raw PCM audio
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.narilabs.com/v1/audio/speech")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"qwen3-tts-fast:free\",\n  \"input\": \"Your order has shipped.\",\n  \"voice\": \"english_female_articulate\",\n  \"stream\": true,\n  \"response_format\": \"pcm\"\n}")
  .asString();
```

```php Stream raw PCM audio
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.narilabs.com/v1/audio/speech', [
  'body' => '{
  "model": "qwen3-tts-fast:free",
  "input": "Your order has shipped.",
  "voice": "english_female_articulate",
  "stream": true,
  "response_format": "pcm"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Stream raw PCM audio
using RestSharp;

var client = new RestClient("https://api.narilabs.com/v1/audio/speech");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"qwen3-tts-fast:free\",\n  \"input\": \"Your order has shipped.\",\n  \"voice\": \"english_female_articulate\",\n  \"stream\": true,\n  \"response_format\": \"pcm\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Stream raw PCM audio
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "qwen3-tts-fast:free",
  "input": "Your order has shipped.",
  "voice": "english_female_articulate",
  "stream": true,
  "response_format": "pcm"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.narilabs.com/v1/audio/speech")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```