Gelbooru (ID)
Pull tags and an image off Gelbooru
- imgtags
- imgurl
- imgid
- width
- height
- source
- IMAGE
You know that feeling: you're browsing Gelbooru, you see a composition you want to riff on, and you think "I wish I had the prompt for this." Gelbooru (ID) is exactly that node. Paste a numeric post ID, and it hands you the post's tags, its direct image URL, dimensions, and source - plus the image itself if you ask. It's the quiet one in the Comfyui-Gelbooru pack (siblings are Gelbooru (Random) and UrlsToImage), but it's the one that feels like magic the first time you wire its tag string straight into a positive prompt and get the character back.
Why this works at all is worth understanding. Illustrious, NoobAI, and the other Danbooru-trained anime models speak booru tag vocabulary natively - 1girl, long_hair, blue_eyes are literal tokens they were trained on. So a real post's tags are a better prompt than anything you'd freehand. Gelbooru's tags are the same lineage as Danbooru's, just a different board, so the output plugs straight into that ecosystem.
How it works
Under the hood it's a single request to Gelbooru's public API - page=dapi&s=post&q=index&id=<id>&json=1. No API key needed, which is a nice contrast to the Random node: the ID lookup endpoint is open. The response tags come space-separated, so the node converts them to comma-separated, and it also grabs file_url, dimensions, and source. The last result is cached to a local gelbooru_prompt_cache.json so use_last_prompt can reuse it without hitting the network again.
One thing the code handles for you: Gelbooru image URLs are served from a CDN and go stale. If the download fails, the node re-queries the post for a fresh URL and retries before giving up and returning a gray "gelbooru not available" placeholder.
The inputs and outputs that matter
Only three inputs, all simple:
- post_id - the numeric ID, grab it from the post URL on gelbooru.com
- use_last_prompt - reuse the previous response instead of re-fetching; handy while you tweak the rest of the workflow
- return_picture - toggle this to also download the image as an IMAGE tensor
Outputs: imgtags (the comma-separated tag string - wire it into a CLIP Text Encode positive prompt), imgurl, imgid, width, height, source, and IMAGE. With return_picture off, the IMAGE output is a blank 1x1 tensor, so don't feed that into a VAE Encode expecting art.
Install
Via ComfyUI Manager, search "Comfyui-Gelbooru". Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/1mckw/Comfyui-Gelbooru.git
Then from the ComfyUI root, install its requirements (requests and boto3 - light, no models to download):
python_embeded\python.exe -m pip install -r custom_nodes\Comfyui-Gelbooru\requirements.txt
Restart ComfyUI and the three "Gelbooru" category nodes appear. (On a normal Python install, swap in python -m pip.)
Gotchas
The most common stumble: you get a gray "gelbooru not available" image. That means the file download failed - usually an expired CDN URL or a hotlink-referrer hiccup. Re-run with use_last_prompt off so it re-fetches. Also: an invalid or deleted post ID returns nothing but blank strings, so double-check the ID if your prompt comes out empty. And remember the tags belong in a Danbooru-trained model's prompt - feeding them into Flux or a natural-language model will give you mush.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| post_id | STRING | Numeric ID of the Gelbooru post to fetch | |
| use_last_prompt | BOOLEAN | false | Reuse the previous API response without making a new request |
| return_picture | BOOLEAN | false | Download the post's image and output as IMAGE tensor |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| imgtags | STRING | All tags of the fetched post, comma-separated |
| imgurl | STRING | Direct file URL of the image |
| imgid | STRING | Post ID on the image board |
| width | INT | Width of the image in pixels |
| height | INT | Height of the image in pixels |
| source | STRING | Source website URL of the post |
| IMAGE | IMAGE | Image tensor (only populated when return_picture is enabled) |