Library: documents, photos and recordings
Click a step to see it happen.
1 Upload
The SDK uploads the file, then asks the server to add it to a collection. Reading runs as a background job, and add waits for it unless you pass wait=False. Each project has a limit on disk, and an upload past it gets a 413.
In the example: lib = curva.library("policies"), then lib.add("home_policy.pdf"), a 3-page sample policy.
2 Read pages
The job reads the text layer of each page where the server runs, so it costs nothing in model fees. A page with no text layer is counted as needing OCR and is not searchable yet. A password-locked PDF is refused.
In the example: The job ended done: 3 of 3 pages read, cost_usd 0.0, ocr_pages 0.
3 Cards
A page of up to 400 words stays one card, and a longer page is cut into cards of about 300 words. Each card keeps its page number, goes into a full-text index and gets a vector from a small embedding model, downloaded once on first use.
In the example: Each page is short, so 3 pages became 3 cards.
4 Two searches
A query runs twice: once for its exact words, once for its meaning. Both take up to 200 candidates. Meaning works best in English, while exact words, names and numbers match in any language.
In the example: flood damage matched page 2 both ways. a burst pipe flooded my kitchen put page 1 first, the page about escape of water from a fixed pipe.
5 Find
The two lists merge by rank, so a card high in both comes first. Find always returns its best matches, even when nothing is relevant, and score reflects rank, so a hit does not prove the topic is in the file and find cannot prove it is absent.
In the example: flood damage returned page 2 first, score 1.0, in 3.7 ms over these 3 cards. alien invasion still returned all 3 cards.
6 Evidence
With sources, Curva searches for each question, by its wording alone and with the state, and merges up to k passages in all. Only those go to the model, fenced as data with an id each. An instruction hidden in a document can still change an answer, so screen outside documents with guard.
In the example: State: A river burst its banks and flooded the house. Questions: is it covered, and what is the excess. All 3 cards were sent.
7 Typed answer
The model answers in verbal mode, in the type you asked for, and lists the ids of the passages each answer rests on. Your code reads a typed value, so it never parses free text.
In the example: covered: 0.0 (no). excess: 250, confidence 1.0. Kimi K2.5 on Bedrock answered in 0.66 s.
8 Cited page
Curva keeps only the ids it sent, so a page number can't be made up. An answer that cites nothing comes back with abstain: true and evidence: [], so you can send it to a person.
In the example: covered cites home_policy.pdf, page 2: We do not cover flood damage from rising rivers. excess cites page 3.
Put files in a library once. Curva reads them, finds what you ask for in milliseconds at no cost, and answers typed questions from the passages it found, each answer citing its page or picture.
import curvalib = curva.library("contracts")lib.add("msa-2024.pdf") # reads every page, locally, at no costlib.find("penalty for late payment") # [{"name": "msa-2024.pdf", "page": 212, "snippet": ...}, ...]
d = curva.decide("Supplier invoice, paid 40 days late", {"interest": "Is interest charged on late payment?"}, sources="contracts")d["interest"].noul # 0.97d["interest"].evidence # [{"file": ..., "name": "msa-2024.pdf", "page": 212, "snippet": ...}]import { Curva, noul } from "curva-ai";const curva = new Curva();const lib = curva.library("contracts");await lib.add("msa-2024.pdf");await lib.find("penalty for late payment");const d = await curva.decide("Supplier invoice, paid 40 days late", { interest: noul("Is interest charged on late payment?") }, { sources: "contracts" });d.answers.interest.evidence;Each project’s files share one limit on disk (curva serve --library-mb, default 10240 MB).
An upload that would pass it gets 413 too_large, and so do uploads running at the same time
whose bytes together would pass it, so the server never holds more than the limit while they
arrive. Upload large files one at a time when they come close to it.
The library lives next to the server’s --db file: library.db and a files folder. It belongs
to the first database that opens it, so a second server whose --db sits in the same folder
(say b.db) gets its own library in b.db-library/ instead of seeing the first one’s files. A
library made before this rule stays with the first server to start after the upgrade.
Photos
Section titled “Photos”Pictures (PNG, JPEG, WebP, GIF) go in the same way. Each one is described once by a vision model into a card: a caption, the objects with their boxes, any text in it, how many people, the main colours, the scene and the quality (good, blurry, dark, overexposed). Finding then works on the cards, locally and for free.
photos = curva.library("photos")photos.add("dock-01.jpg", "dock-02.jpg", max_cost_usd=0.50)photos.find("person in a yellow jacket") # [{"name": "dock-02.jpg", "kind": "image", "bbox": [0.31, 0.2, 0.47, 0.9], ...}]photos.find("damaged parcel", verify="the parcel is damaged") # each hit gets "p", most likely first- Once per picture. Up to 8 pictures go in one vision call. A picture this project has already described (same bytes) is not sent again, in any collection.
- Your model and your cap. The server’s
--modeldescribes pictures unless you passmodel, e.g.photos.add("a.jpg", model="@gemini/gemini-3.1-flash-lite"). Before each call the job prices its pictures at what this project’s pictures have cost so far ($0.0004 each before the first), sends only as many as fit undermax_cost_usd, and endsstoppedwith the rest markedstopped;job["cost_usd"]is what it spent. A call can pass the cap only when its pictures cost more than that price, and then by the difference.lib.estimate(...)prices pictures before you add them. - A failed call is not lost. When the provider refuses a call (busy, rate limited), its
pictures are marked
failedwith the reason; add the same files again and only those are read. - Failures show on the job. When files fail (a cut-off PDF, a damaged picture, the provider
down), the job’s
errorsays how many and the first one’s reason, such as"2 of 2 files failed; the first, scan.pdf: ...". When every file failed, the job endsfailed; when some were read, it endsdonewith thaterror, andinfo()lists each file’s status. - The box of what you named. When the query names an object on a picture’s card, the hit’s
bboxis that object’s box: left, top, right and bottom as fractions of the picture. - Verify with the pixels. A card can miss a detail.
verifysends the top hits’ real pixels to the vision model with your yes-or-no question, 8 pictures to a decision through the normal decision path (calibration, cache, audit). Each hit gets a probabilitypand the list comes back most likely first. With a box question,verify={"type": "box", "instructions": "the dent"}, each hit also gets thebox. That is a paid call per 8 hits, never one per picture in the library.
Recordings
Section titled “Recordings”Hours of CCTV, dashcam or meeting video go in the same way (mp4, webm or mov). Curva does not describe every frame. It reads one frame a second at 64×64 grey, and the change gate keeps a key frame when the picture changes more than the scene’s own noise, at most one every 2 seconds and at least one a minute while nothing happens. Only those key frames are described, 8 to a vision call and 4 calls at once, each into a card like a photo’s with the time it was taken.
cctv = curva.library("cctv")cctv.add("hall-2026-10-23.mp4", max_cost_usd=0.10)cctv.find("when did a person in a red jacket enter?")# [{"name": "hall-2026-10-23.mp4", "kind": "video", "at_ms": 1392000, "end_ms": 1400000, "bbox": [...], ...}, ...]- Moments. A video hit has
at_ms, when its key frame was taken, andend_ms, when the next key frame was (or the end of the video). The event started between the previous key frame andat_ms.bboxis the box of the object the query names on that frame.filter={"kind": ["video"]}keeps only video hits. - Verify on the frame.
verifycuts the key frame atat_msout of the video with ffmpeg and sends its pixels, as for a photo.look: trueonsourcesdoes the same. - Citations with times. With
sources, a cited video passage carriesat_msandend_ms, and the model reads it ashall.mp4, at 0:23:12: .... - The price before the spend.
estimatereads the video’s length with ffprobe and gives a ceiling: one key frame every 2 seconds (pages), priced as pictures, withvideo_seconds. A quiet camera costs far less. The job then finds the exact key frames for free, and whenmax_cost_usdis set and they would cost more, it stops withstoppedbefore sending a single frame, saying how many key frames and what they would cost. - Once per recording. A video this project has already described (same bytes) is copied into a new collection at no cost.
- Progress and cancel.
job["total"]becomes the number of key frames once the free pass ends, anddonecounts them. Cancelling stops the free pass within a minute of video and keeps no card.
| Length | 24 hours a file |
| Size | 8 GiB a file, within the project’s library limit |
| Frame | 40 million pixels |
| Refused in one sentence when added | audio-only files, cut-off or unreadable files, other containers (AVI and so on) |
ffmpeg and ffprobe run as for video clips: no network, an empty environment, the container told from the first bytes. The video is streamed through ffmpeg one small grey frame at a time, so memory stays flat however long it is; no frame is written to disk. Each project runs at most 2 ffmpeg at a time across its requests and its library jobs, and one request may spend at most 90 s in ffmpeg, so one project cannot hold every decoder.
Measured on 2026-10-23 on a laptop (debug build), priced at $0.25 in and $1.50 out per million
tokens for gemini-3.1-flash-lite:
| Recording | Key frames | Free pass | Added in | Cost | Found |
|---|---|---|---|---|---|
| 1 hour, 640×360, a still hallway with 4 photos shown for 6 to 10 s each | 66 | 2.6 s | 50.5 s | $0.0278 (exact estimate before the spend: $0.0264; ceiling: $0.72) | 4 of 4 questions (“when does someone play a guitar?”) put the event’s first second first, in 1.3 to 12 ms |
| 3 hours, 1280×720 at 10 fps, a test pattern that changes every frame | 5,400 (the ceiling) | 164 s | not described | ceiling $2.16 |
Server memory stayed between 24 and 29 MB during the 3-hour pass, ffmpeg’s at 34 MB.
Typed answers with citations
Section titled “Typed answers with citations”sources turns any decision into a question about the library:
from curva import Choiced = curva.decide("War and Peace", { "captured": "Is Pierre taken prisoner by the French in this book?", "city": Choice("Which city burns in this book?", ["Moscow", "Petersburg", "Smolensk"]),}, sources={"collection": "novels", "k": 8})- For each question, Curva finds the
kbest passages (default 8, at most 50) for its wording plus the state, and merges them. - They go to the model in a fenced
<evidence>block, each with an id, as data, never as instructions. The model answers in verbal mode and lists the ids its answer rests on. - Each answer gets
evidence: those passages, with file, name, page, box and snippet. Ids the model invents are dropped; only passages that were sent can be cited, so a page number is never made up. - An answer that rests on no passage is marked
abstain: true, withevidence: []: the library did not answer it, so it is not a confident guess. Send it to a person, or ask withoutsources.
Only the found passages are sent, never the whole document, so the cost of an answer is the cost
of those few thousand tokens. Without sources, the prompt is exactly what it was, so pinned
configs and their calibration are unchanged.
look: true also sends the pictures of the top 4 picture hits with the question, for a photo
library. PDF pages have no page images yet; that comes later, so look adds nothing for a PDF.
The same field works on the compatible route, POST /v1/systemone.
What it costs and how fast
Section titled “What it costs and how fast”| Step | Speed | Cost |
|---|---|---|
| Reading a text PDF | 2.3 s for 2,131 pages on a laptop | $0 |
| Describing pictures | one vision call per 8 pictures | about $0.55 per 1,000 with gemini-3.1-flash-lite* |
find |
about 1.3 ms median over 4,614 cards | $0 |
find with verify |
one model call per 8 hits | about $0.0026 per 8 hits* |
decide with sources |
the model’s time for one call | about $0.0008 a question at k: 8 (some 3,000 input tokens)* |
* Measured on 31 drawn pictures and a 2,131-page novel, priced at $0.25 in and $1.50 out per million tokens. Batching 4 pictures in one call cost 27% less than 4 single calls.
The dashboard
Section titled “The dashboard”The Overview shows what the library holds (documents, pages, pictures), the median search time
and what reading cost over the period. It reads them from GET /v1/summary.
Limits
Section titled “Limits”- PDFs without a text layer are counted as needing OCR and are not searchable yet.
- Figures inside PDFs are not pictures yet.
- A picture card is only as good as the vision model’s description;
verifychecks the pixels when it matters. - A box
verifyasks about up to 8 pictures in one call, and a small model may repeat one picture’s box for similar pictures. Check boxes that matter, or verify fewer hits at a time. - The median search time is kept in memory, for the last 1,000 searches since the server started.
- A recording’s sound is not read yet: a card says what its key frame shows, not what is heard.
- An event shorter than a second can fall between two sampled frames. A scene that changes all the time (traffic, a crowd) costs up to the ceiling, one key frame every 2 seconds, about $0.72 an hour at the price above.
- The measurements above are on synthetic recordings; no real camera footage has been measured yet.

