# P-Video 2 Pro Replace API Documentation > LLM-optimized documentation for P-Video 2 Pro Replace. Copy into your AI assistant for integration help. ## Overview **Model ID:** `p-video-2-pro-replace` **Type:** Video Generation **Credit Cost:** 3 credits per second Pruna P-Video 2 Pro Replace, built on MiniMax H3: swap one or two people in a video for the people in your pictures. Motion, camera, background, everyone else and the sound stay as they were. Up to 120 seconds, 480p or 768p. ## Endpoint ``` POST https://pixeldojo.ai/api/v1/models/p-video-2-pro-replace/run ``` ## Authentication All requests require an API key in the Authorization header: ``` Authorization: Bearer YOUR_API_KEY ``` Get your API key: https://pixeldojo.ai/api-platform/api-keys ## Input Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `video` | url | Yes | - | MP4, MOV or WebM, 1-120 seconds. The output keeps its length, motion, camera, background and sound. | | `images` | array | Yes | - | One picture replaces the main person. Two pictures replace two people, matched left to right unless instruction_prompt says otherwise. | | `instruction_prompt` | string | No | - | Optional, e.g. "The dancer on the left becomes the woman from image 1, the one on the right the man from image 2." | | `video_duration` | number | No | - | Measured from the file by the server before any charge; a sent value is ignored. (min: 1, max: 120) | | `resolution` | enum | No | 768p | 480p (1.5 credits/s) or 768p (3 credits/s). Aspect ratio follows the source. (Options: 480p, 768p) | | `save_audio` | boolean | No | true | Keep the source soundtrack. | | `seed` | integer | No | - | Optional integer seed. | ## Capabilities - Image to Video - Audio Generation ## Quick Start ### 1. Submit a Job ```bash curl -X POST "https://pixeldojo.ai/api/v1/models/p-video-2-pro-replace/run" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "video": "https://example.com/clip.mp4", "images": [ "https://example.com/person.jpg" ], "resolution": "768p" }' ``` **Response:** ```json { "jobId": "job_abc123...", "status": "pending", "statusUrl": "https://pixeldojo.ai/api/v1/jobs/job_abc123", "creditCost": 15, "creditsRemaining": 95 } ``` ### 2. Poll for Results ```bash curl "https://pixeldojo.ai/api/v1/jobs/job_abc123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Completed Response:** ```json { "jobId": "job_abc123...", "status": "completed", "output": { "video": "https://temp.pixeldojo.ai/..." }, "creditCost": 15 } ``` ## Python Example ```python import requests import time API_KEY = "YOUR_API_KEY" # Submit job response = requests.post( "https://pixeldojo.ai/api/v1/models/p-video-2-pro-replace/run", headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" }, json={ "video": "https://example.com/clip.mp4", "images": ["https://example.com/person.jpg"], "resolution": "768p" } ) job = response.json() job_id = job["jobId"] # Poll for completion while True: status_response = requests.get( f"https://pixeldojo.ai/api/v1/jobs/{'{job_id}'}", headers={"Authorization": f"Bearer {API_KEY}"} ) status = status_response.json() if status["status"] == "completed": print("Output:", status["output"]) break elif status["status"] == "failed": print("Error:", status.get("error")) break time.sleep(2) ``` ## JavaScript Example ```javascript const API_KEY = 'YOUR_API_KEY'; // Submit job const submitResponse = await fetch('https://pixeldojo.ai/api/v1/models/p-video-2-pro-replace/run', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "video": "https://example.com/clip.mp4", "images": [ "https://example.com/person.jpg" ], "resolution": "768p" }) }); const job = await submitResponse.json(); // Poll for completion const pollForResult = async (jobId) => { while (true) { const statusResponse = await fetch(`https://pixeldojo.ai/api/v1/jobs/${jobId}`, { headers: { 'Authorization': `Bearer ${API_KEY}` } }); const status = await statusResponse.json(); if (status.status === 'completed') return status.output; if (status.status === 'failed') throw new Error(status.error); await new Promise(r => setTimeout(r, 2000)); } }; const output = await pollForResult(job.jobId); console.log('Output:', output); ``` ## Use Saved Characters (@Name) Write `@Name` in the prompt to use a character, product, outfit, location, prop or style saved in the account's Character Studio, for example `"@Mara on a beach at sunset"`. Its photos are added to `images` automatically, after any images you send yourself, so your own image numbering is unchanged. List saved names with `GET /api/v1/characters` and save new ones with `POST /api/v1/characters`. An `@word` that names nothing saved stays plain text. ## Error Codes | Code | Status | Description | |------|--------|-------------| | `unauthorized` | 401 | Invalid or missing API key | | `insufficient_credits` | 402 | Not enough credits | | `invalid_request` | 400 | Invalid parameters | | `model_not_found` | 404 | Model ID not found | | `internal_error` | 500 | Server error | ## Links - **Full Documentation:** https://pixeldojo.ai/api-platform/p-video-2-pro-replace - **API Keys:** https://pixeldojo.ai/api-platform/api-keys - **Buy Credits:** https://pixeldojo.ai/api-platform/buy-credits - **All Models:** https://pixeldojo.ai/api/v1/models - **OpenAPI Spec:** https://pixeldojo.ai/api/openapi