Relighting Serverless API

Prompts to auto-magically relight your images.

~30.50s
POST /v2/ic-light · 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    "ic-light",
 9    cfg=2,
10    seed=42,
11    steps=25,
12    width=512,
13    height=640,
14    prompt="cat, photoshoot, 4k",
15    highres_scale=1.5,
16    output_format="webp",
17    subject_image="https://segmind-sd-models.s3.amazonaws.com/display_images/ic-lighting-input.jpeg",
18    lowres_denoise=0.9,
19    output_quality=80,
20    appended_prompt="best quality",
21    highres_denoise=0.5,
22    negative_prompt="lowres, bad anatomy, bad hands, cropped, worst quality",
23    number_of_images=1,
24)
25print(result["status"])                      # COMPLETED
26print(result.get("output"))                  # model output (e.g. media URL)
27print(result["metrics"]["inference_time"])   # server compute seconds
28
29# --- Or submit + poll manually (track request_id, control the cadence) ---
30from segmind import SegmindClient, InferenceFailed, InferenceTimeout
31
32client = SegmindClient()                      # reads SEGMIND_API_KEY
33payload = {
34    "cfg": 2,
35    "seed": 42,
36    "steps": 25,
37    "width": 512,
38    "height": 640,
39    "prompt": "cat, photoshoot, 4k",
40    "highres_scale": 1.5,
41    "output_format": "webp",
42    "subject_image": "https://segmind-sd-models.s3.amazonaws.com/display_images/ic-lighting-input.jpeg",
43    "lowres_denoise": 0.9,
44    "output_quality": 80,
45    "appended_prompt": "best quality",
46    "highres_denoise": 0.5,
47    "negative_prompt": "lowres, bad anatomy, bad hands, cropped, worst quality",
48    "number_of_images": 1,
49}
50job = client.submit_async("ic-light", **payload)
51print(job.request_id)                         # available immediately
52try:
53    result = job.wait(timeout=600, interval=1.0)
54except InferenceTimeout as e:
55    print("still running:", e.request_id)
56except InferenceFailed as e:
57    print("failed:", e.detail)

API Endpoint

POSThttps://api.segmind.com/v1/ic-light

Parameters

promptrequired
string

A text description guiding the relighting and generation process

Default: "cat, photoshoot, 4k"
subject_imagerequired
string (uri)

The main foreground image to be relighted

Default: "https://segmind-sd-models.s3.amazonaws.com/display_images/ic-lighting-input.jpeg"
appended_promptoptional
string

Additional text to be appended to the main prompt, enhancing image quality

Default: "best quality"
cfgoptional
number

Classifier-Free Guidance scale - higher values encourage adherence to prompt, lower values encourage more creative interpretation

Default: 2Range: 1 - 32
heightoptional
integer

An enumeration.

Default: 640
Allowed values (13 total):
256320384448512576640704768832+3 more
highres_denoiseoptional
number

Controls the amount of denoising applied when refining the high resolution output (higher = more adherence to the upscaled latent, lower = more creative details added)

Default: 0.5Range: 0.1 - 1
highres_scaleoptional
number

The multiplier for the final output resolution relative to the initial latent resolution

Default: 1.5Range: 1 - 3
light_sourceoptional
string

An enumeration.

Allowed values :
"None""Left Light""Right Light""Top Light""Bottom Light"
lowres_denoiseoptional
number

Controls the amount of denoising applied when generating the initial latent from the background image (higher = more adherence to the background, lower = more creative interpretation)

Default: 0.9Range: 0.1 - 1
negative_promptoptional
string

A text description of attributes to avoid in the generated images

Default: "lowres, bad anatomy, bad hands, cropped, worst quality"
number_of_imagesoptional
integer

The number of unique images to generate from the given input and settings

Default: 1Range: 1 - 12
output_formatoptional
string

An enumeration.

Default: "webp"
Allowed values :
"webp""jpg""png"
output_qualityoptional
integer

The image compression quality (for lossy formats like JPEG and WebP). 100 = best quality, 0 = lowest quality.

Default: 80Range: 0 - 100
seedoptional
integer

A fixed random seed for reproducible results (omit this parameter for a randomized seed)

Default: 42
stepsoptional
integer

The number of diffusion steps to perform during generation (more steps generally improves image quality but increases processing time)

Default: 25Range: 1 - 100
widthoptional
integer

An enumeration.

Default: 512
Allowed values (13 total):
256320384448512576640704768832+3 more

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/ic-light

    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