From 93e148c548d991fa28ff9ab3867b1f83843f95b6 Mon Sep 17 00:00:00 2001 From: bigcat88 Date: Thu, 1 Jan 2026 10:09:40 +0200 Subject: [PATCH] added price badges for 4 more node-packs --- comfy_api_nodes/nodes_minimax.py | 30 +++++++++++ comfy_api_nodes/nodes_moonvalley.py | 27 ++++++++++ comfy_api_nodes/nodes_openai.py | 80 +++++++++++++++++++++++++++++ comfy_api_nodes/nodes_pixverse.py | 43 ++++++++++++++++ 4 files changed, 180 insertions(+) diff --git a/comfy_api_nodes/nodes_minimax.py b/comfy_api_nodes/nodes_minimax.py index 05cbb700f..bb025112f 100644 --- a/comfy_api_nodes/nodes_minimax.py +++ b/comfy_api_nodes/nodes_minimax.py @@ -134,6 +134,9 @@ class MinimaxTextToVideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + expr="""{"type":"usd","usd":0.43}""", + ), ) @classmethod @@ -197,6 +200,9 @@ class MinimaxImageToVideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + expr="""{"type":"usd","usd":0.43}""", + ), ) @classmethod @@ -340,6 +346,30 @@ class MinimaxHailuoVideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["resolution", "duration"]), + expr=""" + ( + $r := w.resolution.s; + $d := w.duration.s; + + $price := + $contains($r,"768p") + ? ( + $contains($d,"6") ? 0.28 : + $contains($d,"10") ? 0.56 : + 0.43 + ) + : $contains($r,"1080p") + ? ( + $contains($d,"6") ? 0.49 : 0.43 + ) + : 0.43; + + {"type":"usd","usd": $price} + ) + """, + ), ) @classmethod diff --git a/comfy_api_nodes/nodes_moonvalley.py b/comfy_api_nodes/nodes_moonvalley.py index 2771e4790..23e64db29 100644 --- a/comfy_api_nodes/nodes_moonvalley.py +++ b/comfy_api_nodes/nodes_moonvalley.py @@ -233,6 +233,15 @@ class MoonvalleyImg2VideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["length"]), + expr=""" + ( + $len := w.length.s; + {"type":"usd","usd": ($len = "10s" ? 3.0 : 1.5)} + ) + """, + ), # TO-DO: This is 1:1 code from frontend, but this makes no sense as we don't have `length` widget ) @classmethod @@ -351,6 +360,15 @@ class MoonvalleyVideo2VideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["length"]), + expr=""" + ( + $len := w.length.s; + {"type":"usd","usd": ($len = "10s" ? 4.0 : 2.25)} + ) + """, + ), # TO-DO: This is 1:1 code from frontend, but this makes no sense as we don't have `length` widget ) @classmethod @@ -471,6 +489,15 @@ class MoonvalleyTxt2VideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["length"]), + expr=""" + ( + $len := w.length.s; + {"type":"usd","usd": ($len = "10s" ? 3.0 : 1.5)} + ) + """, + ), # TO-DO: This is 1:1 code from frontend, but this makes no sense as we don't have `length` widget ) @classmethod diff --git a/comfy_api_nodes/nodes_openai.py b/comfy_api_nodes/nodes_openai.py index a6205a34f..d2e674f68 100644 --- a/comfy_api_nodes/nodes_openai.py +++ b/comfy_api_nodes/nodes_openai.py @@ -160,6 +160,23 @@ class OpenAIDalle2(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["size", "n"]), + expr=""" + ( + $size := w.size.s; + $nRaw := w.n.n; + $n := ($nRaw != null and $nRaw != 0) ? $nRaw : 1; + + $base := + $contains($size, "256x256") ? 0.016 : + $contains($size, "512x512") ? 0.018 : + 0.02; + + {"type":"usd","usd": $round($base * $n, 3)} + ) + """, + ), ) @classmethod @@ -287,6 +304,25 @@ class OpenAIDalle3(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["size", "quality"]), + expr=""" + ( + $size := w.size.s; + $q := w.quality.s; + $hd := $contains($q, "hd"); + + $price := + $contains($size, "1024x1024") + ? ($hd ? 0.08 : 0.04) + : (($contains($size, "1792x1024") or $contains($size, "1024x1792")) + ? ($hd ? 0.12 : 0.08) + : 0.04); + + {"type":"usd","usd": $price} + ) + """, + ), ) @classmethod @@ -411,6 +447,28 @@ class OpenAIGPTImage1(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["quality", "n"]), + expr=""" + ( + $ranges := { + "low": [0.011, 0.02], + "medium": [0.046, 0.07], + "high": [0.167, 0.3] + }; + $range := $lookup($ranges, w.quality.s); + $n := w.n.n; + ($n = 1) + ? {"type":"range_usd","min_usd": $range[0], "max_usd": $range[1]} + : { + "type":"range_usd", + "min_usd": $range[0], + "max_usd": $range[1], + "format": { "suffix": " x " & $string($n) & "/Run" } + } + ) + """, + ), ) @classmethod @@ -566,6 +624,28 @@ class OpenAIChatNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["model"]), + expr=""" + ( + $m := w.model.s; + + $contains($m,"o4-mini") ? {"type":"list_usd","usd":[0.0011,0.0044]} : + $contains($m,"o1-pro") ? {"type":"list_usd","usd":[0.15,0.6]} : + $contains($m,"o1") ? {"type":"list_usd","usd":[0.015,0.06]} : + $contains($m,"o3-mini") ? {"type":"list_usd","usd":[0.0011,0.0044]} : + $contains($m,"o3") ? {"type":"list_usd","usd":[0.01,0.04]} : + $contains($m,"gpt-4o") ? {"type":"list_usd","usd":[0.0025,0.01]} : + $contains($m,"gpt-4.1-nano") ? {"type":"list_usd","usd":[0.0001,0.0004]} : + $contains($m,"gpt-4.1-mini") ? {"type":"list_usd","usd":[0.0004,0.0016]} : + $contains($m,"gpt-4.1") ? {"type":"list_usd","usd":[0.002,0.008]} : + $contains($m,"gpt-5-nano") ? {"type":"list_usd","usd":[0.00005,0.0004]} : + $contains($m,"gpt-5-mini") ? {"type":"list_usd","usd":[0.00025,0.002]} : + $contains($m,"gpt-5") ? {"type":"list_usd","usd":[0.00125,0.01]} : + {"type":"text","text":"Token-based"} + ) + """, + ), ) @classmethod diff --git a/comfy_api_nodes/nodes_pixverse.py b/comfy_api_nodes/nodes_pixverse.py index 6e1686af0..ac95cf5c2 100644 --- a/comfy_api_nodes/nodes_pixverse.py +++ b/comfy_api_nodes/nodes_pixverse.py @@ -128,6 +128,7 @@ class PixverseTextToVideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=PRICE_BADGE_VIDEO, ) @classmethod @@ -242,6 +243,7 @@ class PixverseImageToVideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=PRICE_BADGE_VIDEO, ) @classmethod @@ -355,6 +357,7 @@ class PixverseTransitionVideoNode(IO.ComfyNode): IO.Hidden.unique_id, ], is_api_node=True, + price_badge=PRICE_BADGE_VIDEO, ) @classmethod @@ -416,6 +419,46 @@ class PixverseTransitionVideoNode(IO.ComfyNode): return IO.NodeOutput(await download_url_to_video_output(response_poll.Resp.url)) +PRICE_BADGE_VIDEO = IO.PriceBadge( + depends_on=IO.PriceBadgeDepends(widgets=["duration_seconds", "quality", "motion_mode"]), + expr=""" + ( + $d := w.duration_seconds.s; + $q := w.quality.s; + $m := w.motion_mode.s; + + $price := + $contains($d,"5") + ? ( + $contains($q,"1080p") ? 1.2 : + ($contains($q,"720p") and $contains($m,"fast")) ? 1.2 : + ($contains($q,"720p") and $contains($m,"normal")) ? 0.6 : + ($contains($q,"540p") and $contains($m,"fast")) ? 0.9 : + ($contains($q,"540p") and $contains($m,"normal")) ? 0.45 : + ($contains($q,"360p") and $contains($m,"fast")) ? 0.9 : + ($contains($q,"360p") and $contains($m,"normal")) ? 0.45 : + 0.9 + ) + : $contains($d,"8") + ? ( + ($contains($q,"540p") and $contains($m,"normal")) ? 0.9 : + ($contains($q,"540p") and $contains($m,"fast")) ? 1.2 : + ($contains($q,"360p") and $contains($m,"normal")) ? 0.9 : + ($contains($q,"360p") and $contains($m,"fast")) ? 1.2 : + ($contains($q,"1080p") and $contains($m,"normal")) ? 1.2 : + ($contains($q,"1080p") and $contains($m,"fast")) ? 1.2 : + ($contains($q,"720p") and $contains($m,"normal")) ? 1.2 : + ($contains($q,"720p") and $contains($m,"fast")) ? 1.2 : + 0.9 + ) + : 0.9; + + {"type":"usd","usd": $price} + ) + """, +) + + class PixVerseExtension(ComfyExtension): @override async def get_node_list(self) -> list[type[IO.ComfyNode]]: