Image Generation
Learn how to generate images.
Generate Images
DeepFellow API provides an images/generations endpoint that lets you generate images from a text prompt.
Example code for generating an image:
curl -w '\n' -X 'POST' \
'https://deepfellow-server-host/v1/images/generations' \
-H 'Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "An image of ...",
"model": "CyberRealistic-XL-FP16",
"response_format": "b64_json"
}' | jq -r ".data[0].b64_json" | base64 -d > image.pngCustomize Image Output
You can configure the following output options:
- Size: Image dimensions (e.g.
1024x1024,1024x1536) - Quality: Rendering quality (e.g.
low,medium,high) - Format: File output format
- Compression: Compression level (0-100%) for
jpegandwebpformats - Background: Transparent or opaque
- Number of images: How many images to generate per request
Parameters size, quality, and background support the auto option, where the model will automatically select the best option based on the prompt.
Size and Quality Options
Square images with standard quality are the fastest to generate. The default size is auto, which currently resolves to 512x512 unless the model overrides it.
Available sizes:
- 1024x1024 (square)
- 1536x1024 (landscape)
- 1024x1536 (portrait)
- auto (default, resolves to 512x512)
Quality options:
- low
- medium
- high
- standard
- hd
- auto (default)
Output Format
The API returns base64-encoded image data. The default format is png, but you can also request jpeg or webp.
If using jpeg or webp, you can also specify the output_compression parameter to control the compression level (0-100%). For example, output_compression=50 will compress the image by 50%.
If background is set to transparent, output_format will be png or webp, since jpeg does not support transparency.
To read more about image generation, visit OpenAI API Documentation
Additional Parameters
The endpoint accepts the following parameters in addition to size, quality, background, output_format, and output_compression:
| Parameter | Description |
|---|---|
n | The number of images to generate. Must be between 1 and 10. Default: 1. |
moderation | The content-moderation strictness. Must be one of low or auto. Default: auto. |
style | The visual style of the generated images. Must be one of vivid or natural. vivid leans towards hyper-real and dramatic images; natural produces more natural, less hyper-real images. Default: vivid. |
user | An identifier representing the end-user, useful for monitoring and detecting abuse. |
Fine Control
You can precisely control the look of your generated image by:
- using
v1/images/generationsendpoint parameters (e.g.,size,background,quality), - injecting stable diffusion generation parameters into your prompt using
<sd> {JSON} </sd>tags:
curl -w '\n' -X 'POST' \
'https://deepfellow-server-host/v1/images/generations' \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "\n<sd>\n{\n \"prompt\": \"blue, rose, 8k, cinematic macro shot, soft focus, dreamlike ambiance\",\n \"negative_prompt\": \"nsfw, bad anatomy, blurry, low-quality\",\n \"sampler_name\": \"DPM++ 2M\",\n \"hr_sampler_name\": \"Kerras\",\n \"clip_skip\": 2,\n \"steps\": 32,\n \"cfg_scale\": 7\n}\n</sd>\n",
"model": "CyberRealistic-XL-FP16",
"size": "auto",
"quality": "medium",
"background": "auto",
"output_compression": 95,
"output_format": "png",
"response_format": "b64_json"
}'| jq -r '.data[0].b64_json' | base64 -d > rose.pngUsing Low-Rank Adapters (LoRA)
Low-rank adapters allow you to tune the output of your model while keeping its base capabilities intact. Using LoRA is analogous to postproduction in the movie industry where, after shooting, the material is edited, color-graded, etc.
In case of image generation, the base model can generate the scene and then LoRA can change the tone, color-grading, or style of the scene to get the desired result. You need two stable-diffusion models to do this:
- base model (any stable-diffusion model that can generate images)
- LoRA model
In a single image generation request, both models are used.
Example
curl -w '\n' -X 'POST' \
'https://deepfellow-server-host/v1/images/generations' \
-H "Authorization: Bearer DEEPFELLOW_PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "<sd>\n{\n \"prompt\": \"valley <lora:Fantastic_Landscape-LoRA:0.3>, cinematic lighting, colorful, extreme detail\",\n \"negative_prompt\": \"verybadimagenegative_v1.3, vignetting, bokeh, out of focus, distortion\",\n \"sampler_name\": \"Euler a\",\n \"hr_sampler_name\": \"Karras\",\n \"clip_skip\": 2,\n \"steps\": 20,\n \"cfg_scale\": 7\n}\n</sd>",
"model": "yomama-2.5D",
"size": "1024x1024",
"quality": "medium",
"background": "auto",
"output_compression": 95,
"output_format": "png",
"response_format": "b64_json"
}' | jq -r '.data[0].b64_json' | base64 -d >image.pngWe use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.