Segmind SegSwap v0.1

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.33s
~$0.286
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/seg-swap"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "prompt": "photo of a wooden table in center of living room",
12    "main_image": "https://segmind-resources.s3.amazonaws.com/others/b855aade-9114-4554-9530-088f1eb1e32d-livingroom.png",
13    "object_image": "https://segmind-resources.s3.amazonaws.com/others/69ceda90-7c13-48e2-a436-a4e0f733d136-table2.png",
14    "mask_image": "https://segmind-resources.s3.amazonaws.com/others/b2c6b355-07be-4edc-b6ce-ec05fd6a03f2-mask_room2.png",
15    "steps": 30,
16    "seed": 42,
17    "growmask": 5,
18    "fashion_strength": 1,
19    "subject_strength": 1,
20    "horizontal_repeat": 1,
21    "vertical_repeat": 1,
22    "image_format": "png",
23    "image_quality": 95,
24    "base64": false
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

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

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