Pruna P Image Serverless API

p-image generates high-quality images from text prompts in seconds, optimizing for speed and fidelity.

~6.30s
$0.005 per generation
 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

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

Parameters

promptrequired
string

Describe the image you want generated. Example: 'sunset over a calm ocean'.

aspect_ratiooptional
string

Select the aspect ratio of the image. Use '1:1' for square images.

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

Disable safety checks on generated images. Keep enabled for general use.

Default: false
heightoptional
integer

Set custom height for 'custom' aspect ratio. Use 576 for wide images.

Default: 576Range: 256 - 1440
seedoptional
integer

Set a seed for reproducible generation. Use -1 for completely random results.

Default: 42Range: -1 - 999999999999999
widthoptional
integer

Set custom width for 'custom' aspect ratio. Use 1024 for high-resolution images.

Default: 1024Range: 256 - 1440

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