Segmind SegSwap v0.1 Serverless API

Swap Objects Instantly. The Segmind SegSwap v0.1 model enables dynamic and precise image editing by allowing users to remove, replace, or add objects and transfer patterns seamlessly within images.

~26.38s
POST /v2/seg-swap · 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    "seg-swap",
 9    prompt="photo of a wooden table in center of living room",
10    main_image="https://segmind-resources.s3.amazonaws.com/others/b855aade-9114-4554-9530-088f1eb1e32d-livingroom.png",
11    object_image="https://segmind-resources.s3.amazonaws.com/others/69ceda90-7c13-48e2-a436-a4e0f733d136-table2.png",
12    mask_image="https://segmind-resources.s3.amazonaws.com/others/b2c6b355-07be-4edc-b6ce-ec05fd6a03f2-mask_room2.png",
13    steps=30,
14    seed=42,
15    growmask=5,
16    fashion_strength=1,
17    subject_strength=1,
18    horizontal_repeat=1,
19    vertical_repeat=1,
20    image_format="png",
21    image_quality=95,
22    base64=False,
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    "prompt": "photo of a wooden table in center of living room",
34    "main_image": "https://segmind-resources.s3.amazonaws.com/others/b855aade-9114-4554-9530-088f1eb1e32d-livingroom.png",
35    "object_image": "https://segmind-resources.s3.amazonaws.com/others/69ceda90-7c13-48e2-a436-a4e0f733d136-table2.png",
36    "mask_image": "https://segmind-resources.s3.amazonaws.com/others/b2c6b355-07be-4edc-b6ce-ec05fd6a03f2-mask_room2.png",
37    "steps": 30,
38    "seed": 42,
39    "growmask": 5,
40    "fashion_strength": 1,
41    "subject_strength": 1,
42    "horizontal_repeat": 1,
43    "vertical_repeat": 1,
44    "image_format": "png",
45    "image_quality": 95,
46    "base64": False,
47}
48job = client.submit_async("seg-swap", **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/seg-swap

Parameters

main_imagerequired
string (uri)

The URL of the main image

Default: "https://segmind-resources.s3.amazonaws.com/others/b855aade-9114-4554-9530-088f1eb1e32d-livingroom.png"
mask_imagerequired
string (uri)

The URL of the main image mask

Default: "https://segmind-resources.s3.amazonaws.com/others/b2c6b355-07be-4edc-b6ce-ec05fd6a03f2-mask_room2.png"
object_imagerequired
string (uri)

The URL of the overlay image

Default: "https://segmind-resources.s3.amazonaws.com/others/69ceda90-7c13-48e2-a436-a4e0f733d136-table2.png"
base64optional
boolean

Return image as base64 string

Default: false
fashion_strengthoptional
number

fashion strength

Default: 1Range: 0 - 1
growmaskoptional
integer

Grow mask parameter for adjusting mask size

Default: 5Range: 0 - 20
horizontal_repeatoptional
integer

No of horizontal tiling of object (useful when object is a pattern)

Default: 1Range: 1 - 10
image_formatoptional
string

The output image format

Default: "png"
Allowed values :
"jpeg""png""webp"
image_qualityoptional
integer

The quality of the output image

Default: 95Range: 10 - 100
promptoptional
string

The main prompt describing the scene or subject

Default: "photo of a wooden table in center of living room"
seedoptional
integer

Random seed for reproducibility

Default: 42
stepsoptional
integer

The number of steps for image processing

Default: 30Range: 10 - 100
subject_strengthoptional
number

subject strength

Default: 1Range: 0 - 1
vertical_repeatoptional
integer

No of vertical tiling of object (useful when object is a pattern)

Default: 1Range: 1 - 10

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/seg-swap

    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