# Z Image Turbo Model Specification

Z Image Turbo is an ultra-fast, cost-effective text-to-image synthesis model engineered for rapid image generation, concept ideation, and high-throughput visual workloads.

---

## 1. Quick Overview

* **Model Slug:** `z-image-turbo`
* **Endpoint:** `POST https://api.amandevelops.com/v1/z-image-turbo/`
* **Category:** Fast Text-to-Image Diffusion
* **Pricing:** **$0.0050 per image** (Flat fixed rate)
* **Status Polling:** Pure-database polling at `GET /v1/tasks/{task_id}`
* **Webhooks:** Optional signed webhook callbacks upon generation completion
* **Storage Retention:** 48 hours high-availability public CDN storage

---

## 2. API Request Specification

* **HTTP Method:** `POST`
* **Path:** `/v1/z-image-turbo/`
* **Headers:**
  ```http
  Authorization: Bearer <YOUR_API_KEY>
  Content-Type: application/json
  ```

### Full JSON Request Schema

```json
{
  "prompt": "A futuristic sports car driving through a neon-lit rain-slicked metropolis at night, dramatic reflections, hyper-detailed, 8k",
  "aspect_ratio": "16:9",
  "webhook_url": "https://your-domain.com/api/webhooks/image-completed"
}
```

---

## 3. Parameter Reference

| Parameter | Type | Required? | Default | Description |
|---|---|---|---|---|
| `prompt` | `string` | **Required** | — | Text description of the image to generate. Maximum 1,000 characters. |
| `aspect_ratio` | `string` | Optional | `"1:1"` | Canvas proportion. Supported values: `"1:1"`, `"4:3"`, `"3:4"`, `"16:9"`, `"9:16"`. |
| `webhook_url` | `string` | Optional | `null` | Your webhook URL to receive an automated HTTP POST notification when generation completes. |

---

## 4. Supported Aspect Ratios

Z Image Turbo provides native framing calibration across 5 core aspect ratios:

| Aspect Ratio | Orientation | Ideal Use Cases |
|---|---|---|
| `1:1` | Square (Default) | Profile pictures, avatars, social media feed posts, product icons |
| `16:9` | Widescreen Landscape | YouTube thumbnails, desktop wallpapers, cinematic scenes |
| `9:16` | Vertical / Story | TikTok, Instagram Stories, YouTube Shorts, mobile wallpapers |
| `4:3` | Standard Landscape | Editorial photography, classic compositions |
| `3:4` | Standard Portrait | Portrait photography, posters, magazine layouts |

---

## 5. Pricing & Wallet Economics

Requests to `z-image-turbo` are billed at a flat, budget-friendly rate:

| Model | Price per Generation | Description |
|---|---|---|
| **Z Image Turbo** | **$0.0050 USD** | Fixed rate of half a cent ($0.005) per generated image |

> [!TIP]
> **Automated Failure Refund:**
> If an upstream generation encounters an unforeseen failure or timeout (>300s), the reserved $0.0050 is automatically refunded to your wallet balance immediately.

---

## 6. Asynchronous Request Lifecycle

Z Image Turbo runs on our ultra-fast non-blocking queue engine:

### 1. Ingress Response (`HTTP 202 Accepted` in < 20ms)
```json
{
  "status": "success",
  "code": "TASK_QUEUED",
  "message": "Generation task accepted and queued for inference.",
  "task_id": "task_zit_3f9a1b2c4e5d6789",
  "model": "z-image-turbo",
  "state": "queued",
  "cost_usd": 0.0050,
  "remaining_balance_usd": 14.9950,
  "poll_url": "https://api.amandevelops.com/v1/tasks/task_zit_3f9a1b2c4e5d6789",
  "created_at": "2026-09-18 05:00:00"
}
```

### 2. Status Polling (`GET /v1/tasks/{task_id}`)
Poll the task status from our high-speed database index:

```http
GET /v1/tasks/task_zit_3f9a1b2c4e5d6789
Authorization: Bearer <YOUR_API_KEY>
```

**Completed Response:**
```json
{
  "status": "success",
  "state": "completed",
  "task_id": "task_zit_3f9a1b2c4e5d6789",
  "model": "z-image-turbo",
  "result_url": "https://api.amandevelops.com/storage/z-image-turbo/img_zit_9a8b7c6d5e4f.jpeg",
  "is_expired": false,
  "expires_at": "2026-09-20T05:00:15Z",
  "webhook_status": "delivered",
  "created_at": "2026-09-18 05:00:00",
  "completed_at": "2026-09-18 05:00:10"
}
```

---

## 7. Runnable Code Examples

### cURL
```bash
curl -X POST "https://api.amandevelops.com/v1/z-image-turbo/" \
  -H "Authorization: Bearer ak_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A serene zen garden with blooming cherry blossoms, soft morning sunlight, cinematic",
    "aspect_ratio": "16:9"
  }'
```

### JavaScript (Fetch API)
```javascript
const response = await fetch("https://api.amandevelops.com/v1/z-image-turbo/", {
  method: "POST",
  headers: {
    "Authorization": "Bearer ak_live_YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    prompt: "Cyberpunk female warrior with glowing neon visor, highly detailed digital painting",
    aspect_ratio: "1:1"
  })
});

const data = await response.json();
console.log("Task ID:", data.task_id);
console.log("Cost USD:", data.cost_usd);
console.log("Poll URL:", data.poll_url);
```

### Python (Requests)
```python
import requests
import time

API_KEY = "ak_live_YOUR_API_KEY"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# 1. Enqueue generation task
payload = {
    "prompt": "Hyperrealistic macro shot of a dewdrop on an emerald green leaf, golden hour lighting",
    "aspect_ratio": "16:9"
}

response = requests.post("https://api.amandevelops.com/v1/z-image-turbo/", json=payload, headers=HEADERS)
task_data = response.json()
task_id = task_data["task_id"]
print(f"Enqueued Task ID: {task_id}, Charged: ${task_data['cost_usd']:.4f}")

# 2. Poll for result
while True:
    status_res = requests.get(f"https://api.amandevelops.com/v1/tasks/{task_id}", headers=HEADERS).json()
    state = status_res.get("state")
    print(f"Current State: {state}")
    
    if state == "completed":
        print(f"Image ready: {status_res['result_url']}")
        break
    elif state == "failed":
        print(f"Task failed: {status_res.get('error')}")
        break
        
    time.sleep(2)
```