Pruna P Video Replace Serverless API
Swap on-screen video characters while preserving motion and audio.
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) 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
https://api.segmind.com/v1/p-video-replaceParameters
imagesrequiredstring[]One to three identity reference images to insert. Use clean, well-lit portraits.
videorequiredstring (uri)Source .mp4 whose motion and audio are kept. Use stable, clear-subject footage.
disable_safety_checkeroptionalbooleanTurns off content safety filtering. Leave off unless your pipeline handles moderation.
falseignore_audiooptionalbooleanIgnores source audio during generation. Enable when you need motion only.
falseinstruction_promptoptionalstringText naming who to replace and what to keep. Add detail when identity drifts.
""resolutionoptionalstringOutput resolution, either 720p or 1080p. Draft in 720p, finalize in 1080p.
"720p""720p""1080p"save_audiooptionalbooleanKeeps the source audio in the output. Enable for dialogue, disable for silent clips.
trueseedoptionalintegerRandom seed for reproducible output. Fix for A/B tests, vary for alternatives.
12345Range: -1 - 999999999999999target_fpsoptionalstringOutput frame rate: original, 24, or 48. Match source; use 24 for web.
"original""original""24""48"turbooptionalbooleanFaster inference with slightly lower quality. Enable for quick drafts, disable for finals.
falseResponse 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
POST /v2/p-video-replaceSubmit — 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