Skill: dustinparsons/drawthings (version 1.0.0)

--- name: drawthings description: Generate images with DrawThings (Stable Diffusion) via API. Use when creating images from text prompts, running image generation workflows, or batch generating images. DrawThings runs locally on Mac with MLX/CoreML acceleration. metadata: openclaw: emoji: "🎨" requires: env: ["DRAWTHINGS_URL"] --- # DrawThings Image Generation Generate images using DrawThings, a local Stable Diffusion implementation for Mac with MLX/CoreML acceleration. DrawThings exposes an Automatic1111-compatible API for programmatic image generation. ## When to Use Use this skill when you need to: - Generate images from text prompts - Create variations of a concept - Batch generate multiple images - Test different models/samplers/settings - Generate images with specific dimensions or quality settings ## Configuration Set the `DRAWTHINGS_URL` environment variable (defaults to http://127.0.0.1:7860): ```bash export DRAWTHINGS_URL="http://127.0.0.1:7860" ``` Or configure in OpenClaw: ```bash openclaw config set env.DRAWTHINGS_URL "http://127.0.0.1:7860" ``` ## Quick Start Generate a single image: ```bash python3 scripts/generate.py "a cyberpunk cat in neon city" ``` With custom settings: ```bash python3 scripts/generate.py "a cyberpunk cat" \ --steps 20 \ --cfg-scale 7.5 \ --width 768 \ --height 768 \ --sampler "DPM++ 2M Karras" ``` Batch generation (5 variations): ```bash python3 scripts/generate.py "a fantasy landscape" --batch-size 5 ``` Save to specific location: ```bash python3 scripts/generate.py "portrait photo" --output ./outputs/portrait.png ``` ## API Usage The skill provides a Python script that wraps the DrawThings API (Automatic1111-compatible): **Main endpoint:** `POST /sdapi/v1/txt2img` **Common parameters:** - `prompt` - Text description of the image - `negative_prompt` - What to avoid in the image - `steps` - Number of diffusion steps (8-50, default: 20) - `sampler_name` - Sampler algorithm (default: "DPM++ 2M Karras") - `cfg_scale` - Classifier-free guidance scale (1.0-20.0, default: 7.0) - `width` / `height` - Image dimensions (default: 512x512) - `batch_size` - Number of images to generate (default: 1) - `seed` - Random seed for reproducibility (-1 for random) See `references/api-reference.md` for complete API documentation. ## Presets **Fast (8 steps, UniPC Trailing):** ```bash python3 scripts/generate.py "your prompt" --preset fast ``` **Quality (30 steps, DPM++ 2M Karras):** ```bash python3 scripts/generate.py "your prompt" --preset quality ``` **NFT (optimized for 512x512 with good detail):** ```bash python3 scripts/generate.py "your prompt" --preset nft ``` ## Workflow Examples **Character variations:** ```bash python3 scripts/generate.py "electric sheep, glowing wool, cyberpunk" \ --batch-size 10 \ --steps 20 \ --cfg-scale 7.5 ``` **High-res output:** ```bash python3 scripts/generate.py "detailed portrait" \ --width 1024 \ --height 1024 \ --steps 30 \ --sampler "DPM++ 2M Karras" ``` **Reproducible generation:** ```bash python3 scripts/generate.py "landscape" --seed 42 # Re-run with same seed for identical output ``` ## Output Images are saved as PNG files with metadata embedded: - Prompt, negative prompt - Generation parameters (steps, sampler, cfg_scale, etc.) - Timestamp and seed Default location: `./drawthings_output_YYYYMMDD_HHMMSS.png` ## Troubleshooting **"Connection refused"** - Ensure DrawThings is running - Check the API server is enabled in DrawThings preferences - Verify the port matches (default: 7860) **"Generation failed"** - Check prompt length (max ~75 tokens per CLIP model) - Reduce dimensions if out of memory - Try a different sampler **Slow generation** - Use fewer steps (8-12 for drafts) - Reduce image dimensions (512x512) - Use faster samplers (UniPC, Euler A) **Canvas display quirk (visual only)** - DrawThings UI doesn't clear the canvas between generations - New images appear to render on top of previous ones in the app - This is purely cosmetic - API outputs are unaffected ## Tips - **CFG Scale**: Lower (1-3) for creative/artistic, higher (7-12) for prompt adherence - **Steps**: 8-12 for drafts, 20-30 for final images, 50+ rarely needed - **Samplers**: UniPC/Euler A are fast, DPM++ 2M Karras is quality, LCM for ultra-fast - **Dimensions**: Keep to multiples of 64 (512, 768, 1024) - **Batch processing**: Use `--batch-size` for variations, not multiple script calls ## Models DrawThings supports Stable Diffusion models. To change models: 1. Open DrawThings app 2. Select model from the UI 3. The API will use the currently selected model See `references/models.md` for recommended models and download sources.

path: references/api-reference.md
content: ## DrawThings API Reference

DrawThings exposes an Automatic1111-compatible REST API for programmatic image generation.

### Base URL

Default: `http://127.0.0.1:7860`

Configure via `$DRAWTHINGS_URL` environment variable.

### Text-to-Image Generation

**Endpoint:** `POST /sdapi/v1/txt2img`

**Request Body:**

```json
{
  "prompt": "a cute cat in a cyberpunk city",
  "negative_prompt": "blurry, low quality",
  "steps": 20,
  "sampler_name": "DPM++ 2M Karras",
  "cfg_scale": 7.0,
  "width": 512,
  "height": 512,
  "batch_size": 1,
  "seed": -1
}
```

**Parameters:**

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `prompt` | string | required | Text description of the image to generate |
| `negative_prompt` | string | `""` | What to avoid in the image |
| `steps` | integer | `20` | Number of diffusion steps (8-150) |
| `sampler_name` | string | `"DPM++ 2M Karras"` | Sampling algorithm |
| `cfg_scale` | float | `7.0` | Classifier-free guidance scale (1.0-30.0) |
| `width` | integer | `512` | Image width (64-2048, multiples of 64) |
| `height` | integer | `512` | Image height (64-2048, multiples of 64) |
| `batch_size` | integer | `1` | Number of images to generate (1-8) |
| `seed` | integer | `-1` | Random seed (-1 for random) |

**Available Samplers:**

- `"DPM++ 2M Karras"` - High quality, balanced speed
- `"DPM++ 2M"` - Similar to Karras, slightly different noise schedule
- `"Euler A"` - Fast, good for drafts
- `"Euler"` - Deterministic version of Euler A
- `"UniPC Trailing"` - Very fast, 8-12 steps
- `"LCM"` - Ultra-fast, requires LCM models
- `"DDIM"` - Classic sampler
- `"PLMS"` - Classic sampler

**Response:**

```json
{
  "images": ["base64_encoded_png_1", "base64_encoded_png_2"],
  "parameters": {
    "prompt": "a cute cat in a cyberpunk city",
    "steps": 20,
    "sampler_name": "DPM++ 2M Karras",
    "cfg_scale": 7.0,
    "seed": 1234567890,
    "width": 512,
    "height": 512
  },
  "info": "{\"seed\": 1234567890, \"all_prompts\": [...], ...}"
}
```

The `images` array contains base64-encoded PNG data. The `info` field is a JSON string with detailed generation metadata.

### Get Options

**Endpoint:** `GET /sdapi/v1/options`

Returns current DrawThings configuration including available models, samplers, and settings.

### Set Options

**Endpoint:** `POST /sdapi/v1/options`

Update DrawThings configuration (e.g., change active model).

**Example:**
```json
{
  "sd_model_checkpoint": "model_name.safetensors"
}
```

### Get Models

**Endpoint:** `GET /sdapi/v1/sd-models`

Returns list of available Stable Diffusion models.

**Response:**
```json
[
  {
    "title": "sd_xl_base_1.0",
    "model_name": "sd_xl_base_1.0",
    "hash": "..."
  }
]
```

### Get Samplers

**Endpoint:** `GET /sdapi/v1/samplers`

Returns list of available sampling algorithms.

**Response:**
```json
[
  {"name": "DPM++ 2M Karras"},
  {"name": "Euler A"},
  {"name": "UniPC Trailing"}
]
```

### Progress Polling

**Endpoint:** `GET /sdapi/v1/progress`

Check generation progress for long-running operations.

**Response:**
```json
{
  "progress": 0.65,
  "eta_relative": 12.5,
  "state": {
    "sampling_step": 13,
    "sampling_steps": 20
  }
}
```

### Interrupt Generation

**Endpoint:** `POST /sdapi/v1/interrupt`

Stop the current generation.

## Tips

**CFG Scale Guidelines:**
- 1.0-3.0: Highly creative, may drift from prompt
- 5.0-8.0: Balanced (recommended)
- 10.0-15.0: Very literal interpretation
- 15.0+: Often over-saturated

**Steps Guidelines:**
- 8-12: Fast drafts (UniPC/Euler A)
- 20-30: Standard quality (DPM++ 2M Karras)
- 50+: Diminishing returns

**Dimension Guidelines:**
- Use multiples of 64 (512, 576, 640, 768, 1024)
- SD 1.5 models trained on 512x512
- SDXL models trained on 1024x1024
- Non-square ratios supported (e.g., 768x512 for landscape)

**Batch Size:**
- Generates variations with different seeds
- Uses same prompt/settings for all images
- Faster than multiple separate requests


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)