Create a stream via the API or SDK to get a stream key (for broadcasters) and a playback ID (for viewers). The example below uses the Create Stream API.
Create a stream with the SDK
import { Livepeer } from "livepeer";
const livepeer = new Livepeer({ apiKey: process.env.LIVEPEER_API_KEY });
const { data } = await livepeer.stream.create({
name: "my-stream",
});
console.log("Stream key:", data.streamKey);
console.log("Playback ID:", data.playbackId);
from livepeer import Livepeer
livepeer = Livepeer(api_key=os.environ["LIVEPEER_API_KEY"])
response = livepeer.stream.create({"name": "my-stream"})
if response.stream:
print("Stream key:", response.stream.stream_key)
print("Playback ID:", response.stream.playback_id)
package main
import (
"github.com/livepeer/livepeer-go"
"context"
)
func main() {
client := livepeer.New(livepeer.WithAPIKey(os.Getenv("LIVEPEER_API_KEY")))
ctx := context.Background()
res, err := client.Stream.Create(ctx, livepeer.StreamCreationPayload{
Name: livepeer.String("my-stream"),
})
if err != nil {
log.Fatal(err)
}
if res.Stream != nil {
fmt.Println("Stream key:", *res.Stream.StreamKey)
fmt.Println("Playback ID:", *res.Stream.PlaybackId)
}
}
Use the stream key and playback ID
- Stream key — Give this to the broadcaster. They enter it in OBS (or another encoder) or use it for in-browser WebRTC broadcast. Keep the stream key secret; anyone with it can push video to the stream.
- Playback ID — Use this in your app to play the stream (e.g. with the Livepeer Player or the Playback Info API). You can expose the playback ID to viewers.
Next steps
Last modified on February 18, 2026