Real Estate Video API Python Quickstart
How do you call the PhotoAIVideo API from Python?
PhotoAIVideo exposes a REST API you can drive from Python 3 with the requests library. Each listing photo becomes one POST to /api/v1/videos, which returns a Hypernova clip job of 4 to 6 seconds; a single POST to /api/v1/reels then merges 2 to 30 finished clips into a 1080x1920 or 1920x1080 MP4.
Last reviewed · By Zach Calhoon, Founder
For developers with a key who want code: point the script at a folder of listing photos and it saves reel.mp4. Endpoints and plans live on the Real Estate Video API hub; every call below follows the official docs.
Quickstart at a glance
| Language | Python 3.9 or newer |
|---|---|
| Dependencies | requests; everything else is the standard library |
| Auth | Bearer key read from PHOTOAIVIDEO_API_KEY |
| Upload | Presigned URLs, up to 20 per call and free; PUT JPEG or PNG bytes |
| Clip length | 4, 5 or 6 seconds per photo; the script uses 5 |
| Reel | 2 to 30 finished clips, portrait 1080x1920 or landscape 1920x1080 |
| Billing | 1 credit per clip job and per merge; plans on pricing |
| Failures | Failed jobs refund their credit; the script skips them |
What do you need before running the script?
Python 3.9+ (for list[str] hints), requests, and a key from the API dashboard.
pip install requests
export PHOTOAIVIDEO_API_KEY="your-key-from-the-api-dashboard"
python quickstart.py ./photos "Address text for the overlay"- The key is read from
PHOTOAIVIDEO_API_KEY, so it never lands in the file or a commit. - Calls go to
BASE = "https://app.photoaivideo.com"through onerequests.Session()carryingAuthorization: Bearer(anx-api-keyheader also works). - Every request passes
timeout=, as the requests docs advise, so a silent server can't hang the run. - Filenames like
01-front-exterior.jpgsort into walk-through order, which becomes reel order.
What does the full Python script look like?
Save it as quickstart.py; it sends only documented v1 fields.
#!/usr/bin/env python3
"""Folder of listing photos -> PhotoAIVideo clips -> one reel MP4."""
import os
import sys
import time
from pathlib import Path
import requests
BASE = "https://app.photoaivideo.com"
API_KEY = os.environ.get("PHOTOAIVIDEO_API_KEY")
if not API_KEY:
sys.exit("Set PHOTOAIVIDEO_API_KEY before running this script.")
session = requests.Session()
session.headers.update({"Authorization": f"Bearer {API_KEY}"})
TIMEOUT = 30 # seconds for API calls
TRANSFER_TIMEOUT = 120 # seconds for photo uploads and the MP4 download
POLL_SECONDS = 5
DEADLINE_SECONDS = 15 * 60
# Filename keyword -> (effect code, prompt). First match wins.
MOVES = {
"exterior": ("pull_out", "Slow pull out revealing the front of the house"),
"entry": ("push_in", "Gentle push in through the front entry"),
"living": ("pan_right", "Smooth pan right across the living room"),
"kitchen": ("truck_left", "Steady truck left along the kitchen counters"),
"bedroom": ("push_in", "Soft push in toward the bed"),
"bath": ("pan_left", "Slow pan left across the bathroom vanity"),
"backyard": ("aerial_drone", "Rising aerial view over the backyard"),
"patio": ("orbit_right", "Slow orbit right around the patio at dusk"),
}
FALLBACK = ("push_in", "Slow cinematic push in")
def check_credits(needed: int) -> None:
resp = session.get(f"{BASE}/api/v1/credits", timeout=TIMEOUT)
resp.raise_for_status()
remaining = resp.json()["remainingCredits"]
if remaining < needed:
sys.exit(f"This run needs {needed} credits; {remaining} remain.")
def content_type(path: Path) -> str:
return "image/png" if path.suffix.lower() == ".png" else "image/jpeg"
def upload(paths: list[Path]) -> list[str]:
public_urls: list[str] = []
for start in range(0, len(paths), 20):
chunk = paths[start:start + 20]
resp = session.get(f"{BASE}/api/v1/presigned-urls",
params={"count": len(chunk)}, timeout=TIMEOUT)
resp.raise_for_status()
for path, slot in zip(chunk, resp.json()["uploads"]):
# Plain requests.put: the storage URL must not get the Bearer header.
put = requests.put(slot["presignedUrl"], data=path.read_bytes(),
headers={"Content-Type": content_type(path)},
timeout=TRANSFER_TIMEOUT)
put.raise_for_status()
public_urls.append(slot["publicUrl"])
return public_urls
def post(path: str, body: dict) -> dict:
resp = session.post(f"{BASE}{path}", json=body, timeout=TIMEOUT)
if resp.status_code == 402:
info = resp.json()
sys.exit(f"Not enough credits: required {info.get('required')}, "
f"remaining {info.get('remaining')}.")
if resp.status_code == 400:
sys.exit(f"Validation error from {path}: {resp.text}")
resp.raise_for_status()
return resp.json()
def create_clip(url: str, prompt: str, effects: list[str],
duration: int = 5) -> str:
body = {"prompt": prompt, "imageUrl": url, "effects": effects,
"duration": duration, "model": "hypernova"}
return post("/api/v1/videos", body)["jobId"]
def wait(kind: str, job_id: str) -> dict:
deadline = time.monotonic() + DEADLINE_SECONDS
while time.monotonic() < deadline:
resp = session.get(f"{BASE}/api/v1/{kind}/{job_id}", timeout=TIMEOUT)
resp.raise_for_status()
job = resp.json()["job"]
if job["status"] == "completed":
return job
if job["status"] == "failed":
raise RuntimeError(job.get("error_message") or "generation failed")
time.sleep(POLL_SECONDS)
raise TimeoutError(f"{kind} job {job_id} was still running at the deadline")
def make_reel(job_ids: list[str], address: str) -> str:
body = {
"videoJobIds": job_ids,
"orientation": "portrait",
"musicType": "lofi",
"isFadingEnable": True,
"textOverlay": {"text": address, "position": {"x": 50, "y": 80}},
"ending": {"text": "Book a showing", "duration": 3},
}
return post("/api/v1/reels", body)["jobId"]
def download(url: str, path: Path) -> None:
with requests.get(url, stream=True, timeout=TRANSFER_TIMEOUT) as resp:
resp.raise_for_status()
with path.open("wb") as out:
for chunk in resp.iter_content(chunk_size=1 << 20):
out.write(chunk)
def main(folder: str, address: str = "123 Placeholder Lane") -> None:
photos = sorted(p for p in Path(folder).iterdir()
if p.suffix.lower() in {".jpg", ".jpeg", ".png"})
if len(photos) < 2:
sys.exit("Put at least 2 JPEG or PNG photos in the folder.")
check_credits(len(photos) + 1)
urls = upload(photos)
jobs: list[tuple[Path, str]] = []
for photo, url in zip(photos, urls):
effect, prompt = next((move for key, move in MOVES.items()
if key in photo.stem.lower()), FALLBACK)
job_id = create_clip(url, prompt, [effect])
jobs.append((photo, job_id))
print(f"queued {photo.name} -> {job_id}")
done: list[str] = []
for photo, job_id in jobs:
try:
wait("videos", job_id)
done.append(job_id)
print(f"done {photo.name}")
except RuntimeError as err:
print(f"failed {photo.name}: {err} (credit refunded)")
except TimeoutError as err:
print(f"skipped {photo.name}: {err}")
if len(done) < 2:
sys.exit("Fewer than 2 clips completed, so no reel was merged.")
try:
reel = wait("reels", make_reel(done, address))
except (RuntimeError, TimeoutError) as err:
sys.exit(f"Reel merge did not finish: {err}")
out = Path(folder) / "reel.mp4"
download(reel["download_url"], out)
print(f"saved {out} ({len(done)} clips)")
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit('Usage: python quickstart.py <photo-folder> ["address text"]')
main(*sys.argv[1:3])
How do you upload listing photos from Python?
check_credits() reads GET /api/v1/credits and quits before any upload if remainingCredits is under one per photo plus one for the merge; the balance is shared by every key on the account.
upload() asks GET /api/v1/presigned-urls for at most 20 free slots per call, then PUTs bytes with a bare requests.put so the Bearer header never reaches storage. PNGs get image/png, the rest image/jpeg, and each publicUrl comes back in input order. Images hosted elsewhere are rejected, so this step is required.
How do you create and poll clip jobs?
create_clip() sends a prompt, the uploaded imageUrl, a one-item effects list, duration 5 and model "hypernova" to POST /api/v1/videos, then returns the jobId. The MOVES dict picks the effect from a filename keyword (kitchen gets truck_left), falling back to push_in.
main() queues every clip before waiting on any. wait() checks GET /api/v1/videos/:jobId every 5 seconds with a 15-minute deadline, returns on completed and raises with error_message on failed, which main() logs and skips.
How do you merge clips into a reel and download it?
With two or more finished clips, make_reel() posts their IDs to POST /api/v1/reels in filename order. The body asks for a portrait 1080x1920 cut, lofi music, fades, the address as a textOverlay near the bottom and a three-second ending card.
The same wait() polls GET /api/v1/reels/:jobId. download() streams download_url to reel.mp4 in 1 MB chunks; output_video_url plays inline instead.
What does each API error mean in Python?
"failed" rows are job statuses; each error_message confirms the credit was refunded.
| Status | Meaning | What the script does |
|---|---|---|
| 400 | Validation failed; the message lists allowed values, e.g. a duration outside 4, 5 or 6 or an unknown effect. | post() prints the body and exits. |
| 401 | Missing or invalid key. | HTTPError; check PHOTOAIVIDEO_API_KEY. |
| 402 | Not enough credits; body has required and remaining. | Prints both numbers and stops. |
| 403 | API access not enabled. | HTTPError; contact support. |
| 404 | Job missing or owned by another key. | HTTPError. |
| 500 | Server error. | HTTPError; no retry, run again later. |
| failed: content checks | Photo did not pass content checks. | Clip skipped, credit refunded. |
| failed: photo too large | A side exceeds 6000 pixels. | Skipped; resize and rerun. |
| failed: unreadable photo | File could not be read as an image. | Skipped; re-export as JPEG or PNG. |
| failed: took too long | Generation was stopped. | Skipped; submit the photo again. |
A job past the script's deadline may still finish, so look it up by ID before resubmitting.
What does one run look like for an 8-photo house?
Illustrative example, not a customer project: a 3-bedroom ranch house, 8 photos in a folder.
| File | Effect | Prompt |
|---|---|---|
| 01-front-exterior.jpg | pull_out | Slow pull out revealing the front of the house |
| 02-entry.jpg | push_in | Gentle push in through the front entry |
| 03-living-room.jpg | pan_right | Smooth pan right across the living room |
| 04-kitchen.jpg | truck_left | Steady truck left along the kitchen counters |
| 05-primary-bedroom.jpg | push_in | Soft push in toward the bed |
| 06-primary-bath.jpg | pan_left | Slow pan left across the bathroom vanity |
| 07-backyard.jpg | aerial_drone | Rising aerial view over the backyard |
| 08-patio-dusk.jpg | orbit_right | Slow orbit right around the patio at dusk |
Calls for this run: 1 credits check, 1 presigned-urls request with count=8, 8 PUTs, 8 video jobs (8 credits), 8 polling loops and 1 reel merge (1 credit), for 9 credits charged. Eight 5-second clips give about 40 seconds of footage before the ending card.
Sample output with placeholder IDs, where one clip fails:
queued 01-front-exterior.jpg -> 3f2c…
queued 02-entry.jpg -> 8a41…
queued 03-living-room.jpg -> c07e…
queued 04-kitchen.jpg -> 51bd…
queued 05-primary-bedroom.jpg -> e9a3…
queued 06-primary-bath.jpg -> 2d68…
queued 07-backyard.jpg -> 74f0…
queued 08-patio-dusk.jpg -> b15c…
done 01-front-exterior.jpg
done 02-entry.jpg
done 03-living-room.jpg
done 04-kitchen.jpg
done 05-primary-bedroom.jpg
failed 06-primary-bath.jpg: <error_message from the job> (credit refunded)
done 07-backyard.jpg
done 08-patio-dusk.jpg
saved photos/reel.mp4 (7 clips)The failed clip is refunded and the reel merges from 7 clips, netting 8 credits.
How do you run it, step by step?
- Install and set the key. pip install requests, then export PHOTOAIVIDEO_API_KEY.
- Order the photos. Prefix filenames 01-, 02- so sorted order is reel order.
- Check credits. Stop if fewer than photos + 1 credits remain.
- Upload. Get presigned URLs, PUT each file, keep the publicUrl values.
- Queue clips. POST /api/v1/videos once per photo with model hypernova.
- Poll. Check each job every 5 seconds; log and skip failures.
- Merge and download. POST /api/v1/reels, poll it, stream download_url to disk.
How do you adapt the script for production?
- Landscape cut. Set
orientationtolandscape(1920x1080) andmusicTypetono_music, and droptextOverlayandlogo, for a website or MLS-style version from the same job IDs. - Start and end frames. Add
endImageUrlwith a second uploaded photo of the same room to get a start and end frame clip. - Recovering job IDs.
GET /api/v1/videos?limit=20&offset=0lists this key's jobs newest first, handy after a crash. - Workers. In a web app, move
wait()into a background worker or queue instead of a request handler. The polling guide covers those patterns.
The build guide explains the architecture behind a video feature. This page is the code.
Frequently Asked Questions
Run it against your first listing
Create a key, drop a few test photos in a folder and run the script once before wiring it into your product.
Sources
- PhotoAIVideo API v1 documentation, accessed November 24, 2026.
- Requests documentation, "Quickstart", accessed November 24, 2026.