Image Generation
Generate images from text prompts or reference images
The Image Generation API provides synchronous and asynchronous capabilities to generate AI images.
Endpoint
POST /api/ai/images/generations
Request Format
This API endpoint uniquely supports both JSON and multipart/form-data request bodies, allowing you to easily upload reference images without encoding them into base64.
Request Parameters
prompt (String, Required)
The text description of the desired image. Max length: 3000 characters.
model (String, Required)
The image generation model to use.
image (File/URL, Optional)
The reference image for image-to-image generation. When using
multipart/form-data, you can upload a direct file blob.
aspect_ratio (String, Optional)
The aspect ratio of the generated image (e.g.,
16:9,1:1).
Prompt Length Limit
To prevent resource exhaustion, prompts exceeding 3000 characters will be rejected with a 400 Bad Request error (prompt_too_long).
Example Requests
curl -X POST "https://qxan.net/api/ai/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A beautiful sunset over a cybernetic city",
"model": "runninghub-i2i-v1",
"image": ["https://example.com/path/to/reference.jpg"],
"aspect_ratio": "16:9"
}'curl -X POST "https://qxan.net/api/ai/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "prompt=A beautiful sunset over a cybernetic city" \
-F "model=runninghub-i2i-v1" \
-F "image=@/path/to/reference.jpg"const formData = new FormData();
formData.append("prompt", "A beautiful sunset over a cybernetic city");
formData.append("model", "runninghub-i2i-v1");
formData.append("image", fileInput.files[0]); // Uploading a file directly
const response = await fetch('https://qxan.net/api/ai/images/generations', {
method: 'POST',
headers: {
'Authorization': \`Bearer YOUR_API_KEY\`
},
body: formData // Note: Do not set Content-Type header manually when using FormData
});
const data = await response.json();
console.log(data);Response
As this is a synchronous API, it will block until the image is generated and then directly return the final result array containing the image URL(s).
{
"created": 1776403558,
"data": [
{
"url": "https://rh-images.xiaoyaoyou.com/1fed4ce62b6a35e17d9103980f90ef6a/output/ComfyUI_00001_veioc_1776403543.png"
}
]
}