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.
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) 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
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
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