our logo

Image Generation API Documentation

This page documents the core Text-to-Image endpoints. Use these APIs to generate new images from prompts or store generated images for later use.

Introduction

The Image Generation APIs convert plain text prompts into high‑quality images. You can generate ad creatives, social posts, concept art, or UI assets with a single HTTP request, and optionally persist the results for reuse.

Typical use cases include:

  • Generating images from scratch using only text prompts.
  • Storing generated images for galleries, history views, or billing.

All examples below use the production base URL and are ready to copy‑paste; just replace file paths andYOUR_API_KEY.

Base URL

https://taiapi.aiphotocraft.com/

Authentication

All Image Generation endpoints require an API key. You can create and manage keys in the Developer Dashboard.

API Key Header

Send your key in the request headers:

X-Api-Key: YOUR_API_KEY

Example Request

curl -X POST "https://taiapi.aiphotocraft.com/api/image_generator" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "cinematic portrait of a cyberpunk character, neon lights"
  }'

Do not expose your key

Keep your API key secret. Avoid embedding it in public client‑side code; instead, call these APIs from your backend or a secure serverless function.

Image generation

Image Generator

POST/api/image_generator

Generate an image directly from a text prompt. Ideal for quick concept art, marketing visuals, and social content.

Parameters

NameTypeRequiredDescription
promptstring (JSON body)RequiredText prompt describing the image to generate.
aspectRatiostring (JSON body)OptionalAspect ratio of the generated image (e.g., '1:1', '16:9', '9:16'). Defaults to '1:1'.
imageCountnumber (JSON body)OptionalNumber of images to generate. Defaults to 1.

Task Status Endpoint

GET/api/task-status/{task_id}

Get the status of a task and retrieve the processed image URL.

NameTypeRequiredDescription
task_idstring (path)RequiredThe ID of the task to get the status for.

Example Request

curl -X GET "https://taiapi.aiphotocraft.com/api/task-status/{task_id}"-H "accept: application/json"-H "X-Api-Key: YOUR_API_KEY"

Example Response

{
  "image_url": "https://taiapi.aiphotocraft.com/results/swapped_image.jpg"
}

Response Status Codes

Status CodeDescription
200Successfully retrieved task status.
400Bad request.
401Unauthorized.

Examples

import requests

url = "https://taiapi.aiphotocraft.com/api/image_generator"
headers = {
    "X-Api-Key": "YOUR_API_KEY",
    "accept": "application/json",
    "Content-Type": "application/json",
}

data = {
    "prompt": "beautiful girl",
    "aspectRatio": "1:1",
    "imageCount": 1,
}

response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
task_id = result.get("task_id")
print("Task started. Task ID:", task_id)
# Use task_id to check status at /api/task-status/{task_id}

Text to Image (Stored)

POST/api/texttoimg

Generate and store a colorized image from a text prompt. Useful when you want the API to keep track of generated assets.

Parameters

NameTypeRequiredDescription
promptstring (JSON body)RequiredText prompt describing the image to generate.

Task Status Endpoint

GET/api/task-status/{task_id}

Get the status of a task and retrieve the processed image URL.

NameTypeRequiredDescription
task_idstring (path)RequiredThe ID of the task to get the status for.

Example Request

curl -X GET "https://taiapi.aiphotocraft.com/api/task-status/{task_id}"-H "accept: application/json"-H "X-Api-Key: YOUR_API_KEY"

Example Response

{
  "image_url": "https://taiapi.aiphotocraft.com/results/swapped_image.jpg"
}

Response Status Codes

Status CodeDescription
200Successfully retrieved task status.
400Bad request.
401Unauthorized.

Examples

import requests

url = "https://taiapi.aiphotocraft.com/api/texttoimg"
headers = {
    "X-Api-Key": "YOUR_API_KEY",
    "accept": "application/json",
    "Content-Type": "application/json",
}

data = {
    "prompt": "beautiful girl",
}

response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
task_id = result.get("task_id")
print("Task started. Task ID:", task_id)
# Use task_id to check status at /api/task-status/{task_id}