# 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({
"14": {
"class_type": "TextEncodeAceStepAudio",
"inputs": {
"clip": [
"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": "anime, soft female vocals, kawaii pop, j-pop, childish, piano, guitar, synthesizer, fast, happy, cheerful, lighthearted\t\n"
},
"_meta": {
"title": "TextEncodeAceStepAudio"
}
},
"17": {
"class_type": "EmptyAceStepLatentAudio",
"inputs": {
"batch_size": 1,
"seconds": 120
},
"_meta": {
"title": "Empty Ace Step 1.0 Latent Audio"
}
},
"18": {
"class_type": "VAEDecodeAudio",
"inputs": {
"samples": [
"52",
0
],
"vae": [
"40",
2
]
},
"_meta": {
"title": "VAE Decode Audio"
}
},
"40": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "ace_step_v1_3.5b.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"44": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"14",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"49": {
"class_type": "LatentApplyOperationCFG",
"inputs": {
"end_percent": 1,
"model": [
"51",
0
],
"operation": [
"50",
0
],
"start_percent": 0
},
"_meta": {
"title": "LatentApplyOperationCFG"
}
},
"50": {
"class_type": "LatentOperationTonemapReinhard",
"inputs": {
"multiplier": 1.0000000000000002
},
"_meta": {
"title": "LatentOperationTonemapReinhard"
}
},
"51": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"40",
0
],
"shift": 5.000000000000001
},
"_meta": {
"title": "ModelSamplingSD3"
}
},
"52": {
"class_type": "KSampler",
"inputs": {
"cfg": 5,
"denoise": 1,
"latent_image": [
"17",
0
],
"model": [
"49",
0
],
"negative": [
"44",
0
],
"positive": [
"14",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 468254064217846,
"steps": 50
},
"_meta": {
"title": "KSampler"
}
},
"59": {
"class_type": "SaveAudioMP3",
"inputs": {
"audio": [
"18",
0
],
"filename_prefix": "audio/ComfyUI",
"quality": "V0"
},
"_meta": {
"title": "Save Audio (MP3) (DEPRECATED)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)