Skip to content

Repository files navigation

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)

importasyncioimportosfromdecartimportDecartClient, modelsasyncdefmain():
asyncwithDecartClient(api_key=os.getenv("DECART_API_KEY")) asclient:
# Edit an imageresult=awaitclient.process({
"model": models.image("lucy-image-2"),
"prompt": "Apply a painterly oil-on-canvas look while preserving the composition",
"data": open("input.png", "rb"),
})
withopen("output.png", "wb") asf:
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:

asyncwithDecartClient(api_key=os.getenv("DECART_API_KEY")) asclient:
# Submit and poll automaticallyresult=awaitclient.queue.submit_and_poll({
"model": models.video("lucy-clip"),
"prompt": "Restyle this footage with anime shading and vibrant neon highlights",
"data": open("input.mp4", "rb"),
"on_status_change": lambdajob: print(f"Status: {job.status}"),
})
ifresult.status=="completed":
withopen("output.mp4", "wb") asf:
f.write(result.data)
else:
print(f"Job failed: {result.error}")

Or manage the polling manually:

asyncwithDecartClient(api_key=os.getenv("DECART_API_KEY")) asclient:
# Submit the jobjob=awaitclient.queue.submit({
"model": models.video("lucy-clip"),
"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 statusstatus=awaitclient.queue.status(job.job_id)
print(f"Status: {status.status}")
# Get result when completedifstatus.status=="completed":
data=awaitclient.queue.result(job.job_id)
withopen("output.mp4", "wb") asf:
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:

  1. Display the current version
  2. Prompt for the new version
  3. Update pyproject.toml
  4. Commit and push changes
  5. Create a GitHub release with release notes

The GitHub Actions workflow will automatically build, test, and publish to PyPI.

License

MIT

Releases

Packages

Contributors

Languages