Pruna P Video Replace Serverless API

Swap on-screen video characters while preserving motion and audio.

~50.36s
POST /v2/p-video-replace · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3from segmind import SegmindClient, InferenceFailed, InferenceTimeout
 4
 5# Async (v2) — recommended for long-running / video models.
 6# run() blocks up to 600s; submit_async + job.wait(timeout=...) sets a longer
 7# deadline and keeps the request_id so you can re-poll later.
 8client = SegmindClient()                      # reads SEGMIND_API_KEY
 9payload = {
10    "video": "https://segmind-resources.s3.amazonaws.com/input/p-video-replace-source-video-1782918588.mp4",
11    "images": ["https://segmind-resources.s3.amazonaws.com/input/p-video-replace-identity-1782918588.jpg"],
12    "resolution": "720p",
13    "turbo": False,
14    "save_audio": True,
15    "ignore_audio": False,
16    "target_fps": "original",
17    "instruction_prompt": "",
18    "seed": 12345,
19    "disable_safety_checker": False,
20}
21job = client.submit_async("p-video-replace", **payload)
22print(job.request_id)                         # available immediately
23try:
24    result = job.wait(timeout=900, interval=2.0)
25    print(result["status"])                  # COMPLETED
26    print(result.get("output"))              # model output (e.g. video URL)
27except InferenceTimeout as e:
28    print("still running:", e.request_id)    # re-poll later with this id
29except InferenceFailed as e:
30    print("failed:", e.detail)
31
32# Fast models (<=600s) can use the one-liner instead:
33# result = segmind.run("p-video-replace", **payload)

API Endpoint

POSThttps://api.segmind.com/v1/p-video-replace

Parameters

imagesrequired
string[]

One to three identity reference images to insert. Use clean, well-lit portraits.

videorequired
string (uri)

Source .mp4 whose motion and audio are kept. Use stable, clear-subject footage.

disable_safety_checkeroptional
boolean

Turns off content safety filtering. Leave off unless your pipeline handles moderation.

Default: false
ignore_audiooptional
boolean

Ignores source audio during generation. Enable when you need motion only.

Default: false
instruction_promptoptional
string

Text naming who to replace and what to keep. Add detail when identity drifts.

Default: ""
resolutionoptional
string

Output resolution, either 720p or 1080p. Draft in 720p, finalize in 1080p.

Default: "720p"
Allowed values :
"720p""1080p"
save_audiooptional
boolean

Keeps the source audio in the output. Enable for dialogue, disable for silent clips.

Default: true
seedoptional
integer

Random seed for reproducible output. Fix for A/B tests, vary for alternatives.

Default: 12345Range: -1 - 999999999999999
target_fpsoptional
string

Output frame rate: original, 24, or 48. Match source; use 24 for web.

Default: "original"
Allowed values :
Original"original"
"24""48"
turbooptional
boolean

Faster inference with slightly lower quality. Enable for quick drafts, disable for finals.

Default: false

Response Type

Returns: Video

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/p-video-replace

    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