How to Automate Real Estate Videos With an AI Agent
How do you automate real estate videos with an AI agent?
Give an LLM agent, Claude or ChatGPT through their APIs, three tools that wrap the PhotoAIVideo API. The agent picks photos, camera moves, prompts and reel order; your code uploads the photos, checks credits and polls jobs. Each clip costs 1 credit, failed clips are refunded automatically, and a person approves every reel before it goes public.
Last reviewed · By Zach Calhoon, Founder
This guide is for software makers and brokerage ops teams who want an automatic listing video for every new listing without anyone clicking through each one. Keys, endpoints and plans live on the Real Estate Video API hub; this page covers the split between what an AI agent for listing video should judge and what your code should control, with Claude tool use first and the OpenAI form after.
Who runs each step
| Step | Endpoint | Run by | Why |
|---|---|---|---|
| upload_photos | GET /api/v1/presigned-urls, then PUT | Your code | Inputs must sit on PhotoAIVideo storage; the model only ever sees short ids like p01 |
| check_credits | GET /api/v1/credits | Your code, before the run | Refuse to start when remainingCredits is below clips + reels |
| create_clip | POST /api/v1/videos | Agent tool | Choosing the photo, move, length and prompt is judgment; enums and a cap bound it |
| wait_for_clips | GET /api/v1/videos/:jobId | Agent tool; your code polls | One compact result per batch instead of a model turn for every poll |
| merge_reel | POST /api/v1/reels | Agent tool | Clip order, music and short text are choices; your code attaches the logo |
| publish | None | A person | Going public can't be undone, so it is never a tool |
What does the agent decide, and what stays in your code?
A model earns its place on choices that need reading: which of forty shots deserve a clip, whether a kitchen wants a push-in or a slow pan, what each clip's prompt should say, which order walks a buyer through the house, and what short address line fits the record. A weak pick there costs one clip.
Uploading files, spending credits in bulk and posting in public are different. Each carries a cost a model can't take back, so they live in code you can read and test. The rule for this kind of real estate video API automation: every tool the model can call either costs nothing or costs one credit under a cap you set.
Which tools should the agent get?
Three tools are enough. Each Claude definition carries a name, a description and an input_schema (S3 (opens in a new tab)). Anthropic asks for descriptions that cover what a tool does, when to use it and how it behaves, so the text below is written for the model, not for a developer. Every move, length, orientation and music value is an enum copied from the API docs (S1 (opens in a new tab)), and strict: true makes Claude's calls “always match your schema exactly” (S2 (opens in a new tab)). Names fit ^[a-zA-Z0-9_-]{1,128}$. Your code fills the photo id enum with the ids it issued after upload.
[
{
"name": "create_clip",
"description": "Start one ~5-second camera-move clip from one listing photo. Call it once per photo you keep. Pick the move that suits the room. Use end_photo_id only when two photos show the same room from nearby angles. Returns a clip_id; the clip is not ready until wait_for_clips reports it.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"photo_id": { "type": "string", "enum": ["p01", "p02", "p03"] },
"end_photo_id": { "type": "string", "enum": ["p01", "p02", "p03"] },
"effect": {
"type": "string",
"enum": ["dolly_zoom", "pull_out", "push_in", "aerial_drone", "low_angle",
"high_angle", "aerial", "zoom_in", "zoom_out", "truck_left",
"truck_right", "pedestal_down", "pedestal_up", "crane_down",
"crane_up", "pan_left", "pan_right", "orbit_left", "orbit_right"]
},
"duration": { "type": "integer", "enum": [4, 5, 6] },
"prompt": { "type": "string", "description": "One sentence: what the camera sees and how it moves." }
},
"required": ["photo_id", "effect", "duration", "prompt"],
"additionalProperties": false
}
},
{
"name": "wait_for_clips",
"description": "Call after you have started every clip. Blocks until each clip is completed or failed and returns both lists. A failed clip's credit is refunded; read its error and pick a different photo or prompt.",
"strict": true,
"input_schema": {
"type": "object",
"properties": { "clip_ids": { "type": "array", "items": { "type": "string" } } },
"required": ["clip_ids"],
"additionalProperties": false
}
},
{
"name": "merge_reel",
"description": "Merge 2-30 completed clips into one reel, in the order given (repeats allowed). Use landscape with no text for the MLS cut and portrait for social. Text must come from the listing record. Returns the reel URL for human review.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"clip_ids": { "type": "array", "items": { "type": "string" }, "minItems": 2, "maxItems": 30 },
"orientation": { "type": "string", "enum": ["landscape", "portrait"] },
"music": { "type": "string", "enum": ["no_music", "tropical", "lofi", "jazz"] },
"address_text": { "type": "string" },
"ending_text": { "type": "string" }
},
"required": ["clip_ids", "orientation", "music"],
"additionalProperties": false
}
}
]What does the agent loop look like in Python?
The script uses the anthropic SDK and requests. Whenever Claude stops with stop_reason “tool_use” (S2 (opens in a new tab)), the loop runs each tool_use block and replies with tool_result blocks that come first in the next user message (S4 (opens in a new tab)). A failed call returns is_error: true so the model can choose again. When it stops asking for tools, the script prints the reel links for a person and exits.
import json, os, time
import anthropic, requests
BASE = "https://app.photoaivideo.com"
API = requests.Session()
API.headers["Authorization"] = f"Bearer {os.environ['PHOTOAIVIDEO_API_KEY']}"
MODEL = "claude-opus-5-5" # use a current model id from Anthropic's models page
TOOLS = json.load(open("tools.json")) # the three definitions above
photos: dict[str, str] = {} # "p01" -> publicUrl; the model sees only the ids
reels: list[str] = []
budget = 0 # clips this run may still start
def upload_photos(paths): # code only: the model never sees URLs or bytes
slots = API.get(f"{BASE}/api/v1/presigned-urls",
params={"count": len(paths)}).json()["uploads"] # 1-20 per call
for n, (path, slot) in enumerate(zip(paths, slots), start=1):
ctype = "image/png" if path.endswith(".png") else "image/jpeg"
requests.put(slot["presignedUrl"], data=open(path, "rb").read(),
headers={"Content-Type": ctype}).raise_for_status()
photos[f"p{n:02d}"] = slot["publicUrl"]
def credit_gate(clips, reel_count):
left = API.get(f"{BASE}/api/v1/credits").json()["remainingCredits"]
if left < clips + reel_count:
raise SystemExit(f"Need {clips + reel_count} credits, {left} left")
def post(path, body):
resp = API.post(f"{BASE}{path}", json=body)
if resp.status_code in (400, 402): # validation / not enough credits
raise ValueError(resp.text)
resp.raise_for_status()
return resp.json()["jobId"]
def poll(kind, job_id, cap=600):
deadline = time.monotonic() + cap
while time.monotonic() < deadline:
job = API.get(f"{BASE}/api/v1/{kind}/{job_id}").json()["job"]
if job["status"] in ("completed", "failed"):
return job
time.sleep(5)
return {"status": "failed", "error_message": "still running at the time cap"}
def create_clip(photo_id, effect, duration, prompt, end_photo_id=None):
global budget
if budget <= 0:
raise ValueError("clip budget reached")
body = {"prompt": prompt, "imageUrl": photos[photo_id],
"effects": [effect], "duration": duration}
if end_photo_id:
body["endImageUrl"] = photos[end_photo_id]
clip_id = post("/api/v1/videos", body)
budget -= 1
return {"clip_id": clip_id}
def wait_for_clips(clip_ids):
jobs = {c: poll("videos", c) for c in clip_ids}
return {
"completed": [c for c, j in jobs.items() if j["status"] == "completed"],
"failed": {c: j.get("error_message") for c, j in jobs.items()
if j["status"] == "failed"}, # credits already refunded
}
def merge_reel(clip_ids, orientation, music, address_text=None, ending_text=None):
body = {"videoJobIds": clip_ids, "orientation": orientation, "musicType": music}
if address_text:
body["textOverlay"] = {"text": address_text}
if ending_text:
body["ending"] = {"text": ending_text}
if orientation == "portrait": # branded social cut only; the MLS cut gets no logo
body["logo"] = {"url": os.environ["LOGO_PUBLIC_URL"]} # uploaded like a photo
reel = poll("reels", post("/api/v1/reels", body))
if reel["status"] == "failed":
raise ValueError(reel.get("error_message") or "reel failed")
reels.append(reel["output_video_url"])
return {"reel_url": reel["output_video_url"]}
HANDLERS = {"create_clip": create_clip, "wait_for_clips": wait_for_clips,
"merge_reel": merge_reel}
def run(record, paths):
global budget
upload_photos(paths)
budget = len(photos)
credit_gate(clips=budget, reel_count=2)
shots = ", ".join(f"{pid}={os.path.basename(p)}" for pid, p in zip(photos, paths))
messages = [{"role": "user", "content": f"Listing record:\n{record}\nPhotos: {shots}\n"
"Make a landscape MLS reel with no text and a portrait social reel."}]
client = anthropic.Anthropic()
while True:
resp = client.messages.create(model=MODEL, max_tokens=4096,
tools=TOOLS, messages=messages)
messages.append({"role": "assistant", "content": resp.content})
if resp.stop_reason != "tool_use":
break
results = []
for block in resp.content:
if block.type != "tool_use":
continue
try:
out, failed = HANDLERS[block.name](**block.input), False
except (ValueError, KeyError) as err:
out, failed = {"error": str(err)}, True
results.append({"type": "tool_result", "tool_use_id": block.id,
"content": json.dumps(out), "is_error": failed})
messages.append({"role": "user", "content": results})
print("Review before publishing:", *reels, sep="\n") # never posts anywhereRather not write the loop by hand? The SDK's tool runner can run it for you (S4 (opens in a new tab)). For a plain script with no model in it, start from the Python quickstart.
How is the same tool defined for ChatGPT?
With OpenAI function calling, the video API tool keeps its shape but changes two names (S5 (opens in a new tab)). The schema sits under parameters instead of input_schema, and each answer goes back as a function_call_output item carrying the call's call_id rather than a tool_result. Strict mode also wants additionalProperties: false on every object and every property listed as required, so end_photo_id becomes a string-or-null field. Setting parallel_tool_calls to false keeps each turn to zero or one call.
{
"type": "function",
"name": "create_clip",
"description": "Start one ~5-second camera-move clip from one listing photo...",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"photo_id": { "type": "string", "enum": ["p01", "p02", "p03"] },
"end_photo_id": { "type": ["string", "null"], "enum": ["p01", "p02", "p03", null] },
"effect": { "type": "string", "enum": ["dolly_zoom", "pull_out", "push_in", "..."] },
"duration": { "type": "integer", "enum": [4, 5, 6] },
"prompt": { "type": "string" }
},
"required": ["photo_id", "end_photo_id", "effect", "duration", "prompt"],
"additionalProperties": false
}
}How do you stop the agent from wasting credits?
- Enums plus strict schemas reject a made-up move or an 8-second clip before any request is sent.
- The gate compares
remainingCreditsfromGET /api/v1/creditswith clips plus reels before the first call. - A per-run cap set from the plan makes
create_clipreturnis_errorwith “clip budget reached” once the last allowed clip has started. - Two failures get a fixed retry in code: a photo over 6000 pixels on a side is resized and re-uploaded, and one that “could not be read” is uploaded again. The agent re-chooses only when a content check rejects the image, since that needs a different photo.
- A 402 means the account is short; return it as an error and end the run.
Credits are charged when a job is accepted and refunded automatically if generation fails (S1 (opens in a new tab)), so a failed clip ends up costing nothing. Backoff and time caps are covered in the async job polling guide.
Where does a person stay in the loop?
Nothing in this loop posts. The script ends with two links, and someone watches both reels before either one leaves your system. The landscape MLS cut goes out with no logo object and no agent or brokerage text in the overlay or ending card; check your MLS's own rules, and see MLS-compliant AI video software. The portrait cut can carry your logo for social. Keep the address line and ending text to facts in the listing record, and label the video as AI-made where a platform asks.
What can trigger the agent for every new listing?
Whichever system first knows a listing exists, your own listing database or a webhook from your CRM, calls the script once with that property's record and photos. Agents who don't need an API can use Automation Mode in the PhotoAIVideo app, which picks the movements, generates the clips and merges a reel in one click.
One agent run: an 11-photo 1928 Spanish Revival with a tiled courtyard
Illustrative run for a fictional listing — not a customer project or a real property.
| # | Tool call (who) | Input | Result | Credits |
|---|---|---|---|---|
| 1 | upload_photos (code) | 11 photos | Ids p01–p11 | 0 |
| 2 | check_credits (code) | Plan: 11 clips + 2 reels = 13 | Remaining ≥ 13, run allowed | 0 |
| 3 | create_clip ×11 (agent) | p01 front elevation pull_out 5 s; p02 courtyard fountain orbit_left; p03 arched living room pan_right; p04 beamed-ceiling dining crane_up; p05 kitchen with tile backsplash push_in; p06 primary bedroom push_in; p07 bath with vintage tile pedestal_up; p08 second bedroom truck_left; p09 loggia truck_right; p10 rear garden dolly_zoom; p11 roofline aerial_drone | 11 jobs pending | 11 |
| 4 | wait_for_clips (agent; code polls) | 11 clip ids | 10 completed; p05 failed: “The photo is too large…” | 1 refunded |
| 5 | Retry (code) | p05 resized to ≤ 6000 px per side, re-uploaded, create_clip again | Completed | 1 |
| 6 | merge_reel (agent) | Landscape, no_music, no text | MLS cut, no logo | 1 |
| 7 | merge_reel (agent) | Portrait, lofi, address_text “1928 Spanish Revival · 3 bd · 2 ba”, ending_text “Schedule a showing” | Social cut; logo added by code | 1 |
| 8 | Human review | Both reels | MLS cut approved; social address text edited to match the record before posting | 0 |
Totals: 12 clip charges − 1 refund + 2 reels = 13 credits net. Eleven clips at about 5 seconds each make a reel of roughly 55 seconds.
The bath uses pedestal_up because the docs list no tilt code, and the enum would reject one.
What does the PhotoAIVideo API give the agent to work with?
| Base URL | https://app.photoaivideo.com |
|---|---|
| Auth | Authorization: Bearer <API_KEY> or x-api-key; keys from the API dashboard |
| Upload | Presigned URLs, 1–20 per call, free; JPEG or PNG; external URLs rejected |
| Clip | POST /api/v1/videos on Hypernova; 4, 5 or 6 s; 1 credit |
| Moves | 19 effect codes |
| Reel | POST /api/v1/reels; 2–30 clips; landscape 1920x1080 or portrait 1080x1920; music, text overlay, ending card, logo; 1 credit |
| Refunds | Automatic when a generation fails |
| Errors | 400, 401, 402, 403, 404, 500 |
| Price | See plans |
How to automate listing videos with an AI agent and the PhotoAIVideo API
Get an API key
Create a key in the PhotoAIVideo app's API dashboard and keep it in an environment variable.
Upload and gate in code
Upload the listing photos through presigned URLs, map them to short ids, and stop if remaining credits are below clips plus reels.
Give the agent three tools
Define create_clip, wait_for_clips and merge_reel with strict schemas whose enums come from the API docs.
Run the tool loop
Answer each tool call with a result, enforce the clip cap, and retry oversized or unreadable photos in code.
Review, then publish
Watch both reels, then post the unbranded landscape cut to the MLS and the branded portrait cut to social.
Frequently Asked Questions
On photo rights, see can agents turn listing photos into AI video?
Ready to wire up your agent?
Sources
- S1. PhotoAIVideo API documentation (opens in a new tab)
- S2. Claude Platform Docs — Tool use with Claude (opens in a new tab)
- S3. Claude Platform Docs — Define tools (opens in a new tab)
- S4. Claude Platform Docs — Handle tool calls (opens in a new tab)
- S5. OpenAI API docs — Function calling (opens in a new tab)
- S6. PhotoAIVideo — Can agents turn listing photos into AI video?
All accessed November 28, 2026. PhotoAIVideo is not affiliated with Anthropic or OpenAI.