REST API

Our Stable Diffusion models are accessible via REST API. Below you can see a simple cURL example and JSON response for our endpoint, along with explanations of all parameters.

Example

To generate your own image, send a POST request as shown below:

curl -X POST "https://api.hyperbolic.xyz/v1/image/generation" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $HYPERBOLIC_API_KEY" \
    -d '{
      "model_name": "SDXL1.0-base",
      "prompt": "a photo of an astronaut riding a horse on mars",
      "height": 1024,
      "width": 1024,
      "backend": "auto"
    }'

Note: you can chain the curl command with | jq -r ".images[0].image" | base64 -d > result.jpg to decode and save the generated image.

Input Parameters

  • model_name: The name of Stable Diffusion models. Supported models include:
    • SDXL1.0-base: Stable Diffusion XL 1.0 huggingface
    • SD2: Stable Diffusion v2 huggingface
    • SD1.5: Stable Diffusion v1-5 huggingface
    • SSD: Segmind Stable Diffusion 1B huggingface
    • SDXL-turbo: SDXL-Turbo huggingface
    • SDXL-ControlNet: SDXL1.0-base + ControlNet
    • SD1.5-ControlNet: SD1.5 + ControlNet
  • prompt: The text description of the image you want to generate.
  • height: Height of the image to generate.
  • width: Width of the image to generate.
  • backend: The computational backend for the model.
    • auto: Automatically selects the most suitable backend.
    • tvm: Optimized for speed with TVM , but supports only specific resolutions (width x height). Check supported tvm resolutions .
    • torch: Popular Pytorch backend, supports various resolutions, average generation speed.

Advanced options

  • prompt_2: Only applies to Stable Diffusion XL.
  • negative_prompt: The text specifying what the model should not generate.
  • negative_prompt_2: Only applies to Stable Diffusion XL.
  • image: The reference image of img-to-img pipeline
  • strength: Indicates extent to transform the reference image. Must be between 0 and 1. image is used as a starting point and more noise is added the higher the strength. The number of denoising steps depends on the amount of noise initially added. When strength is 1, added noise is maximum and the denoising process runs for the full number of iterations specified in num_inference_steps. A value of 1 essentially ignores image.
  • seed: An integer that fixes the randomness of the image generation. Using the same seed generates the same output image.
  • cfg_scale: A float describes the relevance of the output image to the prompt. Higher guidance scale encourages to generate images that are closely linked to the text prompt.
  • sampler: The name of the algorithm used in image generation. Different algorithms yield different image qualities and generation steps.
  • steps: The number of steps that Stable Diffusion models to perform. More steps result in higher quality images but slower generation.
  • style_preset: A topic to guide the image model towards a particular style. Check the supported style_preset.
  • enable_refiner: Only applies to Stable Diffusion XL. Enable Stable Diffusion XL-refiner to refine the image.
  • controlnet_name: The name of ControlNet. Check What is ControlNet
  • controlnet_image: The reference image of ControlNet
  • loras: Pairs of lora name and weight. For example, {"Pixel_Art": 0.7, "Logo": 0.6}. Check What is LoRA