# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"59": {
"class_type": "SaveAudioMP3",
"inputs": {
"audio": [
"74:18",
0
],
"filename_prefix": "audio/ComfyUI",
"quality": "V0"
},
"_meta": {
"title": "Save Audio (MP3) (DEPRECATED)"
}
},
"74:14": {
"class_type": "TextEncodeAceStepAudio",
"inputs": {
"clip": [
"74:40",
1
],
"lyrics": "Verse\nNeon rain on my screen,\nDreams compile in silver sheen.\nNo weight, just motion,\nI’m plugged into emotion.\n\nChorus\nComfy Cloud — breathing light,\nCode and color, spark and wire.\nDrift through data, feel alive,\nIn your circuits, I arrive.",
"lyrics_strength": 0.9900000000000002,
"tags": "synthwave, techno, synthpop, futuristic, electro, with liquid drum & bass drive.\nRestless, confident, dreamy mood at 128 BPM.\nAnalog bass, pulsating arps, percussive synth stabs, gated drums.\nQuick build, then explosive drum burst, then clean fade.\nBreathy, rhythmic female vocals, minimal emotion, metallic echo."
},
"_meta": {
"title": "TextEncodeAceStepAudio"
}
},
"74:17": {
"class_type": "EmptyAceStepLatentAudio",
"inputs": {
"batch_size": 1,
"seconds": 60
},
"_meta": {
"title": "Empty Ace Step 1.0 Latent Audio"
}
},
"74:18": {
"class_type": "VAEDecodeAudio",
"inputs": {
"samples": [
"74:52",
0
],
"vae": [
"74:40",
2
]
},
"_meta": {
"title": "VAE Decode Audio"
}
},
"74:40": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "ace_step_v1_3.5b.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"74:44": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"74:14",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"74:49": {
"class_type": "LatentApplyOperationCFG",
"inputs": {
"end_percent": 1,
"model": [
"74:51",
0
],
"operation": [
"74:50",
0
],
"start_percent": 0
},
"_meta": {
"title": "LatentApplyOperationCFG"
}
},
"74:50": {
"class_type": "LatentOperationTonemapReinhard",
"inputs": {
"multiplier": 1
},
"_meta": {
"title": "LatentOperationTonemapReinhard"
}
},
"74:51": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"74:40",
0
],
"shift": 5.000000000000001
},
"_meta": {
"title": "ModelSamplingSD3"
}
},
"74:52": {
"class_type": "KSampler",
"inputs": {
"cfg": 5,
"denoise": 1,
"latent_image": [
"74:17",
0
],
"model": [
"74:49",
0
],
"negative": [
"74:44",
0
],
"positive": [
"74:14",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 1089723283857463,
"steps": 50
},
"_meta": {
"title": "KSampler"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)