Skip to content
Get started

Ask files

Use with an AI tool
tell me when a parcel is left at the door2.3 s, 3 rulesWe replaced them with one rule of our ownrules.md## Parcel leftA parcel or package is on the ground at the door.- not: a doormat- alert: 90% sureNo model call, cost 0.0parcel_leftyes or noDoes not count: a doormat{"if": {"@parcel_left": true}, "min_p": 0.9}curva.watch(frames, ask="rules.md")Qwen3-VL on Bedrockparcel_left firedyes, 0.999997, 554 ms, passed 95% on that one frame## Door opensavedreloadedfirst answer to the new rule0.21 sswitch_ms 7.32.1 sframes 1.2 s apartrules.md1## Parcel left2- colour: redLine 2Curva does not know the settingOld rules stayThe next parcel frame still fired parcel_left

Click a step to see it happen.

  1. 1 Plain words

    You can skip this and write the file yourself. If you pass plain words, the server's model writes them as an ask file once, and the SDK saves it next to your script. Later runs read that file, with no model call, so read what it wrote and edit it.

    In the example: tell me when a parcel is left at the door took 2.3 s and came back with 3 rules, more than we asked for. We replaced them with one rule of our own, Parcel left.

  2. 2 Parse

    Each ## heading starts a rule, the sentences under it say what to look for, and bullets change its settings. This is plain text work, so the same file always gives the same result, and a mistake names the line to fix.

    In the example: Heading ## Parcel left, one sentence, - not: a doormat, - alert: 90% sure. The server read it at cost 0.0.

  3. 3 Questions

    Each rule becomes one typed question, named from its heading. It is yes or no unless a bullet says otherwise, and - not: adds what does not count. The server then runs the same questions as if you had written them in JSON.

    In the example: parcel_left, yes or no: A parcel or package is on the ground at the door. This does not count: a doormat.

  4. 4 Triggers

    A yes-or-no rule alerts on yes unless told otherwise, while a choice or score rule alerts only when told, and a text rule never does. On video the default is at least 80% sure on 2 of the last 3 judged frames, or one frame at 95%.

    In the example: The rule became {"if": {"@parcel_left": true}, "min_p": 0.9}.

  5. 5 Sent as text

    The SDK reads the file and sends its text, because the server can't read your files. The server reads it once when a stream starts, never per frame, so a frame costs the same as with JSON questions.

    In the example: curva.watch(frames, ask="rules.md") sent door camera frames to Qwen3-VL on Bedrock.

  6. 6 Alert fires

    Each judged frame answers the rules, and the trigger checks the answers. By default an alert fires once and can fire again only after the rule has stopped holding.

    In the example: The first frame with a parcel answered yes, 0.999997, in 554 ms. That passed 95%, so parcel_left fired on that one frame.

  7. 7 Save while running

    While you watch, the SDK checks the file's time and size every 0.25 s. On a change it asks the server to check the file, opens a new stream under the same stream id with the new text, and closes the old one.

    In the example: We added ## Door open. The reloaded event came 0.21 s after the save, switch_ms 7.3, and the first answer to the new rule 2.1 s after it, with frames 1.2 s apart.

  8. 8 A bad edit

    If the saved file has a mistake, nothing changes on the stream. You get an error event that names the line and what to change, and the rules you had keep running.

    In the example: We saved - colour: red. The error said Line 2, Curva does not know the setting, and the next parcel frame still fired parcel_left.

Write what Curva should look for in a plain Markdown file, one heading and one sentence per rule:

## Smoke
Smoke or flames are visible anywhere in the picture.
## Someone fell
A person is lying on the floor.
import curva
for event in curva.watch("rtsp://cam", ask="rules.md"):
print(event)
import { Curva } from "curva-ai";
for await (const event of new Curva().watch("rtsp://cam", { ask: "rules.md" })) console.log(String(event));

Each rule is a yes-or-no question. On watch it alerts when the answer is yes, at least 80% sure, on 2 of the last 3 judged frames (or one frame at 95%). Save the file while the stream runs and the new rules apply from the next frames.

for event in curva.watch("rtsp://cam", ask="tell me when smoke appears or someone falls"):
print(event)

The first run sends the words to the server’s model once, which writes them as an ask file. The SDK saves it next to your script (here tell-me-when-smoke-appears-or-someone-falls.md) and says where. Later runs read that file and make no model call, so edit it like any other ask file.

A bullet under a rule changes one thing. Leave them out and the defaults above apply.

# Building site
## No hard hat
A person on the site is not wearing a hard hat.
- not: a person inside a closed vehicle cab
- alert: 3 of 5 frames, 90% sure
- webhook: https://example.com/curva
## Position
How is the person positioned?
- choice: standing, sitting, on the floor
- alert: when on the floor
## Shelf
How full is the front shelf?
- score: empty, half full, full
- alert: when empty
## Plate
The number plate of the nearest car, as written.
- text
## Speeding van
A delivery van is in the frame.
- if speed_kmh > 20
Bullet What it does
- not: ... Adds “This does not count: …” to the rule. Use it for look-alikes.
- choice: a, b, c The answer is one of these (plus none_of_these).
- score: low, medium, high The answer is a level, lowest first.
- text The answer is written out. A text rule never alerts.
- alert: when <answer> Which answer alerts. Yes-or-no rules alert on yes unless told otherwise; choice and score rules alert only when told.
- alert: 3 of 5 frames Alert when the rule holds on 3 of the last 5 judged frames (at most 30).
- alert: 90% sure Alert only at this certainty or above (50% to 100%).
- alert: every time Alert each time it holds, instead of once until it stops.
- alert: never Answer the rule on every frame, with no alert.
- webhook: https://... Post the alert there, signed with the project’s webhook secret.
- slack:, - teams:, - discord:, - telegram: Also post a readable line to that chat (see Actions).
- if speed_kmh > 20 Ask the rule only when a reading in state matches: >, >=, <, <=, =, is or contains.

The heading names the rule: ## No hard hat becomes no_hard_hat in answers and alerts. A line starting with a single # names the file. Text above the first rule is a note for people. A bullet without a colon, or any other line, stays part of the rule’s description.

Terminal window
curva ask check rules.md # each rule in plain words, then the questions and triggers it runs
curva ask check rules.md --json # only the JSON, ready for a request or a watch start message

A mistake names the line and what to change:

rules.md: Line 7: Curva does not know the setting `colour:`, so use one of not, alert, choice, score, text, webhook, slack, teams, discord, telegram or if, or write this line as a sentence without the colon if it describes the rule.

The same file works on decide, listen and watch. The SDKs read the file and send its text, because the server cannot read your files. Over HTTP, send the text itself as ask. To see what the server understood, or to turn plain words into a file, send {"text": ...} to POST /v1/ask-file. A file is read with no model call. listen takes alerts that do not count frames (- alert: 3 of 5 frames is for video).

decision = curva.decide({"ticket": "I was charged twice"}, ask="support-rules.md")

The file is read once when a stream starts, never per frame. These are the numbers we measured on an Apple M-series laptop.

Rules in the file Parse time (p50)
1 3.8 µs
10 37 µs
50 177 µs

A frame costs the same with an ask file as with the same questions written as JSON, because the server runs the same questions either way. Timed on the local tier with every question’s head switched on (300 frames each, release build, 2026-10-27):

Questions Ask file, p50 / p99 JSON, p50 / p99
1 15.0 / 45.9 ms 15.1 / 35.5 ms
5 15.0 / 19.0 ms 15.0 / 26.5 ms
20 14.8 / 25.3 ms 14.9 / 24.1 ms

The image model takes almost all of that time, so 20 questions cost no more than one.

Saving the file while a stream runs, live on Qwen3-VL (Bedrock), a 72 s driving clip at one frame a second, four edits: the Python SDK sees the change within 0.25 s and switches to the new rules in 5 ms (p50; 78 ms at most), and the first answer to a new rule arrives 1.06 s after the save (p50, 1.08 s at most), which is mostly the hosted model’s own time.

Plain words become a file in about 2 s (p50 of 10, Kimi K2.5 and Qwen3-VL on Bedrock). The first run with plain words had its first answer after 4.1 s; the next run read the saved file and had it after 1.9 s, with no model call for the file.

Ready files for different kinds of camera come with curva:

Terminal window
curva ask example # construction-site, warehouse-fire, elderly-fall, retail-staff-only, parking, traffic, driving
curva ask example warehouse-fire > rules.md

driving gives exactly the questions of the built-in driving set, so its answers are the same.