Z Image Turbo Serverless API

Photorealistic images in under one second, bilingual text.

POST /v2/z-image-turbo · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5# Async (v2): submit to the queue and block until COMPLETED.
 6# run() returns the final result dict (600s deadline, 1.0s poll by default).
 7result = segmind.run(
 8    "z-image-turbo",
 9    prompt="Create a vibrant and modern magazine cover for Hindi Farmer, themed for April 2025.\nThe main background is a cool magenta to deep-pink gradient with airy soft shadows that mirror the vivid color of ripe dragon fruit (ड्रैगन फ्रूट).\n\nCentered is a Hindi farmer, a middle-aged man with sun-tanned skin, short textured black hair, and a confident stance. He stands beside a freshly harvested pile of bright red dragon fruit arranged on geometric crates painted in matte dark teal.\nHe wears a lightweight dark grey field jacket, a maroon undershirt, and rugged work pants.\nHis expression is sharp and determined, representing precision farming and market growth in India.\n\nUse a new font direction featuring condensed sans-serif fonts for headlines and a bold serif for key title elements.\nBalance white, dark magenta, and citrus orange text across the layout with clean editorial spacing.\n\nText Layout (all updated to Hindi)\n\n• Top left:\n“प्रीमियम ड्रैगन फ्रूट” in bright orange\nSubtext in white: “कैसे भारतीय किसान निर्यात बाज़ार में कदम बढ़ा रहे हैं”\n\n• Top right:\n“शुष्क भूमि तकनीक” in bold dark magenta\nSubtext: “लंबे मौसम में ऊर्जा-सक्षम सिंचाई के नए तरीके”\n\n• Center right:\nLarge orange “18”\nText: “अधिकतम पैदावार के लिए 18 छंटाई रणनीतियाँ”\n\n• Bottom left:\n“मूल्य युद्ध” in dark magenta\nPale pink subtext: “सालभर ड्रैगन फ्रूट बाज़ार की बदलती गतिशीलता”\n\n• Bottom left corner (with an orange plus sign):\n“तेज़ वृद्धि देने वाला जैविक उर्वरक”\n\n• Bottom right (over the crates):\nIn elegant white serif: “लाल का लाभ”\nOrange subheading: “वे किसान जो लगातार बड़ी पैदावार ले रहे हैं”\n\nArt Direction\n\nDesign should look modern, clean, and forward-focused, emphasizing:\n\ntropical & semi-tropical horticulture\n\npremium produce\n\nthe rising value of dragon fruit cultivation in India\n\nLighting should be bright studio style with soft controlled shadows.",
10    steps=8,
11    guidance_scale=1,
12    seed=-1,
13    height=1024,
14    width=1024,
15    image_format="webp",
16    quality=90,
17    base_64=False,
18)
19print(result["status"])                      # COMPLETED
20print(result.get("output"))                  # model output (e.g. media URL)
21print(result["metrics"]["inference_time"])   # server compute seconds
22
23# --- Or submit + poll manually (track request_id, control the cadence) ---
24from segmind import SegmindClient, InferenceFailed, InferenceTimeout
25
26client = SegmindClient()                      # reads SEGMIND_API_KEY
27payload = {
28    "prompt": "Create a vibrant and modern magazine cover for Hindi Farmer, themed for April 2025.\nThe main background is a cool magenta to deep-pink gradient with airy soft shadows that mirror the vivid color of ripe dragon fruit (ड्रैगन फ्रूट).\n\nCentered is a Hindi farmer, a middle-aged man with sun-tanned skin, short textured black hair, and a confident stance. He stands beside a freshly harvested pile of bright red dragon fruit arranged on geometric crates painted in matte dark teal.\nHe wears a lightweight dark grey field jacket, a maroon undershirt, and rugged work pants.\nHis expression is sharp and determined, representing precision farming and market growth in India.\n\nUse a new font direction featuring condensed sans-serif fonts for headlines and a bold serif for key title elements.\nBalance white, dark magenta, and citrus orange text across the layout with clean editorial spacing.\n\nText Layout (all updated to Hindi)\n\n• Top left:\n“प्रीमियम ड्रैगन फ्रूट” in bright orange\nSubtext in white: “कैसे भारतीय किसान निर्यात बाज़ार में कदम बढ़ा रहे हैं”\n\n• Top right:\n“शुष्क भूमि तकनीक” in bold dark magenta\nSubtext: “लंबे मौसम में ऊर्जा-सक्षम सिंचाई के नए तरीके”\n\n• Center right:\nLarge orange “18”\nText: “अधिकतम पैदावार के लिए 18 छंटाई रणनीतियाँ”\n\n• Bottom left:\n“मूल्य युद्ध” in dark magenta\nPale pink subtext: “सालभर ड्रैगन फ्रूट बाज़ार की बदलती गतिशीलता”\n\n• Bottom left corner (with an orange plus sign):\n“तेज़ वृद्धि देने वाला जैविक उर्वरक”\n\n• Bottom right (over the crates):\nIn elegant white serif: “लाल का लाभ”\nOrange subheading: “वे किसान जो लगातार बड़ी पैदावार ले रहे हैं”\n\nArt Direction\n\nDesign should look modern, clean, and forward-focused, emphasizing:\n\ntropical & semi-tropical horticulture\n\npremium produce\n\nthe rising value of dragon fruit cultivation in India\n\nLighting should be bright studio style with soft controlled shadows.",
29    "steps": 8,
30    "guidance_scale": 1,
31    "seed": -1,
32    "height": 1024,
33    "width": 1024,
34    "image_format": "webp",
35    "quality": 90,
36    "base_64": False,
37}
38job = client.submit_async("z-image-turbo", **payload)
39print(job.request_id)                         # available immediately
40try:
41    result = job.wait(timeout=600, interval=1.0)
42except InferenceTimeout as e:
43    print("still running:", e.request_id)
44except InferenceFailed as e:
45    print("failed:", e.detail)

API Endpoint

POSThttps://api.segmind.com/v1/z-image-turbo

Parameters

promptrequired
string

Text prompt describing the desired image

base_64optional
boolean

Return image as base64 encoded string

Default: false
guidance_scaleoptional
number

Classifier-free guidance scale

Default: 1Range: 0 - 15
heightoptional
integer

Output image height in pixels

Default: 1024Range: 256 - 2048
image_formatoptional
string

Output image format

Default: "webp"
Allowed values :
"jpeg""png""webp"
qualityoptional
integer

Output image quality (1-100)

Default: 90Range: 1 - 100
seedoptional
integer

Random seed for reproducibility. Use -1 for random

Default: -1Range: -1 - 92147483647
stepsoptional
integer

Number of inference steps

Default: 8Range: 1 - 75
widthoptional
integer

Output image width in pixels

Default: 1024Range: 256 - 2048

Response Type

Returns: Text/JSON

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/z-image-turbo

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out