Integrate Livepeer AI and video APIs via official SDKs in TypeScript, Python, and Go. Covers authentication, error handling, retries, and SDK vs direct REST trade-offs.
Livepeer provides two SDK families. The Studio SDK (livepeer) wraps the full Studio API: livestreams, video assets, webhooks, access control, and AI inference. The AI SDK (@livepeer/ai) wraps AI inference endpoints only. Both authenticate with a Bearer token from the Studio dashboard.
import Livepeer from '@livepeer/ai';const client = new Livepeer({ httpBearer: process.env.LIVEPEER_API_KEY,});// Default gateway: https://dream-gateway.livepeer.cloud// For production: configure Studio gateway URL
All nine batch pipelines share the same pattern: call the generate namespace, pass a request body, receive a typed response.
TypeScript
Python
Go
// Text to imageconst result = await client.generate.textToImage({ prompt: 'a photorealistic mountain lake at dawn', modelId: 'SG161222/RealVisXL_V4.0_Lightning', width: 1024, height: 1024,});// result.imageResponse.images[0].url// Image to imageconst img2img = await client.generate.imageToImage({ image: fs.createReadStream('./input.jpg'), prompt: 'convert to oil painting style', modelId: 'timbrooks/instruct-pix2pix', strength: 0.7,});// LLM (OpenAI-compatible format)const llmResult = await client.generate.llm({ messages: [{ role: 'user', content: 'Explain blockchain in one sentence.' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct',});
from livepeer.models import components# Text to imageresult = client.generate.text_to_image( request=components.TextToImageParams( prompt='a photorealistic mountain lake at dawn', model_id='SG161222/RealVisXL_V4.0_Lightning', width=1024, height=1024, ))# result.image_response.images[0].url# Audio to text (Whisper)with open('audio.mp3', 'rb') as f: transcription = client.generate.audio_to_text( request=components.BodyGenAudioToText( audio=components.Audio(content=f.read(), file_name='audio.mp3'), model_id='openai/whisper-large-v3', ) )
import "github.com/livepeer/livepeer-go/models/components"prompt := "a photorealistic mountain lake at dawn"modelID := "SG161222/RealVisXL_V4.0_Lightning"width := int64(1024)height := int64(1024)result, err := client.Generate.TextToImage(ctx, components.TextToImageParams{ Prompt: prompt, ModelID: &modelID, Width: &width, Height: &height, },)
Both SDKs support configurable retry policies with exponential backoff. Cold model load times range from 30 seconds to several minutes — configure retries accordingly.
Use the SDK unless you have a specific reason not to. The SDK adds typed responses, automatic retry logic, request serialisation, and error classification over raw HTTP.Direct REST is appropriate when you are working in a language without an official SDK, integrating with a platform that already manages HTTP (e.g., curl in a shell pipeline), or need fine-grained control over request headers and serialisation.