# 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({
"13": {
"class_type": "RecraftV4TextToVectorNode",
"inputs": {
"model": "recraftv4",
"model.size": "1024x1024",
"n": 1,
"negative_prompt": "",
"prompt": "A warm, whimsical illustration captures a crossing guard gently guiding four schoolchildren across a crosswalk, rendered in a soft, muted palette of mint green, mustard yellow, and earthy tones. The isometric perspective and flat, textured shapes create a playful, modern folk-art style, while the long, soft shadows add depth and a sense of calm, sunny daytime. The composition centers on the protective figure, with children arranged in a loose, natural formation around him, evoking a feeling of safety and gentle care.",
"seed": 0,
"style_id": "",
"style_match": "precise"
},
"_meta": {
"title": "Recraft V4 Text to Vector"
}
},
"14": {
"class_type": "SaveSVGNode",
"inputs": {
"filename_prefix": "svg/Recraft_v4_t2vecotr",
"svg": [
"13",
0
]
},
"_meta": {
"title": "Save SVG"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)