hf-sdxl-image
by @slippersheepig
Generate an image from a text prompt through the Hugging Face Inference API using stabilityai/stable-diffusion-xl-base-1.0 and the HUGGINGFACE_TOKEN environm...
clawhub install hf-sdxl-image📖 About This Skill
name: hf-sdxl-image description: Generate an image from a text prompt through the Hugging Face Inference API using stabilityai/stable-diffusion-xl-base-1.0 and the HUGGINGFACE_TOKEN environment variable. Use when the user asks to generate, draw, create, make, or render an image or illustration from text, especially when they mention Hugging Face, SDXL, or Stable Diffusion XL. Save the generated image to a temporary local path, let OpenClaw send it to the current conversation window, and remove the temporary file after successful delivery unless the user explicitly asks to keep a saved copy.
HF SDXL Image
Generate a single image from a text prompt with the Hugging Face router endpoint. The skill defaults to stabilityai/stable-diffusion-xl-base-1.0 and can be switched to another compatible Hugging Face Inference API model by setting HF_IMAGE_MODEL.
Chat-oriented workflow
When you ask to generate an image:
1. Convert your request into a prompt.
2. Run scripts/generate_hf_sdxl.py with the --output /tmp/openclaw/ argument.
3. The script saves the image to a temporary path and prints the file path to stdout.
4. Send the image back through the current conversation provider's required image/file-send format.
5. After successful delivery, delete the temporary file unless the user explicitly asked to keep it.
Provider-specific delivery rule
This skill only generates and saves an image file. It does not define a universal send format.
When returning the image in chat, always follow the current session provider's required outbound media format. Different providers may require different delivery methods, wrappers, or tools. Do not assume that simply reading a local file path, pasting a path, or relying on one provider's auto-routing behavior will work on another provider.
Required behavior:
Examples of what to avoid:
read on an image path will always send the image correctly.Strong trigger examples
Use this skill for requests like:
Command
Default delivery workflow:
python3 scripts/generate_hf_sdxl.py "a cozy cyberpunk alley at night, cinematic lighting" --wait-for-model --output /tmp/openclaw/
With a model override:
HF_IMAGE_MODEL=stabilityai/stable-diffusion-3-medium-diffusers python3 scripts/generate_hf_sdxl.py "a cozy cyberpunk alley at night, cinematic lighting" --wait-for-model --output /tmp/openclaw/
Use a temporary directory for normal chat delivery. Only point --output at a persistent user-chosen location when the user explicitly asks to save or export the image.
Behavior
--output and saves the generated image to that path or directoryParameters
Troubleshooting
Missing token
If the script says Missing HUGGINGFACE_TOKEN environment variable., export the token before running it.
export HUGGINGFACE_TOKEN=hf_xxx
Optional model override
To switch to another compatible Hugging Face Inference API model, set HF_IMAGE_MODEL.
export HF_IMAGE_MODEL=stabilityai/stable-diffusion-3-medium-diffusers
If HF_IMAGE_MODEL is unset, the script uses stabilityai/stable-diffusion-xl-base-1.0.
401 or 403
The token is missing, invalid, expired, or does not have permission for the endpoint.
503 or model loading errors
Retry with --wait-for-model.
JSON instead of an image
Read the full JSON error body and surface it to the user. Do not pretend generation succeeded.
Storage policy
The default policy is temporary-file delivery.
Resource
scripts/generate_hf_sdxl.py
Use this script for deterministic generation and repeatable testing.
📋 Tips & Best Practices
Missing token
If the script says Missing HUGGINGFACE_TOKEN environment variable., export the token before running it.
export HUGGINGFACE_TOKEN=hf_xxx
Optional model override
To switch to another compatible Hugging Face Inference API model, set HF_IMAGE_MODEL.
export HF_IMAGE_MODEL=stabilityai/stable-diffusion-3-medium-diffusers
If HF_IMAGE_MODEL is unset, the script uses stabilityai/stable-diffusion-xl-base-1.0.
401 or 403
The token is missing, invalid, expired, or does not have permission for the endpoint.
503 or model loading errors
Retry with --wait-for-model.
JSON instead of an image
Read the full JSON error body and surface it to the user. Do not pretend generation succeeded.
Storage policy
The default policy is temporary-file delivery.