SD Outpainting Serverless API
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-outpaintParameters
imagerequiredstring (uri)Image to Segment
promptrequiredstringPrompt to render
guidance_scaleoptionalnumberScale for classifier-free guidance
7.5Range: 0.1 - 25img_heightoptionalintegerDesired result image Height
7681024img_widthoptionalintegerDesired result image width
7681024mask_expandoptionalintegerMask Expansion in pixels uniformly in all four sides, this sometimes helps the model to achieve more seamless results.
8Range: 0 - 256negative_promptoptionalstringPrompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'
num_inference_stepsoptionalintegerNumber of denoising steps.
25Range: 25 - 100offset_xoptionalintegerOffset of the init image on the horizontal axis from the left.
0Range: 0 - 1024offset_yoptionalintegerOffset of the init image on the vertical axis from the top.
0Range: 0 - 1024scaleoptionalnumberScale for classifier-free guidance
0.2Range: 0.1 - 10scheduleroptionalstringType of scheduler.
"DDIM""DDIM"seedoptionalintegerSeed for image generation.
-1strengthoptionalnumberStrength controls how much the images can vary
1Range: 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