Dia (Text to Speech) Serverless API

Dia by Nari Labs is an advanced open-weights TTS model that brings scripts to life with natural speech, emotions, and nonverbal cues. Easily control tone, voice, and delivery. Great alternative to ElevenLabs.

~89.17s
POST /v2/dia · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5# Async (v2): submit to the queue and block until COMPLETED.
 6# run() returns the final result dict (600s deadline, 1.0s poll by default).
 7result = segmind.run(
 8    "dia",
 9    text="[S1] Segmind lets you build powerful image and video workflows — no code needed. \n [S2] Over 200 open and closed models. Just drag, drop, and deploy. \n [S1] Wait, seriously? Even custom models? \n [S2] Yup. Even fine-tuned ones. (chuckles) \n [S1] That's wild. I’ve spent weeks writing code for this. \n [S2] Now you can do it in minutes. Go try Segmind on the cloud. \n  [S1] I'm sold. Let’s go. (laughs)",
10    top_p=0.95,
11    cfg_scale=4,
12    temperature=1.3,
13    input_audio="https://segmind-resources.s3.amazonaws.com/input/7d11a77b-366c-406e-b6af-eefaec4f8574-fa3123db-56cf-4212-9cc9-ebc49e692202-04fc4d16-25df-44cb-9b7c-37aa7543e6d2.wav",
14    speed_factor=0.94,
15    max_new_tokens=3072,
16    cfg_filter_top_k=35,
17)
18print(result["status"])                      # COMPLETED
19print(result.get("output"))                  # model output (e.g. media URL)
20print(result["metrics"]["inference_time"])   # server compute seconds
21
22# --- Or submit + poll manually (track request_id, control the cadence) ---
23from segmind import SegmindClient, InferenceFailed, InferenceTimeout
24
25client = SegmindClient()                      # reads SEGMIND_API_KEY
26payload = {
27    "text": "[S1] Segmind lets you build powerful image and video workflows — no code needed. \n [S2] Over 200 open and closed models. Just drag, drop, and deploy. \n [S1] Wait, seriously? Even custom models? \n [S2] Yup. Even fine-tuned ones. (chuckles) \n [S1] That's wild. I’ve spent weeks writing code for this. \n [S2] Now you can do it in minutes. Go try Segmind on the cloud. \n  [S1] I'm sold. Let’s go. (laughs)",
28    "top_p": 0.95,
29    "cfg_scale": 4,
30    "temperature": 1.3,
31    "input_audio": "https://segmind-resources.s3.amazonaws.com/input/7d11a77b-366c-406e-b6af-eefaec4f8574-fa3123db-56cf-4212-9cc9-ebc49e692202-04fc4d16-25df-44cb-9b7c-37aa7543e6d2.wav",
32    "speed_factor": 0.94,
33    "max_new_tokens": 3072,
34    "cfg_filter_top_k": 35,
35}
36job = client.submit_async("dia", **payload)
37print(job.request_id)                         # available immediately
38try:
39    result = job.wait(timeout=600, interval=1.0)
40except InferenceTimeout as e:
41    print("still running:", e.request_id)
42except InferenceFailed as e:
43    print("failed:", e.detail)

API Endpoint

POSThttps://api.segmind.com/v1/dia

Parameters

textrequired
string

Input text for speech generation. Use [S1], [S2] for speakers and ( ) for actions like (laughs) or (whispers). Verbal tags will be recognized, but might result in unexpected output.

Default: "[S1] Segmind lets you build powerful image and video workflows — no code needed. \n [S2] Over 200 open and closed models. Just drag, drop, and deploy. \n [S1] Wait, seriously? Even custom models? \n [S2] Yup. Even fine-tuned ones. (chuckles) \n [S1] That's wild. I’ve spent weeks writing code for this. \n [S2] Now you can do it in minutes. Go try Segmind on the cloud. \n [S1] I'm sold. Let’s go. (laughs)"
cfg_filter_top_koptional
integer

Filters audio tokens. Higher values = more diverse sounds, lower = more consistent. Values can be 10 to 100.

Default: 35Range: 10 - 100
cfg_scaleoptional
number

Controls how strictly audio follows text. Higher = more accurate, lower = more natural. (1 to 5)

Default: 4Range: 1 - 5
input_audiooptional
string (uri)

Audio file in: .wav .mp3 .flac, for voice cloning. Model will clone this voice style.

Default: null
max_new_tokensoptional
integer

Controls audio length. Higher values = longer audio (≈86 tokens per second). Values can be 500 to 4096

Default: 3072Range: 500 - 4096
seedoptional
integer

Use a seed for reproducible results. Leave blank for random output.

Default: null
speed_factoroptional
number

Controls playback speed. 1.0 = normal, below 1.0 = slower. Values can be 0.5 to 1.5

Default: 0.94Range: 0.5 - 1.5
temperatureoptional
number

Controls randomness. Higher (1.4–2.0) = more variety, lower (0.1–1.0) = more consistency. Values can be 0.1 to 2.

Default: 1.3Range: 0.1 - 2
top_poptional
number

Controls word variety. Higher values allow rarer words. Most users can leave this as is.

Default: 0.95Range: 0.1 - 1

Response Type

Returns: Audio

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/dia

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out