PerciaDocs
percia.ai Open app

Docs Guides

Live (Beta)

Talk to a live agent about a camera in real time, in the app or from code (REST API and MCP). What Live is, how to start, the six API operations, limits and errors.

Live lets you talk to an agent about what a camera sees, as it happens. You ask a question in words, you get an answer, and you can keep asking. You can also add an alert, such as "Alert me when the oven light turns off", and Percia tells you when it happens.

Live (Beta) has two modes: Ask about a watch gives one answer and a picture from a watch that is already running; a Live session is a real-time conversation about a cameraLive (Beta) has two modes: Ask about a watch gives one answer and a picture from a watch that is already running; a Live session is a real-time conversation about a camera

Two ways to use Live#

Ask about a watchLive session
What it isOne question to a watch that is already runningA real-time conversation about a camera
You getOne answer and a pictureAnswers as you talk, and alerts as things happen
CameraThe watch's own cameraThis device's camera, or one of your cameras
Cost1 camera-minuteFree during the beta
ShownOnly to accounts that have a Live-capable watchIn the Live tab

When a Live session has an alert, the Make this a watch button turns it into a normal watch, which keeps running after the session ends.

Start a Live session#

  1. Open the Live tab in the app.
  2. Choose Connect, then This device's camera or one of your cameras.
  3. Optional: write an alert, for example "Alert me when the gate is open".
  4. Choose Start a live session and talk, or type.
  5. Choose Stop when you are done. A session also ends by itself (see the limits).

If the app says Live is busy, the number of sessions open at the same time across all users has reached a shared cap. Try again in a minute.

Limits#

These caps apply to every account, in the app and through the API. Live is free during the beta: billedMinutes is always 0.

LimitValue
Length of one session600 seconds (10 minutes)
Spend per sessionUSD 10. The engine currently ends a session at USD 5.00, so read endedReason and spendUsd
Spend per account per dayUSD 50
Idle time before a session ends120 seconds (2 minutes) without a question or a poll of the events
Open sessions per account5
Open sessions across all users20 (more answers live_busy, try again in a minute)

Use Live from code#

You can start and drive a Live session from the REST API or from an AI agent over MCP. A session on a camera is one conversation: start it, ask questions, read answers and alerts, stop it. The session is time-boxed (see the limits) and nothing keeps running after it ends.

What you need#

  • A key or a login. An API key with the scopes watches:write (start, ask, stop) and watches:read (read sessions and events), or the MCP login. A key with only cameras:read cannot call these operations.
  • A camera of yours that is online. These work: a paired phone or laptop, a push camera (for example one the bridge pushes), and a link camera. The camera must be sending video, or the start answers camera_offline. See Cameras for how to create one. You need the camera's id (GET /cameras).
  • Not available through the API: "This device's camera" (browser frames) and the "Ask about a watch" source stay in the app. A start on anything but a camera answers invalid_request.

Walk-through with curl#

The flow is: start, ask until you get an answer, read the events, stop.

export PERCIA_API_KEY=pk_live_...
export BASE=https://playground.percia.ai/api
AUTH="Authorization: Bearer $PERCIA_API_KEY"

# 1. Find your camera id
curl -sS "$BASE/cameras" -H "$AUTH"

# 2. Start a session. alertWhen is optional: "tell me when ..."
curl -sS -X POST "$BASE/live/sessions" -H "$AUTH" -H 'content-type: application/json' \
  -d '{"source":{"cameraId":"<cameraId>"},"alertWhen":"a person is at the front door"}'
# -> 201 {"sessionId":"ls_...","status":"open","caps":{...},"capabilities":[...],"alertClips":true,"startedAt":"..."}
export SID=ls_...   # the sessionId

# 3. Ask until you get a 200. The session needs 10 to 15 seconds to start: until then the ask
#    answers 503 live_starting or 503 live_unavailable (no frame yet). Wait 4 seconds and ask again.
for i in $(seq 1 15); do
  CODE=$(curl -sS -o ask.json -w '%{http_code}' -X POST "$BASE/live/sessions/$SID/ask" \
    -H "$AUTH" -H 'content-type: application/json' -d '{"question":"What is on the table?"}')
  [ "$CODE" = 200 ] && break
  echo "ask answered $CODE, retrying in 4 s"; sleep 4
done
cat ask.json
# -> {"answer":"...","keyframeId":"...","keyframeUrl":"https://...","costUsd":0.001}

# 4. Read what happened: answers, alerts, the end. Pass the last seq you saw as after.
curl -sS "$BASE/live/sessions/$SID/events?after=0" -H "$AUTH"
# -> {"events":[{"seq":1,"type":"live.answer","at":"...","text":"..."}, ...]}
curl -sS "$BASE/live/sessions/$SID/events?after=1" -H "$AUTH"

# 5. Stop it. Safe to repeat. Always stop a session you are done with: it frees an open-session slot.
curl -sS -X POST "$BASE/live/sessions/$SID/stop" -H "$AUTH"
# -> {"ended":true,"billedMinutes":0,"spendUsd":0.002}

The response bodies above show the field names from the API; the values are examples.

Do not wait for the session to be "running". GET /live/sessions/{id} reports status: "open" for the whole life of a session and never changes to running, so polling it tells you nothing about readiness. Call ask and retry on 503 instead. In real runs the first try answered 503 live_starting after 1 second, then 503 live_unavailable (no frame yet) at about 7 seconds, and the first 200 came 12 to 15 seconds after the start, with 3 to 4 seconds of latency per answer. An ask costs about USD 0.001, and stop returns the session's spendUsd and billedMinutes (0 during the beta).

Keep the session alive. A session with no ask and no poll of the events ends after about 120 seconds with endedReason: "idle". GET /live/sessions/{id} does not count as activity. An ask does, and so does polling GET /live/sessions/{id}/events, so a client that keeps polling the events keeps the session open until the duration or spend cap.

A small loop in JavaScript (Node 18 or later) that starts, retries the ask, reads the events and stops:

const base = "https://playground.percia.ai/api";
const h = { authorization: `Bearer ${process.env.PERCIA_API_KEY}`, "content-type": "application/json" };
const sleep = ms => new Promise(r => setTimeout(r, ms));

const start = await fetch(`${base}/live/sessions`, {
  method: "POST", headers: h,
  body: JSON.stringify({ source: { cameraId: process.env.CAMERA_ID }, alertWhen: "a person is at the door" }),
}).then(r => r.json());
const id = start.sessionId;

// Ask until it answers 200 (503 live_starting / live_unavailable while it starts)
let answer;
for (let i = 0; i < 15 && !answer; i++) {
  const r = await fetch(`${base}/live/sessions/${id}/ask`, { method: "POST", headers: h, body: JSON.stringify({ question: "What is on the table?" }) });
  if (r.status === 200) answer = await r.json();
  else if (r.status === 503) await sleep(4000);
  else throw new Error(`ask failed: ${r.status} ${await r.text()}`);
}
console.log(answer?.answer, answer?.keyframeUrl);

// Read the events (this also keeps the session open), then stop
let after = 0;
for (let i = 0; i < 10; i++) {
  const { events } = await fetch(`${base}/live/sessions/${id}/events?after=${after}`, { headers: h }).then(r => r.json());
  for (const e of events) { after = e.seq; console.log(e.type, e.text ?? ""); }
  await sleep(2000);
}
await fetch(`${base}/live/sessions/${id}/stop`, { method: "POST", headers: h });

Troubleshooting#

You seeWhat it meansWhat to do
409 camera_offline on startThe camera is not online. A phone or laptop camera must have its page open and sending. A push camera must also send a heartbeat (see below)Bring the camera online, check GET /cameras shows online, start again
503 live_starting on askThe session is still starting ("Live is still starting")Ask again in 4 to 5 seconds. Normal for the first 12 to 15 seconds
503 live_unavailable on ask, "no frame yet"The session is up but has not received a frame from the camera yetAsk again in 4 to 5 seconds. If it lasts more than a minute, check the camera is sending video
429 live_busyEvery Live slot across all users is takenWait for Retry-After (about a minute) and start again
Session ended with endedReason: "idle"120 seconds without an ask or a poll of the eventsStart a new session. Poll GET /live/sessions/{id}/events, or ask; do not rely on GET /live/sessions/{id}
409 session_ended on askThe session is overRead endedReason from GET /live/sessions/{id}, then start a new one

Push cameras need a heartbeat#

A push camera (a connector or your own software that publishes video to a camera you created with kind: "push", see Cameras) shows offline about 60 seconds after it connects, even while it keeps publishing. A start on an offline camera answers 409 camera_offline. A connector must call this roughly every 20 seconds with the camera's own token (pc_..., the token returned when the camera was created):

curl -fsS -X POST "https://playground.percia.ai/api/cam/heartbeat" \
  -H "Authorization: Bearer $PERCIA_CAMERA_TOKEN"
# -> 204 No Content (no body to send). 401 means the token is wrong.

The CLI's percia cameras push run sends it every 20 seconds for you, and paired phone and laptop cameras in the app send it automatically. If you wrote your own connector, add it (see Build your own connector).

With the SDKs#

SDK and CLI 0.5.0 and later have the six Live operations. Install them:

npm i @percia/sdk        # JavaScript and TypeScript (CLI: npm i -g @percia/cli)
pip install percia       # Python 3.9+

The operations are startLiveSession, getLiveSession, listLiveSessions, listLiveSessionEvents, askLiveSession and stopLiveSession. In JavaScript they are on percia.api and return { data, error, response } without throwing; in Python they are in percia._generated.api.live and are called through the client, which raises a typed error on a non-2xx answer.

import { createClient } from "@percia/sdk";

const percia = createClient({ apiKey: process.env.PERCIA_API_KEY });
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

const started = await percia.api.startLiveSession({
  body: { source: { cameraId: process.env.CAMERA_ID! }, alertWhen: "a person is at the door" },
});
if (!started.data) throw new Error(`start failed: ${started.response.status}`);
const id = started.data.sessionId!;

try {
  // 503 live_starting / live_unavailable while it starts: retry every 4 s
  for (let i = 0; i < 15; i++) {
    const r = await percia.api.askLiveSession({ path: { id }, body: { question: "What is on the table?" } });
    if (r.data) { console.log(r.data.answer, r.data.keyframeUrl); break; }
    if (r.response.status !== 503) throw new Error(`ask failed: ${r.response.status}`);
    await sleep(4000);
  }
} finally {
  const stopped = await percia.api.stopLiveSession({ path: { id } });
  console.log(stopped.data); // example: { ended: true, billedMinutes: 0, spendUsd: 0.002 }
}

The response values in the comments are examples. The Python call goes through the generated module, so it uses the client's private _call; client.request("POST", f"/live/sessions/{sid}/ask", json={...}) is the public escape hatch for the same route.

The six operations#

Method and pathoperationIdScopeWhat it does
POST /live/sessionsstartLiveSessionwatches:writeStart a session on one of your cameras. Body {source: {cameraId}, alertWhen?}. Answers 201 with sessionId, status, caps, capabilities, alertClips, startedAt
GET /live/sessionslistLiveSessionswatches:readYour recent sessions, newest first: {sessions: [...]}
GET /live/sessions/{id}getLiveSessionwatches:readOne session: status (open or ended; never running; not counted as activity), endedReason, secondsOpen, spendUsd, billedMinutes, caps, alerts
GET /live/sessions/{id}/eventslistLiveSessionEventswatches:readEvents after after (0 or absent = from the start): live.answer, live.item, live.alert, live.budget_warning, live.ended. Poll every 2 seconds; counts as activity
POST /live/sessions/{id}/askaskLiveSessionwatches:writeAsk a question (question, 1 to 500 characters). Answers {answer, keyframeId, keyframeUrl, costUsd}
POST /live/sessions/{id}/stopstopLiveSessionwatches:writeStop now. Answers {ended, billedMinutes, spendUsd}

Event fields: seq (pass the last one as after), type, at, text (the answer, the alert text, or why it ended), conditionId, keyframeUrl (a picture, JPEG) and clipUrl (a 4 second MP4 clip on an alert). Both links are signed, valid for ten minutes, and need no credential. A session ends with endedReason max_duration, max_spend, idle, user, start_failed or unavailable. After the end, the events answer one live.ended. A session of another account answers 404 not_found. Reads still work while Live is switched off.

Errors#

Every error has the usual body (error.code, error.message; see Errors).

StatusCodeWhen
400invalid_requestNo source.cameraId, a source other than a camera, or a question that is not 1 to 500 characters
401No key, or a key that is not valid
403insufficient_scopeThe key lacks watches:write or watches:read
404not_foundNo such session of yours
404camera_not_foundThe camera is not one of yours
409camera_offlineThe camera is not online. A push camera shows offline about 60 s after it connects unless it sends heartbeats every 20 s
409session_endedYou asked in a session that is over (endedReason says why). Start a new one
429live_limitwhich: open_sessions (5 open), daily_spend (USD 50 a day) or, on an ask, session_spend
429live_busyEvery Live slot across all users is taken. Try again in a minute (Retry-After)
503live_startingThe session is still starting ("Live is still starting"). Ask again every 4 to 5 seconds; the first answer comes after 12 to 15 s
503live_disabledLive is switched off for now: start and ask are refused. Reads and stop still work
503live_unavailableNo frame from the camera yet (ask again in 4 to 5 s), not available on your engine line, or the engine did not start

How Live differs from a watch#

A watch runs continuously, on its own, and alerts you (email, webhook, Slack, ...) when its goal is met. It is billed by the camera-minute. A Live session is an interactive, time-boxed conversation: you ask, it answers from what the camera sees now, and it can alert you while the session is open. It ends by itself after at most 10 minutes. To keep an alert running after the session, make it a watch (Make this a watch in the app, or POST /watches/owned).

Inside Live, Ask about a watch is one question to a watch that is already running (one answer and a picture, app only), and a Live session is the real-time conversation on a camera that the API starts.

Use Live from an AI agent (MCP)#

In the full MCP, https://playground.percia.ai/mcp, the agent finds the Live operations by searching the API with its search tool (try "live session") and calls them with execute. You do not need to reconnect. If an agent that was already connected does not see them, start a new chat. Live is not in the Claude directory edition (/mcp/directory) or the ChatGPT edition (/mcp/chatgpt) yet. See AI agents for setup.

A prompt that works: "Start a Live session on my front-door camera, ask what is by the door, tell me when a person arrives, and stop the session when I say so."

Privacy#

During a session, frames and clips from the camera go to Google's Gemini API to be understood. They are kept like the images of other alerts. The authoritative statement is the privacy notice. Tell the people your camera can see that they are recorded.

Status#

Live is a beta. Answers can be wrong, so do not use it for anything where a wrong answer could hurt someone.

The Live API and MCP operations are in the beta too: the caps, the fields and the error codes can change.

Stuck? Ask in the Percia Discord or email support@percia.ai. This page as Markdown: live.md.

© 2026 PerciaPerciaOpen the appStatusDiscordSupportTermsPrivacyllms.txt