> ## Documentation Index
> Fetch the complete documentation index at: https://gladia-95-remi-zdr-update.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Audio chunk

> Payload definition for sending an audio chunk.

When streaming audio to Gladia API, you can stream it either as binary frames or as JSON messages containing a base64-encoded chunk.

## Send audio chunks

There are two ways to stream audio:

1. As binary WebSocket frames:

```ts theme={null}
// `buffer` is a Node.js Buffer / Uint8Array with raw audio bytes
socket.send(buffer);
```

2. As JSON, base64-encoding the audio chunk

```ts theme={null}
socket.send(
	JSON.stringify({
		type: "audio_chunk",
		data: {
			chunk: buffer.toString("base64"),
		},
	})
);
```

## Tips

* Keep chunks reasonably sized (≃ 100ms) for low latency.
* Make sure your chunks are contiguous audio frames with the same format as configured during session initiation.
* On recoverable disconnects, reconnect using the same `url` to continue streaming.
