Generate Image
curl --request POST \
--url https://api.example.com/api/images/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "<string>",
"size": "<string>",
"n": 123,
"steps": 123,
"negative_prompt": "<string>"
}
'import requests
url = "https://api.example.com/api/images/generations"
payload = {
"prompt": "<string>",
"model": "<string>",
"size": "<string>",
"n": 123,
"steps": 123,
"negative_prompt": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: '<string>',
size: '<string>',
n: 123,
steps: 123,
negative_prompt: '<string>'
})
};
fetch('https://api.example.com/api/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'model' => '<string>',
'size' => '<string>',
'n' => 123,
'steps' => 123,
'negative_prompt' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123,\n \"steps\": 123,\n \"negative_prompt\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/images/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123,\n \"steps\": 123,\n \"negative_prompt\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123,\n \"steps\": 123,\n \"negative_prompt\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"url": "<string>"
}Files & Media
Generate Image
POST
/
api
/
images
/
generations
Generate Image
curl --request POST \
--url https://api.example.com/api/images/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "<string>",
"size": "<string>",
"n": 123,
"steps": 123,
"negative_prompt": "<string>"
}
'import requests
url = "https://api.example.com/api/images/generations"
payload = {
"prompt": "<string>",
"model": "<string>",
"size": "<string>",
"n": 123,
"steps": 123,
"negative_prompt": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
model: '<string>',
size: '<string>',
n: 123,
steps: 123,
negative_prompt: '<string>'
})
};
fetch('https://api.example.com/api/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'model' => '<string>',
'size' => '<string>',
'n' => 123,
'steps' => 123,
'negative_prompt' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123,\n \"steps\": 123,\n \"negative_prompt\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/images/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123,\n \"steps\": 123,\n \"negative_prompt\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123,\n \"steps\": 123,\n \"negative_prompt\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"url": "<string>"
}Generate images from text prompts using various AI image generation engines including OpenAI DALL-E, Gemini Imagen, ComfyUI, and Automatic1111.
Request
Headers
string
required
Bearer token for authentication
Body
string
required
Text description of the image to generate
string
Model to use for generation. Defaults to configured model.OpenAI models:
dall-e-2dall-e-3gpt-image-1gpt-image-1.5
imagen-3.0-generate-002
string
Image dimensions in format
WIDTHxHEIGHT (e.g., 512x512, 1024x1024)Can also be auto for models that support dynamic sizing.number
default:"1"
Number of images to generate
number
Number of inference steps (for Stable Diffusion-based engines)
string
Negative prompt describing what to avoid in the image (for Stable Diffusion-based engines)
Response
Returns an array of generated image objects.string
URL path to access the generated image file
Example
curl -X POST https://your-domain.com/api/images/generations \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene mountain landscape at sunset with a lake",
"model": "dall-e-3",
"size": "1024x1024",
"n": 1
}'
Response
[
{
"url": "/api/v1/files/550e8400-e29b-41d4-a716-446655440000/content"
}
]
Supported Engines
Configure the image generation engine in Admin Settings > Images:OpenAI DALL-E
- Cloud-based image generation
- Models: DALL-E 2, DALL-E 3, GPT-IMAGE series
- Requires OpenAI API key
- Supports various sizes depending on model
Gemini Imagen
- Google’s Imagen 3.0 model
- Two endpoint methods:
predictorgenerateContent - Requires Google API key
ComfyUI
- Local/self-hosted image generation
- Highly customizable workflows
- Supports custom models and nodes
- Configure workflow JSON and node mappings
Automatic1111 (Stable Diffusion WebUI)
- Popular Stable Diffusion interface
- Full control over generation parameters
- Supports negative prompts and custom steps
- Optional API authentication
Advanced Parameters
For Stable Diffusion-based engines (ComfyUI, Automatic1111):{
"prompt": "A futuristic city at night",
"negative_prompt": "blurry, low quality, distorted",
"size": "768x768",
"steps": 50,
"n": 2
}
Image Storage
Generated images are:- Automatically uploaded to the files system
- Associated with the user who generated them
- Accessible via the standard file content endpoint
- Linked to chat messages if
chat_idandmessage_idare provided in metadata
Permissions
Requires thefeatures.image_generation permission. Admin users have access by default.
Error Responses
Invalid parameters or generation failed
Image generation is disabled or user lacks permission
Related Endpoints
POST /api/images/edit- Edit existing images with promptsGET /api/images/models- List available models for current engineGET /api/images/config- Get image generation configuration (admin only)