# 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({
"35": {
"class_type": "SaveAudioAdvanced",
"inputs": {
"audio": [
"37:43",
0
],
"filename_prefix": "audio/audio_minimax_music3",
"format": "mp3",
"format.quality": "V0"
},
"_meta": {
"title": "Save Audio (Advanced)"
}
},
"37:10": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"37:13",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"37:12": {
"class_type": "VAEDecodeAudio",
"inputs": {
"samples": [
"37:9",
0
],
"vae": [
"37:7",
0
]
},
"_meta": {
"title": "VAE Decode Audio"
}
},
"37:13": {
"class_type": "MiniMaxMusic3TextEncode",
"inputs": {
"caption": "Genre: 1970s Nuyorican Latin jazz and salsa dura. \nTempo: 118 BPM. \nKey: F minor. \nMood: Gritty, stormy, and relentlessly danceable, escalating from tense syncopation into full-throttle rhythmic drive. \nProduction and Timbre: Warm analog tape saturation, close-mic percussion, biting muted brass, and dry, upfront rhythm section. \nInstrumentation: Vintage electric piano, cutting timbales, driving baby bass, raw baritone saxophone, two muted trumpets, and guiro. \n\nArrangement:\n- Intro: Driving guiro pattern and a cascading electric piano montuno under thunderous timbale fills.\n- Verse: Restless baritone saxophone riffing beneath tight, staccato muted trumpet punches and walking bass.\n- Chorus: Short, infectious Spanish-language chorus belted with a raspy, passionate female vocal backed by tight three-part harmonies.\n- Outro: Explosive mambo section featuring blistering timbale solos, escalating horn crescendos, and an abrupt, tight hit ending.",
"cfg_scale": 1.7,
"clip": [
"37:3",
0
],
"lyrics": "[Intro]\n\n[Verse]\nSube el calor por la escalera\nla noche enciende su tambor\nla luna baila en la azotea\ny el barrio entero pide más\n\n[Chorus]\n¡Que suene, que suene la tormenta!\n¡Que suene hasta el amanecer!\n(¡Ay, que suene!)\n\n[Instrumental]\n\n[Chorus]\n¡Que suene, que suene la tormenta!\n¡Que suene hasta el amanecer!\n(¡Ay, que suene!)\n\n[Outro]",
"max_duration": 60,
"seed": [
"37:38",
0
],
"top_k": 50
},
"_meta": {
"title": "MiniMax Music3 Text Encode"
}
},
"37:15": {
"class_type": "EmptyMiniMaxMusic3LatentAudio",
"inputs": {
"batch_size": 1,
"seconds": [
"37:13",
1
]
},
"_meta": {
"title": "Empty MiniMax Music3 Latent Audio"
}
},
"37:3": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "minimax_music3_text_encoder_pruned_int8_convrot.safetensors",
"device": "default",
"type": "minimax"
},
"_meta": {
"title": "Load CLIP"
}
},
"37:38": {
"class_type": "SeedNode",
"inputs": {
"seed": 197122968890040
},
"_meta": {
"title": "Seed"
}
},
"37:42": {
"class_type": "VAEDecodeAudioTiled",
"inputs": {
"overlap": 64,
"samples": [
"37:9",
0
],
"tile_size": 1536,
"vae": [
"37:7",
0
]
},
"_meta": {
"title": "VAE Decode Audio (Tiled)"
}
},
"37:43": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"37:12",
0
],
"on_true": [
"37:42",
0
],
"switch": True
},
"_meta": {
"title": "If/Else Switch"
}
},
"37:6": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "minimax_music3_dit_fp16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"37:7": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "minimax_music3_dav.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"37:9": {
"class_type": "KSampler",
"inputs": {
"cfg": 1.7,
"denoise": 1,
"latent_image": [
"37:15",
0
],
"model": [
"37:6",
0
],
"negative": [
"37:10",
0
],
"positive": [
"37:13",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": [
"37:38",
0
],
"steps": 30
},
"_meta": {
"title": "KSampler"
}
}
})
# 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("35"):
output.to_file(output.name)