Generate product mockups with Python
You can generate product mockups with Python in one HTTP call. Send your PSD template id and a design URL to the SudoMock render endpoint, and you get back a finished image URL. Start with 500 one-time renders, then choose a published monthly volume plan.
The API keeps your PSD template intact: Smart Objects, blend modes, smart filters, and perspective warp all render from your real file. It also renders editable text layers, so one template personalizes to thousands of variations from a single Python script.
Install the requests library
Grab an API key from your dashboard, then keep it in an environment variable. Every request authenticates with the x-api-key header.
1pip install requests2export SUDOMOCK_API_KEY="sm_your_api_key"
Render your first mockup
One POST to the render endpoint composites your design into the PSD template and returns a finished image URL. Smart Objects, blend modes, smart filters, and perspective warp all render from your real file, so the output matches the template you built.
1import os2import requests34API_BASE = "https://api.sudomock.com/api/v1"5API_KEY = os.environ["SUDOMOCK_API_KEY"]67resp = requests.post(8 f"{API_BASE}/renders",9 headers={"x-api-key": API_KEY, "Content-Type": "application/json"},10 json={11 "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",12 "smart_objects": [13 {14 "uuid": "128394ee-6758-4f2f-aa36-e2b19b152bd9",15 "asset": {"url": "https://your-domain.com/design.png", "fit": "cover"},16 }17 ],18 "export_options": {"image_format": "webp", "image_size": 1920, "quality": 90},19 },20)21resp.raise_for_status()22data = resp.json()23print("Mockup ready:", data["data"]["print_files"][0]["export_path"])
How it works
- 1Upload a PSD once to get its mockup id and the ids of its Smart Objects and text layers.
- 2Loop over your designs in Python and POST one render request per variation.
- 3Read data.print_files[0].export_path from the response and store the finished image URL.
Personalize text layers from Python
SudoMock renders the text layers in your PSD, so you can swap the wording, font, size, and color at render time and get back an image that keeps the look the designer built.
- 2,000+ open-licensed font families, free for commercial use
- Custom TTF and OTF font upload, up to 5 MB each, on Pro and Scale
- Styled segments: mixed-style layers stay editable run by run
- Box text: area text wraps inside its box and clips exactly as designed
1# Swap the wording, font, size, and color on a named text layer.2resp = requests.post(3 f"{API_BASE}/renders",4 headers={"x-api-key": API_KEY, "Content-Type": "application/json"},5 json={6 "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",7 "text_layers": [8 {9 "uuid": "b7f2c1a0-9e34-4d21-8f0a-1c2b3d4e5f60",10 "text": "SUMMER SALE",11 "font": "Poppins-Bold",12 "font_size": 96,13 "color": "#C0392B",14 }15 ],16 },17)18resp.raise_for_status()19print(resp.json()["data"]["print_files"][0]["export_path"])
Edit one mixed-style layer, run by run
When a single layer mixes styles, like a thin first name next to a bold surname, send a segments array with only the runs you want to change. Every run keeps its own font, size, and color, and any run you leave out stays as designed. This bundle of catalog, custom upload, per-segment styling, and box wrap over the API is what sets the text layers apart.
1{2 "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",3 "text_layers": [4 {5 "uuid": "b7f2c1a0-9e34-4d21-8f0a-1c2b3d4e5f60",6 "segments": [7 { "index": 0, "text": "Jane " },8 { "index": 1, "text": "SMITH" }9 ]10 }11 ]12}
Full field reference and the fallback behavior when a font is not in your catalog live in the text layers documentation.
Frequently asked questions
How do I generate a product mockup with Python?
Install requests, then POST your PSD template id and a design URL to https://api.sudomock.com/api/v1/renders with your API key in the x-api-key header. The response returns a finished mockup image URL at data.print_files[0].export_path. No image processing runs on your side.
Can I batch-render many mockups in Python?
Yes. Loop over your designs and send one render request per variation, or run them concurrently with a thread pool. Paid plans render several requests in parallel, so a large catalog of on-product images is practical from a single script.
Can I edit text and fonts in the mockup from Python?
Yes. Add a text_layers array to the render body to swap wording, font, size, and color on named layers. The built-in catalog carries 2,000+ open-licensed font families, and mixed-style layers stay editable segment by segment.
Render your first Python mockup in minutes
Get 500 one-time API credits to test. No credit card required. See pricing for published monthly volumes and annual billing.