Qwen Image Serverless API
Qwen-Image revolutionizes image generation and editing with seamless multilingual text integration and photorealistic detail.
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) 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
https://api.segmind.com/v1/qwen-imageParameters
promptrequiredstringDescribe imaginative landscapes or detailed environments for image generation. Examples: 'A mystical dragon cave' or 'rustic mountain cabin'.
stepsrequiredintegerNumber of steps for generating the image
30Range: 1 - 50aspect_ratiooptionalstringDefines image proportion. Use 16:9 for cinematic, 1:1 for square formats.
"16:9""1:1""16:9""9:16""4:3""3:4""3:2""2:3"base64optionalbooleanOutputs base64 image string. Enable for embedding, disable for files.
falseguidanceoptionalnumberAdjusts adherence to prompt. Set 2.5 for creativity, 5.0 for precision.
3.5Range: 1 - 20image_formatoptionalstringSelect image format. Use 'jpeg' for small files, 'png' for quality.
"png""png""jpeg""webp"negative_promptoptionalstringExclude elements to control results. Useful filters: 'blur' for clarity, 'cartoonish' for realism.
"blurry, cartoonish"qualityoptionalintegerSet clarity level. Choose 80 for web, 100 for print quality.
90Range: 10 - 100seedoptionalintegerDetermines image variation. Use -1 for unique images, fixed for repeatability.
-1Response Type
Returns: Text/JSON
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out