ComfyUI Node

Get Gelbooru Post

The one that demands an API key in the URL

By DraconicDragon·Created 2 years ago·Updated 3 months ago· 7
Get Gelbooru Post
    • IMAGE
    • ALL_TAGS
    • ORIGINAL_WIDTH
    • ORIGINAL_HEIGHT
    url
    img_sizesample
    format_tagstrue
    trailing_commafalse
    exclude_tagstrue
    user_excluded_tagsconditional dnp, sound_warning, unknown_artist, third-party_edit, anonymous_artist, e621, e621 post recursion, e621_comment, patreon, patreon logo, patreon username, instagram username, text, dialogue

    Gelbooru is the odd one out in this pack, and the node knows it. It's the biggest of the "other" boorus, and its API behaves differently from every other board here: tags aren't categorized (you get one big string), it only serves preview and original image sizes, and - since the UK spam incidents got it hammered with ten thousand requests a second - it now requires an API key and user ID on every request. So Get Gelbooru Post is the pack's fiddliest fetch node, and the first thing you need to know is the key part.

    The API key is the setup

    There's no key input field. The node extracts api_key and user_id from the URL you give it, so you paste them into the post link yourself. Both are on Gelbooru's account options page, at the bottom. The URL you feed the node ends up looking like:

    https://gelbooru.com/index.php?page=post&s=view&id=12345&api_key=YOURKEY&user_id=YOURID
    

    Without the key, Gelbooru refuses or rate-limits you to near-uselessness. With it, the node rebuilds the request as the proper API call and everything flows. The one free pass: safebooru.org (a Gelbooru fork, unrelated to safebooru.donmai.us) is also supported and doesn't need credentials.

    How it works

    The handler fetches the post via Gelbooru's page=dapi&s=post&q=index endpoint, parses whichever JSON shape comes back (the response format has drifted between versions, and the parser handles both the list form and the wrapped post form), and reads the single flat tags field. Because there are no categories, you get one ALL_TAGS output instead of the split set - which means this node only makes sense with tag-prompting models that tolerate a flat list. For image sizes, original grabs the full file and everything else remaps to preview, since those are the only two Gelbooru keeps.

    The rest of the inputs are the pack standard: url, img_size, format_tags, trailing_comma, exclude_tags, and user_excluded_tags. Outputs are just IMAGE, ALL_TAGS, ORIGINAL_WIDTH, and ORIGINAL_HEIGHT - a deliberately small set.

    Install

    Same as the rest of the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DraconicDragon/ComfyUI_e621_booru_toolkit
    

    restart, done. Dependencies are the usual requests, pillow, curl_cffi.

    Use the dedicated node, not the Any node

    One trap worth flagging: this is marked experimental, and if you're tempted to use Get Booru Post (Any Service) with a Gelbooru URL instead, don't - the Any node's flat output doesn't surface Gelbooru's ALL_TAGS, so you'd get an empty tag string. Gelbooru is the one board where the specific node isn't just nicer, it's required. Set up the key once, and it's the reliable path into a board whose tags are otherwise a wall of comma-separated noise.

    CategoryBooru Toolkit/Posts

    Inputs (6)

    NameTypeDefaultDescription
    urlSTRINGEnter the booru post URL
    img_sizeCOMBOsampleSelect the image size variant to output through 'IMAGE'. Choose 'none' to output a blank image. For e6, anything below sample will be 'preview'
    format_tagsBOOLEANtrueFormat tags for prompt use. Removes underscores and adds backslashes to brackets
    trailing_commaBOOLEANfalseAppends a comma to the last tag in each output
    exclude_tagsBOOLEANtrueToggle exclusion of tags from output
    user_excluded_tagsSTRINGconditional dnp, sound_warning, unknown_artist, third-party_edit, anonymous_artist, e621, e621 post recursion, e621_comment, patreon, patreon logo, patreon username, instagram username, text, dialogueComma separated list of tags to exclude for output (they can include underscores or spaces, with or without backslashes)

    Outputs (4)

    NameTypeDescription
    IMAGEIMAGE
    ALL_TAGSSTRING
    ORIGINAL_WIDTHINT
    ORIGINAL_HEIGHTINT