API Reference
AI Imager exposes a simple REST API for generating and manipulating images. All endpoints accept multipart/form-data POST requests and return JSON. No authentication required.
Base URL
http://ai-image-gen.xcasper.space
Response Format
All API endpoints return a JSON object with the following shape:
{
"url": ["https://...", "https://..."], // array of image URLs, or null on error
"error": null // error message string, or null on success
}
| Field | Type | Description |
|---|---|---|
url | array<string> | null | List of generated image URLs. null when an error occurred. |
error | string | null | Human-readable error message. null on success. |
Text to Image
Generate one or more images from a text description using the DeepAI engine.
Request Body multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
prompt |
string | Required | Text description of the image to generate. |
total_images |
integer | Required | Number of images to generate (1–4 recommended). |
image_size |
string | Required | Desired resolution. One of 256x256, 512x512, 1024x1024. (Passed through; actual size depends on provider.) |
curl -X POST http://ai-image-gen.xcasper.space/v1/image/prompt/generate \
-F "prompt=A futuristic city skyline at night with neon reflections" \
-F "total_images=2" \
-F "image_size=512x512"
Example Response
{
"url": [
"https://api.deepai.org/job-view-file/abc123/outputs/output.jpg",
"https://api.deepai.org/job-view-file/def456/outputs/output.jpg"
],
"error": null
}
Magic Studio
Generate images using the Magic Studio engine (Casper Tech APIs). Falls back to DeepAI if Magic Studio is unavailable.
Request Body multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Required | Text description of the image to generate. |
total_images | integer | Required | Number of images to generate. |
curl -X POST http://ai-image-gen.xcasper.space/v1/image/bing/generate \
-F "prompt=A magical forest at golden hour with fairy lights" \
-F "total_images=2"
Example Response
{
"url": [
"https://cdn.magicstudio.com/output/image-abc.jpg"
],
"error": null
}
Image + Mask
Upload an original image and a mask image, then describe the desired edit. The AI generates new images matching the prompt.
Request Body multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
original_image_path | file | Required | The base image to edit (PNG, JPG, WEBP). |
masked_image_path | file | Required | Mask image defining the edit region. |
prompt | string | Required | Description of the desired edit. |
total_images | integer | Required | Number of images to generate. |
image_size | string | Required | 256x256, 512x512, or 1024x1024. |
curl -X POST http://ai-image-gen.xcasper.space/v1/image/mask/generate \
-F "original_image_path=@/path/to/original.png" \
-F "masked_image_path=@/path/to/mask.png" \
-F "prompt=A sunlit indoor lounge with a flamingo pool" \
-F "total_images=1" \
-F "image_size=512x512"
Example Response
{
"url": [
"https://api.deepai.org/job-view-file/xyz789/outputs/output.jpg"
],
"error": null
}
Image Variation
Upload a reference image and receive AI-generated variations inspired by its composition and style.
Request Body multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
path_to_image | file | Required | Reference image to generate variations from (PNG, JPG, WEBP). |
total_images | integer | Required | Number of variations to generate. |
image_size | string | Required | 256x256, 512x512, or 1024x1024. |
curl -X POST http://ai-image-gen.xcasper.space/v1/image/variation/generate \
-F "path_to_image=@/path/to/reference.png" \
-F "total_images=2" \
-F "image_size=512x512"
Example Response
{
"url": [
"https://api.deepai.org/job-view-file/aaa111/outputs/output.jpg",
"https://api.deepai.org/job-view-file/bbb222/outputs/output.jpg"
],
"error": null
}
Image History
Returns the generation history for the current session (identified by a session cookie set automatically on first visit).
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | Optional | Maximum number of records to return. Default: 1000. |
target | string | Optional | Specific field to extract: category, prompt, time, or urls. |
category | string | Optional | Filter by category: chatgpt, bing, masking, or variation. |
# Get all history
curl "http://ai-image-gen.xcasper.space/v1/history"
# Get last 5 bing prompts
curl "http://ai-image-gen.xcasper.space/v1/history?category=bing&limit=5"
# Get only image URLs
curl "http://ai-image-gen.xcasper.space/v1/history?target=urls"
Example Response
{
"data": [
{
"category": "chatgpt",
"prompt": "A futuristic city at night",
"time": "2026-04-05T21:57:11",
"urls": [
"https://api.deepai.org/job-view-file/abc/outputs/output.jpg"
]
}
]
}
Error Response
When a request fails, url is null and error contains the reason:
{
"url": null,
"error": "Kindly fill all the fields"
}