Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate images via Stable Diffusion (HuggingFace Diffusers, local/API)
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 38% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 105% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 36% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 119% | 0% |
| case-09 | ✓→✗ | ▼ Worse | 37% | 0% |
Generate images from text prompts using Stable Diffusion locally via HuggingFace Diffusers, or via the HuggingFace Inference API for zero-install operation.
pythonimport requests, base64, os def generate_image_api(prompt, output="output.png"): api_url = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0" headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"} resp = requests.post(api_url, headers=headers, json={"inputs": prompt}, timeout=120) resp.raise_for_status() with open(output, "wb") as f: f.write(resp.content) print(f"Saved: {output}") # Set HF_TOKEN in env: huggingface.co/settings/tokens generate_image_api("a futuristic city at night, cyberpunk style, neon lights, 8k")
python# pip install diffusers transformers accelerate torch from diffusers import StableDiffusionXLPipeline import torch pipe = StableDiffusionXLPipeline.from_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True ) pipe = pipe.to("cuda") # use "cpu" if no GPU (very slow) image = pipe( prompt="a majestic mountain landscape at golden hour, photorealistic", negative_prompt="blurry, low quality, cartoon", num_inference_steps=30, guidance_scale=7.5, width=1024, height=1024 ).images[0] image.save("landscape.png") print("Saved: landscape.png")
pythonimages = pipe( prompt="a robot reading a book in a cozy library", num_images_per_prompt=4, num_inference_steps=25, ).images for i, img in enumerate(images): img.save(f"variation_{i+1}.png") print(f"Saved variation_{i+1}.png")
Good prompt structure:
[subject], [style], [setting/background], [lighting], [quality tags]
Examples:
"a golden retriever puppy, oil painting style, in a sunlit meadow, warm afternoon light, highly detailed"
"abstract data visualization, dark background, glowing cyan lines, geometric patterns, 4k"
"portrait of a scientist, dramatic studio lighting, photorealistic, sharp focus, professional headshot"Useful negative prompt additions:
"blurry, low quality, watermark, signature, deformed, extra limbs, bad anatomy, poorly drawn"pythonfrom diffusers import StableDiffusionPipeline import torch pipe = StableDiffusionPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float32 ) image = pipe( prompt="a simple landscape, watercolor style", num_inference_steps=15, # fewer steps = faster on CPU width=512, height=512 # smaller size for CPU ).images[0] image.save("output.png")
"Generate an image of a futuristic AI lab" → Use step 1 (API) if HF_TOKEN is set. Prompt: "futuristic AI research lab, holographic displays, clean aesthetic, cinematic lighting".
"Create 4 variations of a logo concept for a tech startup" → Use step 3 with a logo-style prompt and num_images_per_prompt=4.
"Generate an image locally without internet" → Use step 2 (local Diffusers). SDXL needs ~8GB VRAM; for CPU use step 5 with SD v1.5 at 512×512.
HF_TOKEN must be set as an environment variable — never hardcode it in scriptsOther measured skills in the registry, with their headline benchmark lift.