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_KEYExample 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
/api/image_generatorGenerate an image directly from a text prompt. Ideal for quick concept art, marketing visuals, and social content.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | string (JSON body) | Required | Text prompt describing the image to generate. |
| aspectRatio | string (JSON body) | Optional | Aspect ratio of the generated image (e.g., '1:1', '16:9', '9:16'). Defaults to '1:1'. |
| imageCount | number (JSON body) | Optional | Number of images to generate. Defaults to 1. |
Task Status Endpoint
/api/task-status/{task_id}Get the status of a task and retrieve the processed image URL.
| Name | Type | Required | Description |
|---|---|---|---|
| task_id | string (path) | Required | The 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 Code | Description |
|---|---|
| 200 | Successfully retrieved task status. |
| 400 | Bad request. |
| 401 | Unauthorized. |
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)
/api/texttoimgGenerate and store a colorized image from a text prompt. Useful when you want the API to keep track of generated assets.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | string (JSON body) | Required | Text prompt describing the image to generate. |
Task Status Endpoint
/api/task-status/{task_id}Get the status of a task and retrieve the processed image URL.
| Name | Type | Required | Description |
|---|---|---|---|
| task_id | string (path) | Required | The 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 Code | Description |
|---|---|
| 200 | Successfully retrieved task status. |
| 400 | Bad request. |
| 401 | Unauthorized. |
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}