Grok Imagine Image (Quality) Serverless API
Photorealistic text-to-image with legible typography and 2K detail.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/grok-imagine-image-quality"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Macro photograph of a hummingbird hovering beside a red hibiscus flower, iridescent emerald feathers, wings frozen mid-beat, tiny nectar droplets suspended in the air, soft bokeh garden background, golden morning light, ultra-detailed, photorealistic",
12 "aspect_ratio": "16:9",
13 "resolution": "2k",
14 "n": 1,
15 "output_format": "jpeg"
16}
17
18response = requests.post(url, headers=headers, json=data)
19
20if response.status_code == 200:
21 result = response.json()
22 print(json.dumps(result, indent=2))
23else:
24 print(f"Error: {response.status_code}")
25 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/grok-imagine-image-quality"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Macro photograph of a hummingbird hovering beside a red hibiscus flower, iridescent emerald feathers, wings frozen mid-beat, tiny nectar droplets suspended in the air, soft bokeh garden background, golden morning light, ultra-detailed, photorealistic",
12 "aspect_ratio": "16:9",
13 "resolution": "2k",
14 "n": 1,
15 "output_format": "jpeg"
16}
17
18response = requests.post(url, headers=headers, json=data)
19
20if response.status_code == 200:
21 result = response.json()
22 print(json.dumps(result, indent=2))
23else:
24 print(f"Error: {response.status_code}")
25 print(response.text)API Endpoint
https://api.segmind.com/v1/grok-imagine-image-qualityParameters
promptrequiredstringText description of the image. Detailed photographic prompts with lighting cues work best.
"Macro photograph of a hummingbird hovering beside a red hibiscus flower, iridescent emerald feathers, wings frozen mid-beat, tiny nectar droplets suspended in the air, soft bokeh garden background, golden morning light, ultra-detailed, photorealistic"aspect_ratiooptionalstringOutput aspect ratio, 14 options. Use 16:9 landscape, 9:16 social, 1:1 square.
"16:9""1:1""3:4""4:3""9:16""16:9""2:3""3:2""9:19.5""19.5:9""9:20"+4 morenoptionalintegerNumber of images per request, 1-4. Each image is billed separately.
1Range: 1 - 4output_formatoptionalstringOutput file format. jpeg default, png for lossless, webp for web delivery.
"jpeg""jpeg""png""webp"resolutionoptionalstringOutput resolution. Use 2k for final renders, 1k for fast iteration.
"2k""1k""2k"Response 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