# 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({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"98",
0
],
"model": [
"78",
0
],
"negative": [
"47",
0
],
"positive": [
"94",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 31,
"steps": 8
},
"_meta": {
"title": "KSampler"
}
},
"18": {
"class_type": "VAEDecodeAudio",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"97",
2
]
},
"_meta": {
"title": "VAE Decode Audio"
}
},
"47": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"94",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"78": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"97",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"94": {
"class_type": "TextEncodeAceStepAudio1.5",
"inputs": {
"bpm": 68,
"cfg_scale": 2,
"clip": [
"97",
1
],
"duration": 86,
"generate_audio_codes": True,
"keyscale": "D minor",
"language": "en",
"lyrics": "[Intro]\n\n[Verse 1]\nThe lamp is lit on the headland rock\nThe wind is clawing at the door\nI wind the clock and I watch the black\nWhere the boats went out before\n\n[Verse 2]\nThe kettle sings and the shutters shake\nThe sea is grey as an old man's beard\nI count the hours till the morning breaks\nAnd the shape of a sail appears\n\n[Chorus]\nHold on, hold on, the light is burning\nSteady on the water, steady through the storm\nHold on, hold on, the tide is turning\nBring them home, bring them home\n\n[Verse 3]\nThe dawn comes thin through the salted glass\nThe swell lies down like a weary hound\nAnd there on the edge where the gulls go past\nA hull comes riding round\n\n[Chorus]\nHold on, hold on, the light is burning\nSteady on the water, steady through the storm\nHold on, hold on, the tide is turning\nBring them home, bring them home\n\n[Outro]",
"min_p": 0,
"seed": 31,
"tags": "Genre: 1960s American Appalachian folk ballad. Tempo: 68 BPM. Key: D minor modulating to D major. Mood: Desolate, intimate, and introspective, gradually blooming into warm, resolute hope. Production style: Warm analog tape saturation, close-mic dryness with soft plate reverb evoking a wooden cabin interior. Instrumentation: Fingerpicked steel-string acoustic guitar, gentle clawhammer banjo, bowed upright bass, and rustic fiddle. Vocal style: Lone, weathered baritone with understated vibrato, unpolished and conversational. Arrangement: Intro features solitary, muted guitar arpeggios. Verses remain sparse, driven by the solo voice, quiet bass drone, and distant fiddle accents. Chorus introduces subtle banjo counterpoint. Final chorus builds to an expansive peak with rich acoustic multi-tracking, resonant open-string strumming, and soaring fiddle swells. Outro strips back to a single decaying guitar chord.",
"temperature": 0.85,
"timesignature": "3",
"top_k": 0,
"top_p": 0.9
},
"_meta": {
"title": "TextEncodeAceStepAudio1.5"
}
},
"97": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "ace_step_1.5_turbo_aio.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"98": {
"class_type": "EmptyAceStep1.5LatentAudio",
"inputs": {
"batch_size": 1,
"seconds": 86
},
"_meta": {
"title": "Empty Ace Step 1.5 Latent Audio"
}
},
"104": {
"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)
for output in job.get_outputs("104"):
output.to_file(output.name)