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.
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) 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
https://api.segmind.com/v1/diaParameters
textrequiredstringInput 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.
"[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_koptionalintegerFilters audio tokens. Higher values = more diverse sounds, lower = more consistent. Values can be 10 to 100.
35Range: 10 - 100cfg_scaleoptionalnumberControls how strictly audio follows text. Higher = more accurate, lower = more natural. (1 to 5)
4Range: 1 - 5input_audiooptionalstring (uri)Audio file in: .wav .mp3 .flac, for voice cloning. Model will clone this voice style.
nullmax_new_tokensoptionalintegerControls audio length. Higher values = longer audio (≈86 tokens per second). Values can be 500 to 4096
3072Range: 500 - 4096seedoptionalintegerUse a seed for reproducible results. Leave blank for random output.
nullspeed_factoroptionalnumberControls playback speed. 1.0 = normal, below 1.0 = slower. Values can be 0.5 to 1.5
0.94Range: 0.5 - 1.5temperatureoptionalnumberControls randomness. Higher (1.4–2.0) = more variety, lower (0.1–1.0) = more consistency. Values can be 0.1 to 2.
1.3Range: 0.1 - 2top_poptionalnumberControls word variety. Higher values allow rarer words. Most users can leave this as is.
0.95Range: 0.1 - 1Response 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
POST /v2/diaSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- 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.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out