Qwen Image Serverless API

Qwen-Image revolutionizes image generation and editing with seamless multilingual text integration and photorealistic detail.

~28.40s
~$0.121
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/qwen-image"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "prompt": "A mystical dragon hovering above a sparkling waterfall under a starry sky.",
12    "negative_prompt": "blurry, cartoonish",
13    "steps": 30,
14    "seed": -1,
15    "guidance": 3.5,
16    "aspect_ratio": "16:9",
17    "image_format": "png",
18    "quality": 90,
19    "base64": false
20}
21
22response = requests.post(url, headers=headers, json=data)
23
24if response.status_code == 200:
25    result = response.json()
26    print(json.dumps(result, indent=2))
27else:
28    print(f"Error: {response.status_code}")
29    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/qwen-image

Parameters

promptrequired
string

Describe imaginative landscapes or detailed environments for image generation. Examples: 'A mystical dragon cave' or 'rustic mountain cabin'.

stepsrequired
integer

Number of steps for generating the image

Default: 30Range: 1 - 50
aspect_ratiooptional
string

Defines image proportion. Use 16:9 for cinematic, 1:1 for square formats.

Default: "16:9"
Allowed values :
"1:1""16:9""9:16""4:3""3:4""3:2""2:3"
base64optional
boolean

Outputs base64 image string. Enable for embedding, disable for files.

Default: false
guidanceoptional
number

Adjusts adherence to prompt. Set 2.5 for creativity, 5.0 for precision.

Default: 3.5Range: 1 - 20
image_formatoptional
string

Select image format. Use 'jpeg' for small files, 'png' for quality.

Default: "png"
Allowed values :
"png""jpeg""webp"
negative_promptoptional
string

Exclude elements to control results. Useful filters: 'blur' for clarity, 'cartoonish' for realism.

Default: "blurry, cartoonish"
qualityoptional
integer

Set clarity level. Choose 80 for web, 100 for print quality.

Default: 90Range: 10 - 100
seedoptional
integer

Determines image variation. Use -1 for unique images, fixed for repeatability.

Default: -1

Response Type

Returns: Text/JSON

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