# HTTP Streaming Endpoints

Realtime audio streaming using our REST API

Get started in 2 minutes with our HTTP REST API; you can also use our [Python SDK](https://docs.play.ht/reference/python-sdk) or [Nodejs SDK](https://github.com/playht/playht-nodejs-sdk) streaming.

## Get your Credentials

To use the HTTP API you will need an API Key and a User Id, you can easily generate those, [check this guide for a how-to](https://docs.play.ht/reference/authentication).

## Let's Stream

Let's stream some sentences and get the audio buffer back. Swap out the placeholders with your credentials.

```curl cURL
curl --request POST \
     --url https://api.play.ht/api/v2/tts/stream \
     --header 'X-USER-ID: <YOUR_USER_ID>' \
     --header 'AUTHORIZATION: <YOUR_API_KEY>' \
     --header 'accept: audio/mpeg' \
     --header 'content-type: application/json' \
     --output output.mp3 \
     --data '
{
  "text": "Hey, this is Jennifer from Play. Please hold on a moment, let me just um pull up your details real quick.",
  "voice": "s3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json",
  "output_format": "mp3",
  "speed": 1,
  "sample_rate": 48000,
  "voice_engine": "Play3.0"
}
'
```
```javascript Node.js
import fs from "fs";
import fetch from "node-fetch";

const url = "https://api.play.ht/api/v2/tts/stream";
const options = {
  method: "POST",
  headers: {
    accept: "audio/mpeg",
    "content-type": "application/json",
    "X-USER-ID": "<YOUR_USER_ID>",
    AUTHORIZATION: "<YOUR_API_KEY>",
  },
  body: JSON.stringify({
    voice_engine: 'Play3.0',
    text: "Hey, this is Jennifer from Play. Please hold on a moment, let me just um pull up your details real quick.",
    voice:
      "s3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json",
    output_format: "mp3",
    sample_rate: "44100",
    speed: 1,
  }),
};

const response = await fetch(url, options);
const readableStream = response.body;

// Pipe the readable stream to a writable stream, this can be a local file or any other writable stream
readableStream.pipe(fs.createWriteStream("./audio.mp3"));
```

The above example will return an audio buffer stream that you can use to save locally or stream over the network to a browser, app, or telephony system.

You can try running the above Node.js demo [here](https://replit.com/t/playai/6mbpqm/repls/HTTP-Streaming-with-PlayHT-TTS-API?embed=1).

For more details on the HTTP Streaming API, [check this guide](https://docs.play.ht/reference/api-generate-tts-audio-stream).

That is all you need to get started with realtime streaming through our HTTP API. If you need support, reach out to us at <support@play.ht> or join us on [Discord](https://discord.gg/ZGganaStFq).