Speech generation endpoint handler.
POST
/v1/audio/speech
const url = 'https://example.com/v1/audio/speech';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"input":"[S1] Dia is an open weights text to dialogue model. [S2] You get full control over scripts and voices. [S1] Wow. Amazing. (laughs) [S2] Try it now on Git hub or Hugging Face.","instructions":"example","model":"nari-labs/Dia-1.6B","response_format":"mp3","speed":1,"stream_format":"example","voice":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/audio/speech \ --header 'Content-Type: application/json' \ --data '{ "input": "[S1] Dia is an open weights text to dialogue model. [S2] You get full control over scripts and voices. [S1] Wow. Amazing. (laughs) [S2] Try it now on Git hub or Hugging Face.", "instructions": "example", "model": "nari-labs/Dia-1.6B", "response_format": "mp3", "speed": 1, "stream_format": "example", "voice": "example" }'Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
Speech generation request
object
input
required
The text content to convert to speech.
string
Example
[S1] Dia is an open weights text to dialogue model. [S2] You get full control over scripts and voices. [S1] Wow. Amazing. (laughs) [S2] Try it now on Git hub or Hugging Face.instructions
Additional directions for how to speak the input.
string | null
model
The TTS model to use for audio generation.
string
Example
nari-labs/Dia-1.6Bresponse_format
The desired audio format for the generated speech.
string
speed
Playback speed between 0.25 and 4.0, default 1.0.
number | null format: double
stream_format
Raw audio (audio, default) or server-sent audio events (sse).
string | null
voice
This model’s voice, currently only default.
string | null
Responses
Section titled “ Responses ”Encoded audio or speech events
string format: binary
string format: binary
string format: binary
string format: binary
string format: binary
string format: binary
Invalid speech parameters or unsupported model capability