Async API for Image Generation
Complete guide to CyberPhotoBooth API integration
Async API allows you to submit generation tasks to a queue and retrieve results later, avoiding long waits and timeouts.
An API key is required to access the API. Get it via Telegram bot
Authorization header:
/async/submitSubmits a generation task to the queue
style field accepts either the style name or its style_id. For example: "SteamPunk" or 1029 — use whichever is more convenient.Request body:
{
"mode": "style_sdxl_zero",
"style": "SteamPunk",
"return_s3_link": false,
"params": {
"Sex": "man",
"Face": "base64_image_data",
"Fon": "base64_image_data"
}
}Response:
{
"job_id": "uuid-of-task",
"status": "queued",
"estimated_wait_time_seconds": 30
}/async/status/{job_id}Checks task status and returns result
Possible statuses:
queued— in queueprocessing— processingcompleted— completedfailed— failednot_found— not found / expiredSuccessful result:
{
"job_id": "uuid",
"status": "completed",
"processing_time_ms": 15000,
"results": {
"images": ["base64_image_1", "base64_image_2"],
"videos": []
}
}/public/stylesRetrieves list of all available public styles (no authentication required)
Response:
[
{ "name": "GTA", "style_id": 1079 },
{ "name": "Mad Max", "style_id": 1046 },
{ "name": "Киберпанк", "style_id": 1009 },
{ "name": "Стимпанк", "style_id": 1029 },
...
]import httpx
import asyncio
async def generate_async():
async with httpx.AsyncClient() as client:
# 1. Submit task
response = await client.post(
"https://api.cyberphotobooth.ru/api/async/submit",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"mode": "style_sdxl_zero",
"style": "SteamPunk",
"return_s3_link": False,
"params": {"Sex": "man", "Face": "...", "Fon": "..."}
}
)
job_data = response.json()
job_id = job_data["job_id"]
print(f"Task submitted: {job_id}")
# 2. Wait for result
while True:
await asyncio.sleep(2) # Check every 2 seconds
status_response = await client.get(
f"https://api.cyberphotobooth.ru/api/async/status/{job_id}"
)
result = status_response.json()
status = result.get("status")
if status == "completed":
print("Done!")
images = result["results"]["images"]
return images
elif status == "failed":
print(f"Error: {result.get('error')}")
break
else:
print(f"Status: {status}")
# Run
asyncio.run(generate_async())Image fields (for example, Face and Fon) should be sent as a base64-encoded payload without the Data URI prefix (i.e., without data:image/png;base64,).