Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Last active May 10, 2024 16:29
Show Gist options
  • Save jamesseanwright/ad588ca8a72a2418ffebd31c2e16200d to your computer and use it in GitHub Desktop.
Save jamesseanwright/ad588ca8a72a2418ffebd31c2e16200d to your computer and use it in GitHub Desktop.
Example HTTP request for Stable Diffusion's txt2img API
curl -X 'POST' https://<HOST>/sdapi/v1/txt2img \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "Photo of a man eating an egg",
"negative_prompt": "",
"seed": -1,
"subseed": -1,
"subseed_strength": 0,
"seed_resize_from_h": -1,
"seed_resize_from_w": -1,
"sampler_name": "DPM++ 3M SDE Karras",
"sd_model_checkpoint": "sd-v1-5-inpainting.ckpt",
"batch_size": 1,
"n_iter": 1,
"steps": 20,
"cfg_scale": 7,
"width": 512,
"height": 512,
"restore_faces": false,
"tiling": false,
"do_not_save_samples": false,
"do_not_save_grid": false,
"eta": 0,
"s_min_uncond": 0,
"s_churn": 0,
"s_tmax": null,
"s_tmin": 0,
"s_noise": 1,
"disable_extra_networks": false,
"enable_hr": true,
"hr_prompt": "Photo of a man eating an egg",
"hr_scale": 2,
"hr_upscaler": "R-ESRGAN 4x+",
"denoising_strength": 0.7,
"firstphase_width": 512,
"firstphase_height": 512,
"send_images": true,
"save_images": false
}' | jq -r '.images[0]' | base64 -d > /tmp/txt2img.jpg && open /tmp/txt2img.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment