× Home Text to Image Magic Studio Image + Mask Variations Image to Prompt API Docs
Back to app
v1

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

Base URL
http://ai-image-gen.xcasper.space

Response Format

All API endpoints return a JSON object with the following shape:

JSON
{
  "url": ["https://...", "https://..."],  // array of image URLs, or null on error
  "error": null                                   // error message string, or null on success
}
FieldTypeDescription
urlarray<string> | nullList of generated image URLs. null when an error occurred.
errorstring | nullHuman-readable error message. null on success.
200 Success — images generated
400 Bad request — missing required fields
501 Generation failed — upstream error
POST /v1/image/prompt/generate

Text to Image

Generate one or more images from a text description using the DeepAI engine.

Request Body multipart/form-data

FieldTypeRequiredDescription
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
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

JSON · 200 OK
{
  "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
}
POST /v1/image/bing/generate

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

FieldTypeRequiredDescription
promptstringRequiredText description of the image to generate.
total_imagesintegerRequiredNumber of images to generate.
cURL
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

JSON · 200 OK
{
  "url": [
    "https://cdn.magicstudio.com/output/image-abc.jpg"
  ],
  "error": null
}
POST /v1/image/mask/generate

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

FieldTypeRequiredDescription
original_image_pathfileRequiredThe base image to edit (PNG, JPG, WEBP).
masked_image_pathfileRequiredMask image defining the edit region.
promptstringRequiredDescription of the desired edit.
total_imagesintegerRequiredNumber of images to generate.
image_sizestringRequired256x256, 512x512, or 1024x1024.
cURL
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

JSON · 200 OK
{
  "url": [
    "https://api.deepai.org/job-view-file/xyz789/outputs/output.jpg"
  ],
  "error": null
}
POST /v1/image/variation/generate

Image Variation

Upload a reference image and receive AI-generated variations inspired by its composition and style.

Request Body multipart/form-data

FieldTypeRequiredDescription
path_to_imagefileRequiredReference image to generate variations from (PNG, JPG, WEBP).
total_imagesintegerRequiredNumber of variations to generate.
image_sizestringRequired256x256, 512x512, or 1024x1024.
cURL
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

JSON · 200 OK
{
  "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
}
GET /v1/history

Image History

Returns the generation history for the current session (identified by a session cookie set automatically on first visit).

Query Parameters

ParameterTypeRequiredDescription
limitintegerOptionalMaximum number of records to return. Default: 1000.
targetstringOptionalSpecific field to extract: category, prompt, time, or urls.
categorystringOptionalFilter by category: chatgpt, bing, masking, or variation.
cURL
# 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

JSON · 200 OK
{
  "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:

JSON · 400 / 501
{
  "url": null,
  "error": "Kindly fill all the fields"
}