Documentation Index Fetch the complete documentation index at: https://docs.hyperbolic.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Image Generation APIs
Sunset Notice: All image generation models on this page are being discontinued. These models will be removed in a future update. Please plan your migration accordingly.
Generate stunning images from text prompts using state-of-the-art diffusion models. Choose from FLUX.1-dev for best quality, SDXL for versatility, or Stable Diffusion for classic reliability.
Endpoint
POST https://api.hyperbolic.xyz/v1/image/generation
Basic Example
import requests
import base64
url = "https://api.hyperbolic.xyz/v1/image/generation"
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_API_KEY"
}
data = {
"model_name" : "FLUX.1-dev" ,
"prompt" : "A futuristic city skyline at sunset, cyberpunk style, neon lights" ,
"height" : 1024 ,
"width" : 1024 ,
"steps" : 30 ,
"cfg_scale" : 5
}
response = requests.post(url, headers = headers, json = data)
result = response.json()
# Decode and save the image
image_data = base64.b64decode(result[ "images" ][ 0 ][ "image" ])
with open ( "generated_image.png" , "wb" ) as f:
f.write(image_data)
curl -X POST "https://api.hyperbolic.xyz/v1/image/generation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "FLUX.1-dev",
"prompt": "A futuristic city skyline at sunset, cyberpunk style, neon lights",
"height": 1024,
"width": 1024,
"steps": 30,
"cfg_scale": 5
}' | jq -r ".images[0].image" | base64 -d > generated_image.png
Request Parameters
Required Parameters
Parameter Type Description model_namestring Model ID (e.g., FLUX.1-dev, SDXL1.0-base) promptstring Text description of the image to generate
Optional Parameters
Parameter Type Default Description heightinteger 1024 Image height in pixels widthinteger 1024 Image width in pixels stepsinteger 30 Number of inference steps (more = higher quality, slower) cfg_scalefloat 5 Prompt relevance (higher = closer to prompt, typically 5-15) negative_promptstring - What to avoid in the generated image seedinteger - Random seed for reproducible results samplerstring - Sampling algorithm to use backendstring auto Computation backend: auto, tvm, or torch
SDXL-Specific Parameters
Parameter Type Description prompt_2string Secondary prompt for SDXL models negative_prompt_2string Secondary negative prompt for SDXL enable_refinerboolean Enable SDXL refiner for enhanced details
The API returns a JSON object containing base64-encoded image data:
{
"images" : [
{
"image" : "iVBORw0KGgoAAAANSUhEUgAA..."
}
]
}
Decoding the Response
import base64
def save_image ( response_json , filename = "output.png" ):
"""Decode and save the generated image."""
image_data = base64.b64decode(response_json[ "images" ][ 0 ][ "image" ])
with open (filename, "wb" ) as f:
f.write(image_data)
Available Models
Model Model ID Best For FLUX.1-dev ⚠️ Sunset FLUX.1-devBest quality, outstanding prompt following SDXL 1.0 ⚠️ Sunset SDXL1.0-baseHigh-quality, versatile, supports LoRA SDXL Turbo ⚠️ Sunset SDXL-turboFast generation Stable Diffusion 2 ⚠️ Sunset SD2Good balance of speed and quality Stable Diffusion 1.5 ⚠️ Sunset SD1.5Classic, reliable, supports LoRA Segmind SD 1B ⚠️ Sunset SSDDomain-specific applications
Model Recommendations
Choosing the right model:
Best quality: FLUX.1-dev for outstanding prompt following and visual quality
Fast generation: SDXL Turbo for quick iterations
Image-to-image: SDXL 1.0 or SD1.5 (FLUX does not support image-to-image)
LoRA support: SDXL 1.0 or SD1.5 for style customization
Supported Resolutions
All image models support the following resolutions:
Resolution Aspect Ratio 1024 x 1024 1:1 (Square) 1152 x 896 ~4:3 1216 x 832 ~3:2 1344 x 768 ~16:9 1536 x 640 ~2.4:1 (Ultrawide) 1664 x 2432 ~2:3 (Portrait) 2048 x 2048 1:1 (Large Square) 2432 x 1664 ~3:2 (Landscape) 640 x 1536 ~1:2.4 (Tall) 768 x 1344 ~9:16 (Portrait) 832 x 1216 ~2:3
Pricing
Base rate: $0.01 per image at 1024x1024 resolution with 25 steps.
Pricing formula:
Price = $0.01 × (width/1024) × (height/1024) × (steps/25)
Pricing Examples
Resolution Steps Price 1024 x 1024 25 $0.01 1024 x 1024 50 $0.02 2048 x 2048 25 $0.04 2048 x 2048 50 $0.08 512 x 512 25 $0.0025
Image-to-Image Generation
Transform existing images using a reference image. Supported by Stable Diffusion models only.
import requests
import base64
from PIL import Image
from io import BytesIO
def encode_image ( image_path ):
"""Encode an image file to base64."""
with Image.open(image_path) as img:
buffered = BytesIO()
img.save(buffered, format = "PNG" )
return base64.b64encode(buffered.getvalue()).decode( "utf-8" )
# Encode your reference image
reference_image = encode_image( "input_image.png" )
url = "https://api.hyperbolic.xyz/v1/image/generation"
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_API_KEY"
}
data = {
"model_name" : "SDXL1.0-base" ,
"prompt" : "A watercolor painting of the same scene" ,
"image" : reference_image,
"strength" : 0.7 ,
"height" : 1024 ,
"width" : 1024 ,
"steps" : 30
}
response = requests.post(url, headers = headers, json = data)
result = response.json()
# Save the result
image_data = base64.b64decode(result[ "images" ][ 0 ][ "image" ])
with open ( "transformed_image.png" , "wb" ) as f:
f.write(image_data)
# First encode your image: base64 -i input.png -o input_base64.txt
curl -X POST "https://api.hyperbolic.xyz/v1/image/generation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "SDXL1.0-base",
"prompt": "A watercolor painting of the same scene",
"image": "YOUR_BASE64_ENCODED_IMAGE",
"strength": 0.7,
"height": 1024,
"width": 1024,
"steps": 30
}' | jq -r ".images[0].image" | base64 -d > transformed_image.png
Image-to-Image Parameters
Parameter Type Description imagestring Base64-encoded reference image strengthfloat Transformation strength (0-1). Higher values = more change from original
Strength guide:
0.3-0.5: Subtle changes, preserves most of the original
0.5-0.7: Moderate transformation
0.7-1.0: Major changes, original is mostly a guide
Image-to-image is supported by Stable Diffusion models only. FLUX.1-dev does not support this feature.
LoRA Adapters
LoRA (Low-Rank Adaptation) adapters let you apply custom styles to your generated images. Available for SDXL and SD1.5 models.
Available LoRAs
SDXL LoRAs:
LoRA Name Style Add_DetailEnhanced details More_ArtArtistic style Pixel_ArtPixel art style LogoLogo design Sci-fiScience fiction CrayonsCrayon drawing Paint_SplashPaint splash effect Outdoor_Product_PhotographyProduct photography
SD1.5 LoRAs:
LoRA Name Style Add_DetailEnhanced details SuperheroComic superhero style LineartLine art Anime_LineartAnime-style line art Cartoon_BackgroundCartoon backgrounds Pencil_SketchPencil sketch
Using LoRAs
import requests
import base64
url = "https://api.hyperbolic.xyz/v1/image/generation"
headers = {
"Content-Type" : "application/json" ,
"Authorization" : "Bearer YOUR_API_KEY"
}
data = {
"model_name" : "SDXL1.0-base" ,
"prompt" : "a cute cat" ,
"height" : 1024 ,
"width" : 1024 ,
"lora" : { "Pixel_Art" : 1.0 }
}
response = requests.post(url, headers = headers, json = data)
result = response.json()
image_data = base64.b64decode(result[ "images" ][ 0 ][ "image" ])
with open ( "pixel_cat.png" , "wb" ) as f:
f.write(image_data)
curl -X POST "https://api.hyperbolic.xyz/v1/image/generation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "SDXL1.0-base",
"prompt": "a cute cat",
"height": 1024,
"width": 1024,
"lora": {"Pixel_Art": 1.0}
}' | jq -r ".images[0].image" | base64 -d > pixel_cat.png
Combining Multiple LoRAs
Mix multiple LoRAs by adjusting their weights (0.0-1.0):
data = {
"model_name" : "SDXL1.0-base" ,
"prompt" : "a cute cat logo" ,
"height" : 1024 ,
"width" : 1024 ,
"lora" : {
"Pixel_Art" : 0.5 ,
"Logo" : 0.5 ,
"Paint_Splash" : 0.9
}
}
Experiment with different weight combinations to achieve unique styles. Lower weights apply subtle influence, while higher weights create stronger effects.
Backend Options
Backend Description autoAutomatically selects the best backend (recommended) tvmOptimized for speed using TVM torchPyTorch backend, more flexible
Tips for Better Results
Prompt Writing
Be specific: “A golden retriever puppy playing in autumn leaves, soft sunlight” works better than “a dog”
Include style: Add artistic style keywords like “photorealistic”, “oil painting”, “anime style”
Describe lighting: Mention lighting conditions like “soft natural light”, “dramatic shadows”, “neon glow”
Using Negative Prompts
Exclude unwanted elements:
data = {
"model_name" : "FLUX.1-dev" ,
"prompt" : "professional portrait photo of a woman" ,
"negative_prompt" : "blurry, low quality, distorted, deformed" ,
"height" : 1024 ,
"width" : 1024
}
Reproducible Results
Use the seed parameter to generate the same image:
data = {
"model_name" : "FLUX.1-dev" ,
"prompt" : "a magical forest" ,
"seed" : 42 ,
"height" : 1024 ,
"width" : 1024
}
CFG Scale Guide
1-5: More creative, may deviate from prompt
5-10: Balanced (recommended)
10-15: Closely follows prompt
15+: Very strict, may reduce quality
Next Steps
Text APIs Generate text with large language models
Vision Language Models Analyze images with multimodal AI
Audio APIs Text-to-speech generation