Official Python SDK for the SudoMock Mockup Generator API
Project description
SudoMock Python SDK
Official Python client for the SudoMock Mockup Generator API.
Generate photorealistic product mockups from PSD templates or AI-powered rendering -- all from your Python code.
Installation
pip install sudomock
Quick Start
from sudomock import SudoMock
# 1. Create a client (or set SUDOMOCK_API_KEY env var)
client = SudoMock(api_key="sm_your_api_key")
# 2. List your mockup templates
mockups = client.mockups.list(limit=10)
for m in mockups.mockups:
print(f"{m.name} ({m.uuid})")
# 3. Render a mockup with your artwork
render = client.renders.create(
mockup_uuid=mockups.mockups[0].uuid,
smart_objects=[{
"uuid": mockups.mockups[0].smart_objects[0].uuid,
"asset": {"url": "https://example.com/your-design.png"},
}],
)
print(render.url) # https://cdn.sudomock.com/renders/.../render.webp
Async Usage
import asyncio
from sudomock import AsyncSudoMock
async def main():
async with AsyncSudoMock(api_key="sm_your_api_key") as client:
mockups = await client.mockups.list()
render = await client.renders.create(
mockup_uuid=mockups.mockups[0].uuid,
smart_objects=[{
"uuid": mockups.mockups[0].smart_objects[0].uuid,
"asset": {"url": "https://example.com/design.png"},
}],
)
print(render.url)
asyncio.run(main())
AI Rendering (No PSD Required)
from sudomock import SudoMock
client = SudoMock(api_key="sm_your_api_key")
# AI automatically detects the print area and applies perspective
render = client.ai.render(
source_url="https://example.com/product-photo.jpg",
artwork_url="https://example.com/your-design.png",
product_type="t-shirt", # optional hint
)
print(render.url)
Error Handling
from sudomock import SudoMock
from sudomock.exceptions import (
AuthenticationError,
InsufficientCreditsError,
RateLimitError,
NotFoundError,
ValidationError,
ServerError,
SudoMockError, # base class for all errors
)
client = SudoMock(api_key="sm_your_api_key")
try:
render = client.renders.create(
mockup_uuid="...",
smart_objects=[...],
)
except AuthenticationError:
print("Invalid API key")
except InsufficientCreditsError as e:
print(f"Out of credits. Resets at: {e.credits_reset_at}")
except RateLimitError as e:
print(f"Rate limited. Retry after: {e.retry_after}s")
except NotFoundError:
print("Mockup not found")
except ValidationError:
print("Invalid request parameters")
except ServerError:
print("Server error, will be retried automatically")
except SudoMockError as e:
print(f"Unexpected error: {e.message} (HTTP {e.status_code})")
Account & Credits
from sudomock import SudoMock
client = SudoMock(api_key="sm_your_api_key")
account = client.account.get()
print(f"Plan: {account.subscription.plan}")
print(f"Credits remaining: {account.usage.credits_remaining}")
print(f"Credits limit: {account.usage.credits_limit}")
print(f"Period ends: {account.subscription.current_period_end}")
Configuration
from sudomock import SudoMock
client = SudoMock(
api_key="sm_your_api_key", # or SUDOMOCK_API_KEY env var
base_url="https://api.sudomock.com", # default
timeout=30.0, # default request timeout (seconds)
render_timeout=120.0, # render request timeout (seconds)
max_retries=3, # retry on 429/5xx (exponential backoff)
)
API Reference
Mockups
| Method | Description |
|---|---|
client.mockups.list(limit=, offset=, search=) |
List mockup templates |
client.mockups.get(uuid) |
Get mockup details |
client.mockups.delete(uuid) |
Delete a mockup |
Renders
| Method | Description |
|---|---|
client.renders.create(mockup_uuid=, smart_objects=, export_options=, export_label=) |
Render a mockup |
AI
| Method | Description |
|---|---|
client.ai.render(source_url=, artwork_url=, product_type=, ...) |
AI-powered render |
Account
| Method | Description |
|---|---|
client.account.get() |
Get account info, credits, subscription |
Export Options
export_options = {
"image_format": "webp", # "webp", "png", "jpg"
"image_size": 1920, # max dimension in pixels
"quality": 95, # 1-100 (for webp/jpg)
}
Smart Object Configuration
smart_objects = [{
"uuid": "smart-object-uuid",
"asset": {
"url": "https://example.com/design.png",
"fit": "fill", # "fill", "fit", "stretch"
"rotate": 0, # degrees
"position": {"top": 100, "left": 100},
"size": {"width": 800, "height": 600},
},
"color": {
"hex": "#FFFFFF",
"blending_mode": "multiply",
},
}]
Requirements
- Python 3.9+
- httpx for HTTP
- Pydantic v2 for response models
- tenacity for retry logic
License
MIT -- see LICENSE.
Links
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
sudomock-0.1.0.tar.gz
(10.5 kB
view details)
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
sudomock-0.1.0-py3-none-any.whl
(14.8 kB
view details)
File details
Details for the file sudomock-0.1.0.tar.gz.
File metadata
- Download URL: sudomock-0.1.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9643036ab93b2fadfa9b0731b5220fd22b50c207353ef48deb4cd079437e1696
|
|
| MD5 |
0488a4db55d7eb7fd7dda5a9d0fed15d
|
|
| BLAKE2b-256 |
1427e50e7635e97db0b3b750ad2b4c63910ce3f3a02d5907237000ee9cf56440
|
File details
Details for the file sudomock-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sudomock-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ba06e2d326c40ee5d807b4a3817ce1fd0fb77be2d80c62eaf8f06470ac50326
|
|
| MD5 |
03c2574fee2fca5ceaf31a01cd9e1081
|
|
| BLAKE2b-256 |
980cd8abb7263dd4f091da624d79b2077fb642a1573afb47a2d6edbfbbeb33b8
|