Decart's Python SDK
Project description
Decart Python SDK
A Python SDK for Decart's models.
Installation
Using UV
uv add decart
Using pip
pip install decart
Documentation
For complete documentation, guides, and examples, visit: https://docs.platform.decart.ai/sdks/python
Quick Start
Image Editing (Process API)
import asyncio
import os
from decart import DecartClient, models
async def main():
async with DecartClient(api_key=os.getenv("DECART_API_KEY")) as client:
# Edit an image
result = await client.process({
"model": models.image("lucy-pro-i2i"),
"prompt": "Apply a painterly oil-on-canvas look while preserving the composition",
"data": open("input.png", "rb"),
})
with open("output.png", "wb") as f:
f.write(result)
asyncio.run(main())
Video Editing (Queue API)
For video editing jobs, use the queue API to submit jobs and poll for results:
async with DecartClient(api_key=os.getenv("DECART_API_KEY")) as client:
# Submit and poll automatically
result = await client.queue.submit_and_poll({
"model": models.video("lucy-pro-v2v"),
"prompt": "Restyle this footage with anime shading and vibrant neon highlights",
"data": open("input.mp4", "rb"),
"on_status_change": lambda job: print(f"Status: {job.status}"),
})
if result.status == "completed":
with open("output.mp4", "wb") as f:
f.write(result.data)
else:
print(f"Job failed: {result.error}")
Or manage the polling manually:
async with DecartClient(api_key=os.getenv("DECART_API_KEY")) as client:
# Submit the job
job = await client.queue.submit({
"model": models.video("lucy-pro-v2v"),
"prompt": "Add cinematic teal-and-orange grading and gentle film grain",
"data": open("input.mp4", "rb"),
})
print(f"Job ID: {job.job_id}")
# Poll for status
status = await client.queue.status(job.job_id)
print(f"Status: {status.status}")
# Get result when completed
if status.status == "completed":
data = await client.queue.result(job.job_id)
with open("output.mp4", "wb") as f:
f.write(data)
Development
Setup with UV
# Clone the repository
git clone https://github.com/decartai/decart-python
cd decart-python
# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install all dependencies (including dev dependencies)
uv sync --all-extras
# Run tests
uv run pytest
# Run linting
uv run ruff check decart/ tests/ examples/
# Format code
uv run black decart/ tests/ examples/
# Type check
uv run mypy decart/
Common Commands
# Install dependencies
uv sync --all-extras
# Run tests with coverage
uv run pytest --cov=decart --cov-report=html
# Run examples
uv run python examples/process_video.py
uv run python examples/realtime_synthetic.py
# Update dependencies
uv lock --upgrade
Test UI
The SDK includes an interactive test UI built with Gradio for quickly testing all SDK features without writing code.
# Install Gradio
pip install gradio
# Run the test UI
python test_ui.py
Then open http://localhost:7860 in your browser.
The UI provides tabs for:
- Image Editing - Image-to-image edits
- Video Editing - Video-to-video edits
- Video Restyle - Restyle videos using text prompts or reference images
- Tokens - Create short-lived client tokens
Enter your API key at the top of the interface to start testing.
Publishing a New Version
The package is automatically published to PyPI when you create a GitHub release.
Automated Release
Use the release script to automate the entire process:
python release.py
The script will:
- Display the current version
- Prompt for the new version
- Update
pyproject.toml - Commit and push changes
- Create a GitHub release with release notes
The GitHub Actions workflow will automatically build, test, and publish to PyPI.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file decart-0.0.30.tar.gz.
File metadata
- Download URL: decart-0.0.30.tar.gz
- Upload date:
- Size: 192.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdb6c66ebe6c77f5ec986c27480b19d6da81ed6d2f194f47972693a42cbca189
|
|
| MD5 |
aa24877fa62677dd872a3759595b45b9
|
|
| BLAKE2b-256 |
7b301a358ac2c0f60052daafed188052fa3cce37ecb9e0fbbf1d7646ca36680e
|
Provenance
The following attestation bundles were made for decart-0.0.30.tar.gz:
Publisher:
publish.yml on DecartAI/decart-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decart-0.0.30.tar.gz -
Subject digest:
bdb6c66ebe6c77f5ec986c27480b19d6da81ed6d2f194f47972693a42cbca189 - Sigstore transparency entry: 1185849045
- Sigstore integration time:
-
Permalink:
DecartAI/decart-python@f0e022c08671c71a41708451684a311e2b4db069 -
Branch / Tag:
refs/tags/v0.0.30 - Owner: https://github.com/DecartAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f0e022c08671c71a41708451684a311e2b4db069 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decart-0.0.30-py3-none-any.whl.
File metadata
- Download URL: decart-0.0.30-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17544e89f599eec2b52a133d267d8470889be61e7d6ce478c4f05fc6872b8301
|
|
| MD5 |
1dee1fe4877fbb3482ab558c51527f3b
|
|
| BLAKE2b-256 |
dac8a58ad38e5cccbb5a3a2e7e5d710c262f5bebba4cca0070dd8a8abd0089ac
|
Provenance
The following attestation bundles were made for decart-0.0.30-py3-none-any.whl:
Publisher:
publish.yml on DecartAI/decart-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decart-0.0.30-py3-none-any.whl -
Subject digest:
17544e89f599eec2b52a133d267d8470889be61e7d6ce478c4f05fc6872b8301 - Sigstore transparency entry: 1185849048
- Sigstore integration time:
-
Permalink:
DecartAI/decart-python@f0e022c08671c71a41708451684a311e2b4db069 -
Branch / Tag:
refs/tags/v0.0.30 - Owner: https://github.com/DecartAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f0e022c08671c71a41708451684a311e2b4db069 -
Trigger Event:
release
-
Statement type: