# Z Image API Complete API reference for Z Image text-to-image generation. ## Model Variants This API supports one model variant: | Model | ID | Description | |-------|-----|-------------| | **Z Image** | `z-image` | Fast text-to-image generation | ## Quick Comparison | Feature | Z Image | |---------|---------| | Input | Text prompt | | Output | Single generated image | | Aspect Ratios | Multiple supported ratios | | Resolution | Derived from width/height ratio values | | `seed` | Optional | ### Supported Aspect Ratios The `width:height` pair must be one of: `1:1`, `3:2`, `2:3`, `3:4`, `4:3`, `9:16`, `16:9`, `9:21` ## Z Image (Text-to-Image) ### Endpoint ``` POST /api/v1/image/task ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model_name` | string | Must be `"z-image"` | | `prompt` | string | Image generation prompt | | `width` | number | Width ratio value (e.g., `16` for `16:9`) | | `height` | number | Height ratio value (e.g., `9` for `16:9`) | #### Optional | Parameter | Type | Description | |-----------|------|-------------| | `seed` | number | Random seed in range `[0, 2147483647]`. Use `null` or `0` for random generation. | ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/image/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'z-image', prompt: 'A cinematic portrait of a traveler standing on a cliff at golden hour', width: 16, height: 9, seed: 0 }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Response Format Submit response: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/image/{task_id}", "task_status": "submitted" } } ``` Poll with `GET /api/v1/image/{task_id}`. Task statuses: `submitted`, `processing`, `succeed`, `failed`. Successful polling responses expose generated image URLs under `data.task_result.images[].url`. ## Best Practices - Use ratio values, not pixel dimensions, for `width` and `height`. - Keep prompts descriptive but focused on subject, lighting, and composition. - Use a fixed `seed` when you want reproducible generations during testing.