Python SDK Guide
The Sync Python SDK (syncsdk) wraps the Sync REST API with typed methods for Python 3.8+. It provides methods for creating lip sync generations, polling for results, estimating costs, and managing assets.
Source code: sync-python-sdk on GitHub
Installation
Requires Python 3.8+. Install from PyPI:
We recommend using a virtual environment to avoid dependency conflicts:
Authentication
The SDK reads your API key from the SYNC_API_KEY environment variable automatically:
You can also pass the key directly:
Create an API key from the API Keys page in your dashboard. See the Authentication guide for security best practices.
Quick Start
Create a lip sync generation, poll until it finishes, and print the output URL.
Run it:
Core Operations
Creating Generations
Video + Audio
The most common use case. Provide a video and an audio file, and Sync generates matching lip movements.
Video + Text-to-Speech
Use the built-in ElevenLabs integration to go straight from text to lip-synced video. No separate TTS step needed.
The script field has a maximum of 5,000 characters per generation. For longer scripts, split them into segments. See the Text-to-Speech Lip Sync Guide for details.
Polling vs Webhooks
Polling is the simplest approach. Call generations.get() in a loop until the status is terminal:
Webhooks are better for production. Pass a webhook_url when creating the generation, and Sync sends a POST request when the job finishes:
See the Webhooks guide for payload format and signature verification.
Listing Generations
Retrieve your recent generations. Optionally filter by status:
Getting Generation Details
Fetch the full details of a single generation by ID:
Cost Estimation
Estimate the cost before submitting a generation:
Working with Files
URL Inputs
The simplest approach — pass publicly accessible URLs for your video and audio:
Asset IDs
If you have uploaded files to the Sync media library (via the dashboard or Assets API), reference them by asset ID:
File Uploads
Upload local files directly using the multipart endpoint:
File uploads are limited to 20MB per file. For larger files, host them at a public URL and use the URL-based input instead.
Browsing Assets
List and retrieve assets from your media library:
Error Handling
The SDK raises ApiError for HTTP errors. Wrap your calls in try/except blocks:
Common Errors
Retry Logic
For production systems, add retry logic with exponential backoff:
Async Usage
The SDK includes an async client for use with asyncio. Use AsyncSync instead of Sync:
The async client supports the same methods as the sync client — create, get, list, estimate_cost, and create_with_files.
The async client works with any asyncio-compatible framework like FastAPI, Sanic, or aiohttp.
Type Hints
The SDK is fully typed. All request parameters, response objects, and enums have type annotations. Your editor will provide autocomplete and inline documentation out of the box.
Available Models
See the Models page for detailed comparisons.
Next Steps
- API Reference — Full endpoint documentation with parameter details
- TypeScript SDK Guide — Equivalent guide for the TypeScript SDK
- Video Dubbing API Guide — Build a dubbing pipeline
- Text-to-Speech Lip Sync Guide — Combine TTS with lip sync
- Webhooks — Replace polling with real-time notifications
- Segments Guide — Handle multi-speaker videos
- Error Handling — Full error code reference
Frequently Asked Questions
Does the Python SDK support async?
Yes. The SDK includes an AsyncSync client for use with asyncio. Import AsyncSync instead of Sync and use await with all SDK methods. The async client supports the same operations as the sync client and works with frameworks like FastAPI, Sanic, and aiohttp.
How do I handle timeouts?
The SDK raises ApiError for HTTP errors including timeouts. Wrap calls in try/except blocks and implement retry logic with exponential backoff for transient errors. For polling, use a sleep interval of 10 seconds between status checks to avoid hitting rate limits.
Can I cancel a generation?
The Sync API does not currently provide a cancel endpoint for in-progress generations. Once a generation is submitted, it will run to completion or fail. You only pay for successfully completed generations. Monitor status via polling or webhooks to track progress.

