Nodes/ComfyUI-Kie-API/KIE Get Remaining Credits
ComfyUI Node

KIE Get Remaining Credits

KIE Get Remaining Credits

By gateway·Created 9 months ago·Updated 4 months ago· 39
KIE Get Remaining Credits
    • data
    • credits_remaining
    logtrue

    Every node in this pack spends your Kie.ai credits, and this is the one that tells you how much is left. KIE Get Remaining Credits is about as minimal as a node gets - a single boolean input and one purpose: verify your API key works and show your balance. The pack's own README recommends running it first, before anything else, and it's right. It's the cheapest possible smoke test for the whole setup.

    Why you'll actually use it: the KIE nodes are pay-as-you-go, and there's no subscription safety net. "Why did my job fail?" is, embarrassingly often, "because the balance hit zero." This node answers that in one run instead of a support ticket or a long squint at kie.ai/logs.

    How it works

    It reads your API key from config/kie_key.txt in the pack folder, hits KIE's chat/credit endpoint with a Bearer token, and parses the response. If the key is missing or invalid, it errors immediately - which is itself useful diagnostic information. On success it returns the raw JSON payload plus the parsed credit count.

    The inputs and outputs that matter

    One input, one you can ignore: log (boolean, default true) just controls console output. Set it false if you want a silent run.

    Two outputs:

    • credits_remaining - an INT with your balance. Wire this into a text display or compare against a threshold to auto-gate a workflow (a simple "skip generation if under 50 credits" gate is a genuinely nice safety pattern).
    • data - the raw JSON response as a STRING, useful if you want the full response body for logging or automation.

    That's the whole node. It doesn't call any model, so it costs nothing but the request.

    Installing

    It comes with the pack - install once, get every KIE node including this one. ComfyUI Manager: search "ComfyUI Kie API". Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/gateway/ComfyUI-Kie-API
    # restart ComfyUI
    

    The setup that actually matters is the key: create config/kie_key.txt from kie_key.example.txt and paste in your Kie.ai key. Run this node first and confirm a sane number comes back - that proves key + credits + network in one shot.

    Where people get burned

    Honestly, not much to trip over here - the node is four lines of logic. The traps are upstream: a stale or empty kie_key.txt gives you the "KIE API key not found" error, and a wrong key gives you a non-200 error from the endpoint. Both are exactly what you want to discover here, before you waste credits on a generation that was never going to authenticate. One genuine gotcha: the endpoint reports whatever KIE's record says, so if you have multiple keys or spend from a dashboard, the number reflects that account, not your imagination.

    Categorykie/api

    Inputs (1)

    NameTypeDefaultDescription
    logBOOLEANtrue

    Outputs (2)

    NameTypeDescription
    dataSTRING
    credits_remainingINT