SD Outpainting
Stable Diffusion Outpainting can extend any image in any direction
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)
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
https://api.segmind.com/v1/sd1.5-outpaint
Parameters
image
requiredstring (uri)
Image to Segment
prompt
requiredstring
Prompt to render
guidance_scale
optionalnumber
Scale for classifier-free guidance
7.5
Range: 0.1 - 25img_height
optionalinteger
Desired result image Height
768
1024
img_width
optionalinteger
Desired result image width
768
1024
mask_expand
optionalinteger
Mask Expansion in pixels uniformly in all four sides, this sometimes helps the model to achieve more seamless results.
8
Range: 0 - 256negative_prompt
optionalstring
Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'
num_inference_steps
optionalinteger
Number of denoising steps.
25
Range: 25 - 100offset_x
optionalinteger
Offset of the init image on the horizontal axis from the left.
0
Range: 0 - 1024offset_y
optionalinteger
Offset of the init image on the vertical axis from the top.
0
Range: 0 - 1024scale
optionalnumber
Scale for classifier-free guidance
0.2
Range: 0.1 - 10scheduler
optionalstring
Type of scheduler.
"DDIM"
"DDIM"
seed
optionalinteger
Seed for image generation.
-1
strength
optionalnumber
Strength controls how much the images can vary
1
Range: 0.1 - 1Response Type
Returns: Image
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