SDKs

Official Python and TypeScript SDKs for the Sync lip sync API. Install, authenticate, and start generating lip synced videos.

Sync provides official lip sync SDK libraries for Python and TypeScript. Both SDKs wrap the Sync API and give you typed methods for creating generations, polling status, and retrieving results — so you can add video lip sync integration to your app in minutes.

Installation

Requires Python 3.8+.

$pip install syncsdk

Requires Node.js 18+.

$npm i @sync.so/sdk

Authentication

Both SDKs read your API key from the SYNC_API_KEY environment variable automatically. Set it before running your code:

$export SYNC_API_KEY="your-api-key"

You can create an API key from the API Keys page in your dashboard. See the Authentication guide for more details and security best practices.

Quick Start

The example below creates a lip sync generation and polls until the result is ready.

1import time
2from sync import Sync
3from sync.common import Audio, Video
4
5sync = Sync()
6
7# Create a lipsync generation
8response = sync.generations.create(
9 input=[
10 Video(url="https://assets.sync.so/docs/example-video.mp4"),
11 Audio(url="https://assets.sync.so/docs/example-audio.wav"),
12 ],
13 model="lipsync-2",
14)
15
16job_id = response.id
17print(f"Job submitted: {job_id}")
18
19# Poll until complete
20generation = sync.generations.get(job_id)
21while generation.status not in ["COMPLETED", "FAILED", "REJECTED"]:
22 time.sleep(10)
23 generation = sync.generations.get(job_id)
24
25if generation.status == "COMPLETED":
26 print(f"Output: {generation.output_url}")
27else:
28 print(f"Generation {job_id} failed")
1import { SyncClient } from "@sync.so/sdk";
2
3const sync = new SyncClient();
4
5async function main() {
6 // Create a lipsync generation
7 const response = await sync.generations.create({
8 input: [
9 { type: "video", url: "https://assets.sync.so/docs/example-video.mp4" },
10 { type: "audio", url: "https://assets.sync.so/docs/example-audio.wav" },
11 ],
12 model: "lipsync-2",
13 });
14
15 const jobId = response.id;
16 console.log(`Job submitted: ${jobId}`);
17
18 // Poll until complete
19 let generation = await sync.generations.get(jobId);
20 while (!["COMPLETED", "FAILED", "REJECTED"].includes(generation.status)) {
21 await new Promise((r) => setTimeout(r, 10000));
22 generation = await sync.generations.get(jobId);
23 }
24
25 if (generation.status === "COMPLETED") {
26 console.log(`Output: ${generation.outputUrl}`);
27 } else {
28 console.log(`Generation ${jobId} failed`);
29 }
30}
31
32main();

For a full walkthrough with error handling, see the Quickstart guide.

When should I use the SDK vs the raw API?

Use the SDK when you want typed methods, automatic authentication, and less boilerplate. Use the raw REST API when you need full control over HTTP requests, work in a language without an official SDK, or want to minimize dependencies.

SDKRaw REST API
AuthenticationAutomatic via SYNC_API_KEY env varManual x-api-key header on every request
Type safetyFull type hints (Python) and TypeScript typesNone — you parse JSON responses yourself
BoilerplateMinimal — one-liner to create a generationBuild HTTP requests, parse responses, handle headers
Language supportPython 3.8+ and TypeScript/Node.js 18+Any language with an HTTP client
Async supportPython AsyncSync client, TypeScript native asyncBuild your own async handling
File uploadscreate_with_files() helper methodMultipart form-data via POST /v2/generate/upload
Cost estimationestimate_cost() typed methodPOST /v2/generate/estimate-cost

Feature comparison

Both SDKs cover the full Sync API surface with equivalent functionality:

FeaturePython SDKTypeScript SDK
Packagepip install syncsdknpm i @sync.so/sdk
Min runtimePython 3.8+Node.js 18+
Client classSync() / AsyncSync()SyncClient()
Create generationsync.generations.create(...)sync.generations.create(...)
File uploadsync.generations.create_with_files(...)POST /v2/generate/upload
Poll statussync.generations.get(id)sync.generations.get(id)
List generationssync.generations.list()sync.generations.list()
Cost estimationsync.generations.estimate_cost(...)sync.generations.estimateCost(...)
Batch processingsync.batch.create(...)sync.batch.create(...)
Asset managementsync.assets.list() / sync.assets.get(id)sync.assets.list()
Async supportAsyncSync client for asyncioNative async/await
Error classApiError (status_code, body)SyncError (statusCode, body)

Error handling overview

Both SDKs raise typed exceptions for API errors. Wrap your calls in try/except (Python) or try/catch (TypeScript) and inspect the status code to decide how to respond:

Status CodeMeaningRecommended Action
400Invalid input (bad URL, unsupported format)Fix input parameters before retrying
401Missing or invalid API keyCheck that SYNC_API_KEY is set correctly
402Feature requires a higher planUpgrade at sync.so
429Rate limit or concurrency limit exceededBack off and retry with exponential delay
500+Transient server errorRetry with exponential backoff

For production systems, implement retry logic with exponential backoff for 429 and 5xx errors. See the Python SDK Guide and TypeScript SDK Guide for code examples.

For the complete list of methods, parameters, and response types, see the API Reference.