Segmind Relighting V2 Serverless API

Transform images with customizable, photorealistic lighting for unparalleled visual creativity and authenticity.

~68.72s
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)

API Endpoint

POSThttps://api.segmind.com/v1/segmind-relighting-v2

Parameters

imagerequired
string (uri)

Provide the URL of the image to be relit. Use a URL from cloud storage like S3.

light_directionrequired
string

Set the direction of lighting. For dramatic effects, choose 'back' or 'left'.

Default: "back"
Allowed values :
"left""right""top""back"
light_intensityrequired
string

Adjust light brightness. Choose 'strong' for well-lit images and 'mood' for softer settings.

Default: "strong"
Allowed values :
"mood""bright""medium""strong"
light_temperaturerequired
string

Choose light color to affect mood. 'Warm' is cozy while 'cool' suits tech themes.

Default: "warm"
Allowed values :
"warm""cool""neutral""sunset"
light_typerequired
string

Select the lighting source for desired mood. 'Spotlight' creates a focused beam effect.

Default: "spotlight"
Allowed values :
"softbox""sunlight""spotlight""ambient"
backgroundoptional
string

Select if the image background should be transparent or not; 'opaque' for regular use.

Default: "opaque"
Allowed values :
"transparent""opaque"
output_compressionoptional
integer

Adjust compression level. Lower numbers mean smaller file size but risk quality loss.

Default: 100
output_formatoptional
string

Decide the format for the output image; 'webp' for balanced quality and size.

Default: "png"
Allowed values :
"png""jpeg""webp"
qualityoptional
string

Set visual quality of the output image. 'High' suits professional needs.

Default: "high"
Allowed values :
"low""medium""high"
sizeoptional
string

Determine output resolution. 'Auto' allows the model to decide optimal resolution.

Default: "auto"
Allowed values :
"1024x1024""1536x1024""1024x1536""auto"
use_case_configoptional
string

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/segmind-relighting-v2

    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