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

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

Who runs each step of an agent-driven listing video
StepEndpointRun byWhy
upload_photosGET /api/v1/presigned-urls, then PUTYour codeInputs must sit on PhotoAIVideo storage; the model only ever sees short ids like p01
check_creditsGET /api/v1/creditsYour code, before the runRefuse to start when remainingCredits is below clips + reels
create_clipPOST /api/v1/videosAgent toolChoosing the photo, move, length and prompt is judgment; enums and a cap bound it
wait_for_clipsGET /api/v1/videos/:jobIdAgent tool; your code pollsOne compact result per batch instead of a model turn for every poll
merge_reelPOST /api/v1/reelsAgent toolClip order, music and short text are choices; your code attaches the logo
publishNoneA personGoing 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.

tools.json: Claude tool definitions
[
  {
    "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.

agent_run.py
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 anywhere

Rather 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.

create_clip as an OpenAI function tool (strict)
{
  "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 remainingCredits from GET /api/v1/credits with clips plus reels before the first call.
  • A per-run cap set from the plan makes create_clip return is_error with “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 calls, inputs, results and credits for one illustrative agent run
#Tool call (who)InputResultCredits
1upload_photos (code)11 photosIds p01–p110
2check_credits (code)Plan: 11 clips + 2 reels = 13Remaining ≥ 13, run allowed0
3create_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_drone11 jobs pending11
4wait_for_clips (agent; code polls)11 clip ids10 completed; p05 failed: “The photo is too large…”1 refunded
5Retry (code)p05 resized to ≤ 6000 px per side, re-uploaded, create_clip againCompleted1
6merge_reel (agent)Landscape, no_music, no textMLS cut, no logo1
7merge_reel (agent)Portrait, lofi, address_text “1928 Spanish Revival · 3 bd · 2 ba”, ending_text “Schedule a showing”Social cut; logo added by code1
8Human reviewBoth reelsMLS cut approved; social address text edited to match the record before posting0

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?

PhotoAIVideo API key facts
Base URLhttps://app.photoaivideo.com
AuthAuthorization: Bearer <API_KEY> or x-api-key; keys from the API dashboard
UploadPresigned URLs, 1–20 per call, free; JPEG or PNG; external URLs rejected
ClipPOST /api/v1/videos on Hypernova; 4, 5 or 6 s; 1 credit
Moves19 effect codes
ReelPOST /api/v1/reels; 2–30 clips; landscape 1920x1080 or portrait 1080x1920; music, text overlay, ending card, logo; 1 credit
RefundsAutomatic when a generation fails
Errors400, 401, 402, 403, 404, 500
PriceSee plans

How to automate listing videos with an AI agent and the PhotoAIVideo API

  1. Get an API key

    Create a key in the PhotoAIVideo app's API dashboard and keep it in an environment variable.

  2. 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.

  3. Give the agent three tools

    Define create_clip, wait_for_clips and merge_reel with strict schemas whose enums come from the API docs.

  4. Run the tool loop

    Answer each tool call with a result, enforce the clip cap, and retry oversized or unreadable photos in code.

  5. 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

No. Neither Anthropic, OpenAI nor PhotoAIVideo ships a plugin, connector or MCP server for this. You wrap the REST endpoints as tools in your own code.

No. Give it one wait tool and let your code poll every few seconds. A poll per model turn burns tokens and adds nothing the model can decide.

The credit charged when the job was accepted is refunded automatically, and the job's error_message says why it failed.

No. Every input image must be uploaded to PhotoAIVideo storage through a presigned URL; external URLs are rejected. Only use photos you have the right to animate.

Yes. The same three tools work as function tools: the schema goes under parameters, results go back as function_call_output, and strict mode needs every field required.

On photo rights, see can agents turn listing photos into AI video?

Ready to wire up your agent?

Sources