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.
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) 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
https://api.segmind.com/v1/seg-swapParameters
main_imagerequiredstring (uri)The URL of the main image
"https://segmind-resources.s3.amazonaws.com/others/b855aade-9114-4554-9530-088f1eb1e32d-livingroom.png"mask_imagerequiredstring (uri)The URL of the main image mask
"https://segmind-resources.s3.amazonaws.com/others/b2c6b355-07be-4edc-b6ce-ec05fd6a03f2-mask_room2.png"object_imagerequiredstring (uri)The URL of the overlay image
"https://segmind-resources.s3.amazonaws.com/others/69ceda90-7c13-48e2-a436-a4e0f733d136-table2.png"base64optionalbooleanReturn image as base64 string
falsefashion_strengthoptionalnumberfashion strength
1Range: 0 - 1growmaskoptionalintegerGrow mask parameter for adjusting mask size
5Range: 0 - 20horizontal_repeatoptionalintegerNo of horizontal tiling of object (useful when object is a pattern)
1Range: 1 - 10image_formatoptionalstringThe output image format
"png""jpeg""png""webp"image_qualityoptionalintegerThe quality of the output image
95Range: 10 - 100promptoptionalstringThe main prompt describing the scene or subject
"photo of a wooden table in center of living room"seedoptionalintegerRandom seed for reproducibility
42stepsoptionalintegerThe number of steps for image processing
30Range: 10 - 100subject_strengthoptionalnumbersubject strength
1Range: 0 - 1vertical_repeatoptionalintegerNo of vertical tiling of object (useful when object is a pattern)
1Range: 1 - 10Response 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/seg-swapSubmit — 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