Skip to main content
POST
Stream Speech

Authorizations

x-api-key
string
header
required

HeyGen API key. Obtain from your HeyGen dashboard.

Body

application/json
voice_id
string
required

Identifier of the voice used for speech synthesis.

Minimum string length: 1
text
string
required

Plain text to synthesize. SSML and break tags are not supported.

Required string length: 1 - 5000
language
string
required

Language code used for speech synthesis, such as en.

Minimum string length: 1
seed
integer | null

Optional best-effort deterministic generation seed.

Required range: 0 <= x <= 4294967295
with_timestamps
boolean
default:false

Whether to include word-timestamp events in the response stream.

Response

Server-Sent Events stream. Each data: frame contains an audio, alignment, or terminal error event; a clean stream terminates with data: [DONE].

One JSON event carried by the speech SSE stream.

type
string
required

Event type.

Allowed value: "audio"
part_index
integer
required

Zero-based sequence number of this audio part.

Required range: x >= 0
audio
string
required

Base64-encoded standalone WAV audio part.