SD Outpainting Serverless API
Stable Diffusion Outpainting can extend any image in any direction
POST /v2/sd1.5-outpaint · submit + poll 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "sd1.5-outpaint",
9 image="https://segmind.com/image5.png",
10 prompt="streets in italy",
11 negative_prompt="NONE",
12 scheduler="DDIM",
13 num_inference_steps=25,
14 img_width=1024,
15 img_height=1024,
16 scale=1,
17 strength=1,
18 offset_x=256,
19 offset_y=256,
20 guidance_scale=7.5,
21 mask_expand=8,
22 seed=124567,
23)
24print(result["status"]) # COMPLETED
25print(result.get("output")) # model output (e.g. media URL)
26print(result["metrics"]["inference_time"]) # server compute seconds
27
28# --- Or submit + poll manually (track request_id, control the cadence) ---
29from segmind import SegmindClient, InferenceFailed, InferenceTimeout
30
31client = SegmindClient() # reads SEGMIND_API_KEY
32payload = {
33 "image": "https://segmind.com/image5.png",
34 "prompt": "streets in italy",
35 "negative_prompt": "NONE",
36 "scheduler": "DDIM",
37 "num_inference_steps": 25,
38 "img_width": 1024,
39 "img_height": 1024,
40 "scale": 1,
41 "strength": 1,
42 "offset_x": 256,
43 "offset_y": 256,
44 "guidance_scale": 7.5,
45 "mask_expand": 8,
46 "seed": 124567,
47}
48job = client.submit_async("sd1.5-outpaint", **payload)
49print(job.request_id) # available immediately
50try:
51 result = job.wait(timeout=600, interval=1.0)
52except InferenceTimeout as e:
53 print("still running:", e.request_id)
54except InferenceFailed as e:
55 print("failed:", e.detail) 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "sd1.5-outpaint",
9 image="https://segmind.com/image5.png",
10 prompt="streets in italy",
11 negative_prompt="NONE",
12 scheduler="DDIM",
13 num_inference_steps=25,
14 img_width=1024,
15 img_height=1024,
16 scale=1,
17 strength=1,
18 offset_x=256,
19 offset_y=256,
20 guidance_scale=7.5,
21 mask_expand=8,
22 seed=124567,
23)
24print(result["status"]) # COMPLETED
25print(result.get("output")) # model output (e.g. media URL)
26print(result["metrics"]["inference_time"]) # server compute seconds
27
28# --- Or submit + poll manually (track request_id, control the cadence) ---
29from segmind import SegmindClient, InferenceFailed, InferenceTimeout
30
31client = SegmindClient() # reads SEGMIND_API_KEY
32payload = {
33 "image": "https://segmind.com/image5.png",
34 "prompt": "streets in italy",
35 "negative_prompt": "NONE",
36 "scheduler": "DDIM",
37 "num_inference_steps": 25,
38 "img_width": 1024,
39 "img_height": 1024,
40 "scale": 1,
41 "strength": 1,
42 "offset_x": 256,
43 "offset_y": 256,
44 "guidance_scale": 7.5,
45 "mask_expand": 8,
46 "seed": 124567,
47}
48job = client.submit_async("sd1.5-outpaint", **payload)
49print(job.request_id) # available immediately
50try:
51 result = job.wait(timeout=600, interval=1.0)
52except InferenceTimeout as e:
53 print("still running:", e.request_id)
54except InferenceFailed as e:
55 print("failed:", e.detail)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
Asynchronous requests (v2)
Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.
- 1
POST /v2/sd1.5-outpaintSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- A FAILED request is served as HTTP 422 — the body still carries the error detail.
- An unknown or expired request_id returns HTTP 404.
- Results are retained for 1 hour, then expire.
- Content / RAI blocks surface as FAILED, not a separate state.
- Track completion by polling the status endpoint.
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