Official Python SDK for the SnapEdit API — 40+ AI image & video editing models through a single API key.
Project description
SnapEdit Python SDK
Official Python SDK for the SnapEdit API — 40+ AI image & video editing models through a single API key. Sync and async, fully typed.
Install
pip install snapedit-api
Requires Python 3.8+.
Quick start
from snapedit import SnapEdit
client = SnapEdit(api_key="sk-snap-...") # or set SNAPEDIT_API_KEY
out = client.remove.background("https://example.com/photo.jpg")
print(out.data[0].url)
Inputs accept a URL (fetched server-side), a local file path, bytes, a pathlib.Path, or any binary file-like object:
client.enhance.image("./portrait.jpg", zoom_factor=4, enhance_faces=True)
with open("photo.png", "rb") as f:
client.remove.background(f)
Async
import asyncio
from snapedit import AsyncSnapEdit
async def main():
async with AsyncSnapEdit() as client: # reads SNAPEDIT_API_KEY
out = await client.generate.zimage("a red panda astronaut", aspect_ratio="16:9")
print(out.data[0].url)
asyncio.run(main())
What's available
| Group | Methods (examples) |
|---|---|
client.detect |
objects, text, wires |
client.remove |
background, objects, text, logo, wires, reflection, mirror, background_graphic |
client.enhance |
image, image_pro, art, restore, colorize, light_restore, backlit_fix, night_flash |
client.generate |
zimage, qwen, art, background, headshot, sticker |
client.edit |
edit, multi |
client.beauty |
retouch_skin, makeup, hairstyle |
client.utility |
outpaint, pose_suggest, ai_detect |
client.try_on |
create, get, cancel, wait, run (async task) |
client.video |
enhance, remove_logo (upload-based async task) |
client.files |
remove_logo_pdf (upload-based async task) |
Async task endpoints
Virtual try-on, video, and PDF endpoints are long-running. Use the one-shot
run / enhance / remove_logo helpers to submit and poll to completion:
task = client.try_on.run(
model_image="https://example.com/model.jpg",
cloth_image="https://example.com/shirt.jpg",
cloth_type="upper",
)
print(task.download_url)
# Videos upload the file for you, then poll:
result = client.video.enhance("./clip.mp4", zoom_factor="2K")
print(result.download_url)
Control polling with WaitOptions:
from snapedit import WaitOptions
task = client.try_on.run(
model_image="...", cloth_image="...", cloth_type="upper",
opts=WaitOptions(poll_interval=2, max_wait=600,
on_progress=lambda t: print(t.status, t.progress)),
)
Configuration
client = SnapEdit(
api_key="sk-snap-...",
auth_scheme="bearer", # or "api-key" header
timeout=60.0, # per-request seconds
max_retries=2, # auto-retry 429 / 5xx / network errors
base_url="https://api.snapedit.app",
)
Errors
from snapedit import SnapEditError, SnapEditTaskError
try:
client.remove.background("bad-input")
except SnapEditError as e:
print(e.status, e.type, e.code)
if e.is_rate_limit:
print("retry after", e.retry_after, "seconds")
SnapEditTaskError is raised when an async task fails or a wait() times out.
Rate limits
After any request, inspect client.rate_limit (limit, remaining, reset).
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 snapedit_api-1.0.0.tar.gz.
File metadata
- Download URL: snapedit_api-1.0.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d91d4f0b754664a4112fa0f33720a0ff730235b9953d3338fd2eed74acb299ce
|
|
| MD5 |
4c669ceedc395fc05979609a1aaa781f
|
|
| BLAKE2b-256 |
d6ffbd841c0735a800a52201f57104897e2347ccfe753cfad6610a672b05ce55
|
File details
Details for the file snapedit_api-1.0.0-py3-none-any.whl.
File metadata
- Download URL: snapedit_api-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c380b40f0503f320ca9f109c84cbe4e202495135e520c6d3ef9a3ee8c0be086
|
|
| MD5 |
e84e2a0ed30b3454df93c142b929a5d4
|
|
| BLAKE2b-256 |
844133cadb57d9b2257453adf5ece6bc91be3481b08b3cf2b63a3f710a40d84e
|