Pruna P Image Serverless API
p-image generates high-quality images from text prompts in seconds, optimizing for speed and fidelity.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/p-image"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Vibrant neon signboard glowing at night that says “Pruna P Image is LIVE on Segmind”, bold cyberpunk style, dark city backdrop, intense electric colors",
12 "aspect_ratio": "16:9",
13 "width": 1024,
14 "height": 1024,
15 "seed": 42,
16 "disable_safety_checker": false
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/p-image"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Vibrant neon signboard glowing at night that says “Pruna P Image is LIVE on Segmind”, bold cyberpunk style, dark city backdrop, intense electric colors",
12 "aspect_ratio": "16:9",
13 "width": 1024,
14 "height": 1024,
15 "seed": 42,
16 "disable_safety_checker": false
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text)API Endpoint
https://api.segmind.com/v1/p-imageParameters
promptrequiredstringDescribe the image you want generated. Example: 'sunset over a calm ocean'.
aspect_ratiooptionalstringSelect the aspect ratio of the image. Use '1:1' for square images.
"16:9""1:1""16:9""9:16""4:3""3:4""3:2""2:3""custom"disable_safety_checkeroptionalbooleanDisable safety checks on generated images. Keep enabled for general use.
falseheightoptionalintegerSet custom height for 'custom' aspect ratio. Use 576 for wide images.
576Range: 256 - 1440seedoptionalintegerSet a seed for reproducible generation. Use -1 for completely random results.
42Range: -1 - 999999999999999widthoptionalintegerSet custom width for 'custom' aspect ratio. Use 1024 for high-resolution images.
1024Range: 256 - 1440Response 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