Segmind Relighting V2 Serverless API
Transform images with customizable, photorealistic lighting for unparalleled visual creativity and authenticity.
POST /v2/segmind-relighting-v2 · 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 "segmind-relighting-v2",
9 image="https://segmind-resources.s3.amazonaws.com/output/b9b4e651-ecfb-4dd8-a121-6663f63cca8e-5e23ecbb-6875-4296-9b05-481c03eac5bf.png",
10 light_direction="back",
11 light_type="spotlight",
12 light_temperature="warm",
13 light_intensity="strong",
14 size="auto",
15 quality="high",
16 background="opaque",
17 output_compression=100,
18 output_format="png",
19)
20print(result["status"]) # COMPLETED
21print(result.get("output")) # model output (e.g. media URL)
22print(result["metrics"]["inference_time"]) # server compute seconds
23
24# --- Or submit + poll manually (track request_id, control the cadence) ---
25from segmind import SegmindClient, InferenceFailed, InferenceTimeout
26
27client = SegmindClient() # reads SEGMIND_API_KEY
28payload = {
29 "image": "https://segmind-resources.s3.amazonaws.com/output/b9b4e651-ecfb-4dd8-a121-6663f63cca8e-5e23ecbb-6875-4296-9b05-481c03eac5bf.png",
30 "light_direction": "back",
31 "light_type": "spotlight",
32 "light_temperature": "warm",
33 "light_intensity": "strong",
34 "size": "auto",
35 "quality": "high",
36 "background": "opaque",
37 "output_compression": 100,
38 "output_format": "png",
39}
40job = client.submit_async("segmind-relighting-v2", **payload)
41print(job.request_id) # available immediately
42try:
43 result = job.wait(timeout=600, interval=1.0)
44except InferenceTimeout as e:
45 print("still running:", e.request_id)
46except InferenceFailed as e:
47 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 "segmind-relighting-v2",
9 image="https://segmind-resources.s3.amazonaws.com/output/b9b4e651-ecfb-4dd8-a121-6663f63cca8e-5e23ecbb-6875-4296-9b05-481c03eac5bf.png",
10 light_direction="back",
11 light_type="spotlight",
12 light_temperature="warm",
13 light_intensity="strong",
14 size="auto",
15 quality="high",
16 background="opaque",
17 output_compression=100,
18 output_format="png",
19)
20print(result["status"]) # COMPLETED
21print(result.get("output")) # model output (e.g. media URL)
22print(result["metrics"]["inference_time"]) # server compute seconds
23
24# --- Or submit + poll manually (track request_id, control the cadence) ---
25from segmind import SegmindClient, InferenceFailed, InferenceTimeout
26
27client = SegmindClient() # reads SEGMIND_API_KEY
28payload = {
29 "image": "https://segmind-resources.s3.amazonaws.com/output/b9b4e651-ecfb-4dd8-a121-6663f63cca8e-5e23ecbb-6875-4296-9b05-481c03eac5bf.png",
30 "light_direction": "back",
31 "light_type": "spotlight",
32 "light_temperature": "warm",
33 "light_intensity": "strong",
34 "size": "auto",
35 "quality": "high",
36 "background": "opaque",
37 "output_compression": 100,
38 "output_format": "png",
39}
40job = client.submit_async("segmind-relighting-v2", **payload)
41print(job.request_id) # available immediately
42try:
43 result = job.wait(timeout=600, interval=1.0)
44except InferenceTimeout as e:
45 print("still running:", e.request_id)
46except InferenceFailed as e:
47 print("failed:", e.detail)API Endpoint
https://api.segmind.com/v1/segmind-relighting-v2Parameters
imagerequiredstring (uri)Provide the URL of the image to be relit. Use a URL from cloud storage like S3.
light_directionrequiredstringSet the direction of lighting. For dramatic effects, choose 'back' or 'left'.
"back""left""right""top""back"light_intensityrequiredstringAdjust light brightness. Choose 'strong' for well-lit images and 'mood' for softer settings.
"strong""mood""bright""medium""strong"light_temperaturerequiredstringChoose light color to affect mood. 'Warm' is cozy while 'cool' suits tech themes.
"warm""warm""cool""neutral""sunset"light_typerequiredstringSelect the lighting source for desired mood. 'Spotlight' creates a focused beam effect.
"spotlight""softbox""sunlight""spotlight""ambient"backgroundoptionalstringSelect if the image background should be transparent or not; 'opaque' for regular use.
"opaque""transparent""opaque"output_compressionoptionalintegerAdjust compression level. Lower numbers mean smaller file size but risk quality loss.
100output_formatoptionalstringDecide the format for the output image; 'webp' for balanced quality and size.
"png""png""jpeg""webp"qualityoptionalstringSet visual quality of the output image. 'High' suits professional needs.
"high""low""medium""high"sizeoptionalstringDetermine output resolution. 'Auto' allows the model to decide optimal resolution.
"auto""1024x1024""1536x1024""1024x1536""auto"use_case_configoptionalstringResponse 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/segmind-relighting-v2Submit — 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