SD Outpainting

Stable Diffusion Outpainting can extend any image in any direction

~4.34s
~$0.011
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/sd1.5-outpaint"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "image": "https://segmind.com/image5.png",
12    "prompt": "streets in italy",
13    "negative_prompt": "NONE",
14    "scheduler": "DDIM",
15    "num_inference_steps": 25,
16    "img_width": 1024,
17    "img_height": 1024,
18    "scale": 1,
19    "strength": 1,
20    "offset_x": 256,
21    "offset_y": 256,
22    "guidance_scale": 7.5,
23    "mask_expand": 8,
24    "seed": 124567
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30    result = response.json()
31    print(json.dumps(result, indent=2))
32else:
33    print(f"Error: {response.status_code}")
34    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/sd1.5-outpaint

Parameters

imagerequired
string (uri)

Image to Segment

promptrequired
string

Prompt to render

guidance_scaleoptional
number

Scale for classifier-free guidance

Default: 7.5Range: 0.1 - 25
img_heightoptional
integer

Desired result image Height

Allowed values :
7681024
img_widthoptional
integer

Desired result image width

Allowed values :
7681024
mask_expandoptional
integer

Mask Expansion in pixels uniformly in all four sides, this sometimes helps the model to achieve more seamless results.

Default: 8Range: 0 - 256
negative_promptoptional
string

Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'

num_inference_stepsoptional
integer

Number of denoising steps.

Default: 25Range: 25 - 100
offset_xoptional
integer

Offset of the init image on the horizontal axis from the left.

Default: 0Range: 0 - 1024
offset_yoptional
integer

Offset of the init image on the vertical axis from the top.

Default: 0Range: 0 - 1024
scaleoptional
number

Scale for classifier-free guidance

Default: 0.2Range: 0.1 - 10
scheduleroptional
string

Type of scheduler.

Default: "DDIM"
Allowed values :
"DDIM"
seedoptional
integer

Seed for image generation.

Default: -1
strengthoptional
number

Strength controls how much the images can vary

Default: 1Range: 0.1 - 1

Response Type

Returns: Image

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