Python SDK tutorial
Install the GenAsset Python SDK, save a generated image with full recipe metadata, attach input images, and load the saved version back into a pipeline.
Goal
Use the Python SDK when your image is created outside ComfyUI: Diffusers, a local model runner, a notebook, a batch pipeline, or a custom script. The goal is the same as the ComfyUI tutorial: save the output image plus the recipe fields needed to recreate it later.
Authenticate
Use one workspace token from GenAsset settings or onboarding.
Save the run
Send image, prompt, model, seed, sampler, dimensions, tags, and workflow metadata.
Reload later
Load a version recipe or download the saved preview into another Python run.
Setup
Install the SDK in the same environment as your generation code. Keep the token in an environment variable for local scripts, notebooks, and batch jobs.
python3 -m venv .venv
source .venv/bin/activate
pip install gen-asset-sdk pillow
export GENASSET_TOKEN="ga_your_workspace_token"
export GENASSET_BASE_URL="https://genasset.xyz" GENASSET_TOKEN locally and rotate the token if it is exposed.Steps
- Create or choose a GenAsset workspace token.
- Install
gen-asset-sdkand setGENASSET_TOKEN. - Run your Python generation pipeline and save the output image to disk.
- Call
client.save_image(...)with the output image and the full recipe fields. - Open the GenAsset dashboard and confirm the new asset has Type Python SDK.
- Open the asset detail page and check prompt, negative prompt, model, seed, steps, CFG, sampler, scheduler, denoise, size, tags, and intent.
from pathlib import Path
from PIL import Image, ImageDraw
from gen_asset_sdk import GenAssetClient
client = GenAssetClient(token="ga_your_workspace_token")
out = Path("outputs/python-sdk-blue-cube.png")
out.parent.mkdir(parents=True, exist_ok=True)
# Replace this demo image with your real Diffusers, Invoke, or custom pipeline output.
image = Image.new("RGB", (512, 512), (22, 36, 54))
draw = ImageDraw.Draw(image)
draw.rounded_rectangle((150, 130, 360, 350), radius=24, fill=(39, 138, 107))
draw.text((142, 385), "GenAsset Python SDK", fill=(235, 248, 242))
image.save(out)
result = client.save_image(
image_path=out,
asset_name="python-sdk-blue-cube",
prompt="a translucent blue glass cube on a brushed steel table, clean product photo, soft rim light",
negative_prompt="low quality, blurry, text, watermark, distorted cube",
model="runwayml/stable-diffusion-v1-5",
seed=1778911201,
steps=20,
cfg=7.5,
sampler_name="Euler",
scheduler="normal",
denoise=1.0,
width=512,
height=512,
workflow_name="python-sdk-blue-cube",
workflow_kind="txt2img-from-python",
family="sd1.5",
intent="txt2img",
tags=["python-sdk", "product", "tutorial"],
)
print(result["asset"]["id"])
print(result["version"]["id"]) input_images. GenAsset stores them in the Inputs panel so the run can be audited later.result = client.save_image(
image_path="outputs/edited-room.png",
input_images=["inputs/source-room.png"],
asset_name="python-sdk-room-edit",
prompt="same room without the plant, brighter morning light",
negative_prompt="plant, clutter, low quality",
model="stabilityai/stable-diffusion-xl-base-1.0",
seed=314159,
steps=24,
cfg=6.0,
sampler_name="DPM++ 2M",
scheduler="karras",
denoise=0.42,
width=1024,
height=1024,
workflow_kind="img2img-from-python",
family="sdxl",
intent="image_to_image",
)Validated run
- The SDK creates replay-focused workflow JSON automatically if you do not pass your own workflow payload.
- Saved Python runs are shown as Type: Python SDK in the asset Generation panel.
- Recipe fields are aligned with the ComfyUI save path: prompt, negative prompt, model, seed, steps, CFG, sampler, scheduler, denoise, width, height, family, and workflow kind.
- Input images are uploaded with the saved version and appear in the asset Inputs panel.
payload = client.load_version("paste_version_id_here")
version = payload["version"]
print(version["asset_id"])
print(version.get("prompt"))
print(version.get("metadata_json"))
client.download_version_image(
"paste_version_id_here",
"outputs/reloaded-from-genasset.png",
)