Liblib Comfy Fusion Generation
Generate images with LiblibAI ComfyUI App API (template-based workflow). Supports public image URL or local file.
For local files from Feishu, the recommended flow is:
- upload the local file to R2 (S3-compatible) to get a public URL
- use that public URL as the Liblib
LoadImageinput - return the Liblib result
imageUrlasMEDIA:https://...so Feishu displays it directly
Prerequisites
Environment variables must be set:
LIB_ACCESS_KEY— API access keyLIB_SECRET_KEY— API secret key
Usage
Run the CLI at scripts/liblib_client.py:
# Public URL input
python3 scripts/liblib_client.py run --image-url "https://example.com/input.jpg"
# Local file (Feishu inbound attachment) → upload to R2 → use public URL
python3 scripts/liblib_client.py run --local-image "/path/to/input.png" --basename "product-fusion"
# Local file (advanced): embed as data URI (only if Liblib accepts it)
python3 scripts/liblib_client.py run --local-image "/path/to/input.png" --local-image-mode data-uri
# Parse URL from Feishu message text
python3 scripts/liblib_client.py run --feishu-text "请处理这个图 https://example.com/input.jpg"
# Submit only (no poll)
python3 scripts/liblib_client.py run --local-image "./input.jpg" --no-poll
# Query task status
python3 scripts/liblib_client.py status <generateUuid>
Output and Feishu 回传
- After a successful run (
generateStatus=5), the script downloadsimages[].imageUrlintoworkspace/outputs/images/YYYY-MM-DD/<basename>.(png|jpg|...)(override with--output-dir). - stdout prints a single line:
MEDIA:./outputs/images/YYYY-MM-DD/<file>(relative toworkspace/). Use this with OpenClaw Feishu channel so the image appears in the current chat without extra API calls. - Full task JSON is printed to stderr for debugging.
- If
MEDIA:is not supported in your channel, usefeishu-uploaderwith--receive-id-type chat_idand the groupchat_id, or--open-idfor DM.
Parameters (run)
| Flag | Meaning |
|---|---|
--local-image | Local path; takes priority over URL. Default mode uploads to R2 and uses public URL. |
--local-image-mode | r2 (default) or data-uri. |
--image-url | Public URL the Liblib servers can fetch. |
--feishu-text / FEISHU_TEXT | Extract first http(s) URL from text. |
--output-dir | Default: <workspace>/outputs/images. |
--basename | Filename stem (default liblib-fusion). |
--no-download | Skip downloading result files. |
--no-print-media | Do not print MEDIA: line; stdout prints absolute path of first saved file instead. |
API Details
- Submit endpoint:
POST /api/generate/comfyui/app - Status endpoint:
POST /api/generate/comfy/status - Auth query params:
AccessKey,Signature,Timestamp,SignatureNonce - Signature algorithm:
- content =
uriPath & Timestamp & SignatureNonce HMAC-SHA1(secretKey, content)- URL-safe Base64 without trailing
=
- content =
Async Pattern
- Submit task to get
generateUuid - Poll status endpoint until
generateStatusis 5 (success) or 6 (failed) - Read
images[].imageUrlwhen successful
Notes
- URL input: must be publicly reachable by Liblib.
- Local input: default uses R2 upload to produce a public URL. Requires
boto3. - Returned image URLs are temporary (typically ~7 days).
- If API returns content review errors, try a different source image or URL.