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)

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

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. 1
    POST /v2/sd1.5-outpaint

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • 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.

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