Skip to content
Get started

HTTP API

Use with an AI tool

The HTTP API is versioned under /v1, and v1 is frozen: changes are additive only (new optional fields), and no field is ever removed or renamed. Breaking changes would go to /v2.

All bodies are JSON. When the server has API keys, send Authorization: Bearer curva_… on every route except /health (see Auth).

Every response carries an x-request-id header. Send your own x-request-id (1–64 visible ASCII characters) to follow a request across services; otherwise the server generates one. The same id appears in the server’s log line for the request.

Answers typed questions about a state.

Request

{
"model": "inclusionai/ling-3.0-flash-fin:free",
"mode": "auto",
"state": { "ticket": "I was charged twice for A-104, refund please" },
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this",
"options": { "billing": "Payments, refunds", "technical": "Bugs", "sales": "Pricing" }
},
"frustration": {
"type": "score",
"instructions": "How frustrated the customer is",
"levels": ["Calm", "Frustrated but civil", "Very angry"]
},
"refund_requested": { "type": "noul", "instructions": "The customer explicitly asks for a refund" }
}
}

Response (real output)

{
"id": "dec_19294a3c1f2000000",
"model": "inclusionai/ling-3.0-flash-fin:free",
"mode": "logprobs",
"latency_ms": 1144,
"cost_usd": 0.0,
"cached": false,
"answers": {
"department": { "choice": "billing", "probabilities": { "billing": 0.9999, "technical": 0.0, "sales": 0.0001 }, "confidence": 0.9999 },
"frustration": { "score": 0.65, "probabilities": [0.36, 0.62, 0.02], "levels": ["Calm", "Frustrated but civil", "Very angry"], "confidence": 0.62 },
"refund_requested": { "noul": 0.999 }
}
}
Field Required Meaning
state yes Any JSON (string, object or array). At most 150,000 bytes of JSON (about 32k tokens; a character outside the Latin alphabet takes 2 to 4 bytes)
questions yes 1–64 questions, key → question. Order is kept in the response
model no One of:
• a model id
• a list tried in order until one answers (fallback chain)
• {"council": [...]}: 2–5 models answer concurrently and are blended; answers get agreement
• {"cascade": [...], "escalate_below": 0.8}: cheapest first, and only unsure questions go to the next model; answers get answered_by
• {"race": [...]}: all asked at once; the first valid answer wins
• {"hedge": [...], "after_ms": 150}: 2–5 models. The first is asked; each after_ms (10 to 10000, default 150) without a valid answer, the next one is asked as well, at once when a model fails. The first valid answer wins, the others are cancelled, and model in the response names the model that answered; latency_ms includes the wait before that model was asked. A backup costs a call only when the model before it is slow or fails
• {"auto": [...]}: 2–5 models as a hedge that the server arranges: fastest model of the last five minutes first, the next after one and a half times its usual time
Defaults to the server’s --model
mode no auto (default: logprobs if the model returns them, else verbal), logprobs or verbal
debias no Default true: ask with the options in original and reversed order, concurrently, and average. false halves the calls. "auto": debias until a (model, question) has shown no position bias (at least 20 paired answers, 95% of them agreeing: same top label, top probability within 0.1), then ask only the original order, with the full pair on every 10th request to keep checking; one disagreement starts it over. What it learned is kept in memory per server process (at most 10,000 model-question pairs)
think no Default false. true lets the model reason briefly before answering, for hard questions: always verbal mode (mode: logprobs gets 422), 1,024 more output tokens for the reasoning, and on OpenRouter reasoning: {"effort": "low"}. Slower and costlier; part of the cache key
project no Calibration namespace (default "default"). Feedback and calibrators are kept per project
config no A pinned config: curva-1.0.0, curva-1.1.0 or curva-1.2.0 (questions before the state, so providers and local servers can cache the repeating part of the prompt). A pin freezes the prompt template and the default mode, debias and model. curva-latest (the default) is whichever pin the operator chose with --latest-config. Fields set on the request still win. Unknown names get 422
privacy no standard (default) or strict: only providers that neither store nor train on prompts are used, and extracted values are returned but never stored (the audit log shows them as redacted)
explain no true adds explain: {field: drop in probability} to each answer. Leave-one-out over at most 12 top-level fields of an object state, with one extra call per field. Not with depends_on (422)
brief no true asks the model to list only each question’s likely labels instead of a probability for every label: a shorter reply, so a faster decision. Labels it leaves out share the remaining probability. Only changes verbal answers. Part of the cache key
learn no true keeps this decision’s state on the server (at most 2,000 bytes of JSON, 180 days). Once the decision has feedback, the state and its true answer are shown to the model as an example for the same question in the same project, up to 4 per question. The response then has lessons, the number of examples shown. Not with privacy: "strict", images, assets or explain
ask no A question set built into the server, in place of questions: "check" (state {action, policy?, context?, requester?}, 422 without action; the entries of context from the party requester names are not shown to the model; without policy, Curva’s default: an action that cannot be undone or that moves money needs the user’s explicit approval; answers check: allow or block), "spoken" (state: what was just said in a voice call; answers verdict), "guard" (the guardrails recipe), "signals" (the voice-call recipe) or {"name": "next", "actions": {name: what it does}} (answers next: one of your actions, or done). An object also takes min_confidence (default 0.8). The answers take feedback like any other. It also takes the text of an ask file (a ## heading and a sentence per rule): its rules become the questions, and its alerts the triggers when the request has none
deadline_ms no 50 to 120000. Answer within this many milliseconds or fail with 504 deadline, for live uses such as a voice call where a late answer is useless. Every wait counts: fetching and preparing the assets (a download, ffprobe, scaling a picture), the model, retries and the provider rate limit. A decision that misses its deadline is neither stored nor audited; only the miss is counted (project, first model of the plan, deadline and time) as late in GET /v1/summary. Not with explain (422). See Voice
call no An id of your own, 1 to 64 characters from A-Z, a-z, 0-9 and ._:- (422 otherwise), that ties this decision to the others of one conversation, such as a phone call or a chat session. It is kept on the audit entry, and GET /v1/audit?call=<id> lists that call’s decisions. Not part of the cache key
node no The name of the place in your app that asks for this decision, such as checkout.fraud or support.triage: 1 to 64 characters from A-Z, a-z, 0-9 and ._:- (422 otherwise). It is kept on the audit entry, GET /v1/audit?node=<name> lists that node’s decisions and GET /v1/summary adds them up per node. Not returned in the response and not part of the cache key
images no Up to 8 images judged with the state, for vision models: https:// URLs (at most 2,048 characters, fetched by the model provider) or data:image/<png|jpeg|webp|gif>;base64,... URIs (at most 16 MiB decoded each; inline pictures are turned upright, stripped of EXIF and scaled to at most 1,568 px). Part of the cache key; the audit log keeps only a salted SHA-256 of each. See Images
assets no Named pictures and recordings: key → {"type": "image" | "audio", "format", one of "data_base64" | "url" | "part", "sample_rate"}. Every key must be named in state or a question (422 otherwise); each goes to the model as its own part after a key: label. Images: png, jpeg, webp, gif, at most 16 MiB; an https url goes to the provider as is. Audio: wav, mp3, pcm16 (needs sample_rate) or mulaw (8 kHz unless sample_rate), at most 10 MiB and 2 minutes; a url is fetched by Curva over https from a public address only. With audio the decision is verbal and asked once (no debias); not with explain, mode: logprobs or learn. part names a part of a multipart/form-data request whose first part, request, is this JSON. At most 8 images and assets together. See Images and recordings
sources no {"collection": "<name>", "k": 8, "look": false}: answer from a library collection. Curva finds the k (1 to 50) best passages for each question’s wording plus the state, sends them in a fenced <evidence> block with ids (e1, e2, …) and asks in verbal mode (mode: logprobs gets 422). Each answer gets evidence: the passages the model said it rests on, kept only when their ids were sent. An answer resting on none gets abstain: true. Only the found passages are sent, so the cost is that of those tokens. look: true also sends the pictures of the top 4 picture hits (PDF pages have no images yet). Without sources the prompt is exactly as before. 404 for a collection the project does not have. See Library
triggers no Actions to fire when the answers hold: name → {"if": {"@key": answer}, "min_p", "webhook", "slack", "teams", "discord", "telegram", "timeout_ms", "on_fallback"}. if holds rule conditions; min_p (default 0) is the least calibrated confidence of those answers. Each destination is one URL: webhook gets the action as JSON signed with the project’s webhook secret (a trigger with webhook on a project without one gets 422 before any model call), and the chat apps get one readable line. timeout_ms (default 5000, 1 to 30000) caps each attempt; a delivery is tried up to 3 times. The fired ones come back in actions and are sent beside the response, never holding it up. Only public https addresses, unless the server lists the host and port in CURVA_ALLOW_PRIVATE_HOOKS. See Actions
Field Types Meaning
type all choice, score, noul or multi, or the extraction types text, number, integer and box (answered in verbal mode only; mode: logprobs gets 422). A box answers where something is in the pictures (guide)
instructions all The question in plain words
options choice Key → description (may be ""), 2–255 options, plus the escape option. Over 20 options a question is answered in verbal mode, since logprobs only return the top 20; mode: logprobs then gets 422
escape choice Default true: adds a none_of_these option so the model is never forced into a wrong pick (the key is reserved)
levels score 2–20 descriptions, lowest first
min_confidence choice, score, text, number, integer 0–1. The answer gets abstain: true when its confidence is below this. Not together with target_accuracy (422)
target_accuracy choice, score, noul, text, number, integer Strictly between 0.5 and 1; 422 otherwise, on other types and together with min_confidence. A promised accuracy: answers that are not marked abstain must be right at least this share of the time. The confidence to act on is learned from this project’s feedback for this exact question, and until the labels prove one every answer has abstain: true (see Promised accuracy). It is not part of the cache key, and changing it keeps the question’s labels
coverage choice, multi, noul Strictly between 0 and 1; 422 otherwise and on other types. Once the question has 30 feedback labels, the answer gains a set that contains the true answer with probability ≥ coverage. It is not part of the cache key (guide)
options, threshold multi 1–20 options; each is scored as its own yes/no (in the same call). Options with P ≥ threshold (default 0.5) are selected
max_length text Most characters in the value: 1–2000, default 200
max_boxes box Most boxes in the answer: 1–20, default 1
min, max number, integer Inclusive bounds on the value (whole numbers for an integer)
nullable text, number, integer true: the answer may be null when the state has no such value (default false)
examples choice, score, noul, text, number, integer Up to 10 {"state": ..., "label": ...} few-shot examples (label as in feedback)
when all {"<state field>": value or [values]}: ask only when every named top-level field of an object state matches; otherwise the answer is {"skipped": true} and no model is called for it. Needs an object state (else 422) unless every field is an @key: "@<key>" reads question <key>’s answer (option key, true/false by P(yes) ≥ 0.5, level index, selected keys, or the value) and makes it a dependency (guide)
depends_on all Keys of questions to answer first, in an earlier stage of the same request; this question sees their answers. Unknown keys, self-dependencies, cycles and more than 8 stages get 422 (guide)
think all true: this question reasons in a verbal call of its own, concurrently with its stage’s normal call (default false)
rules all Up to 32 {"if": {"<state field>": condition, ...}, "answer": label}. A condition is a value (equals), a list (any of) or an operator object: contains (case-insensitive), starts_with, gt, gte, lt, lte, exists. The first rule whose conditions all hold answers the question with no model call; answer is a label as in feedback (a list of option keys for a Multi; the value for text, number and integer). Checked after when; conditions may read @key answers too. Needs an object state; unknown operators and invalid answers get 422 (guide)
Field Meaning
id dec_…: unique and sortable by time
mode The mode that actually answered (auto resolves to logprobs or verbal)
latency_ms, cost_usd Model time and model cost for this decision (both 0 when cached), over the model calls that gave the answers; calls in one stage run concurrently. latency_ms leaves out the wait for Curva’s own rate limit, earlier attempts that were retried and the backoff between them, models that failed before another one answered, the one logprobs attempt on a model that turns out to have no logprobs, and Curva’s own work
wall_ms The whole time the decision took, in ms, from when Curva started on the request until the answer was ready to send: rate-limit waits, retries, every model call, calibration and storing the decision. At least latency_ms; small for a cached decision
cached true = served from the decision cache: no model call (with stages: every call)
debiased true = asked in both option orders and averaged. false with debias: false, when debias: "auto" asked only the original order, or when one of the two orders failed
project The calibration namespace used
config The pinned config the decision ran under (e.g. curva-1.1.0)
answers.<key> See below
actions Only when a trigger fired: [{"name", "id", "because"}]. id (act_…) is the x-curva-idempotency-key of every delivery and replay; see GET /v1/deliveries

Every answer has calibrated (true once the project’s feedback has fitted a calibrator for this exact question), plus:

Type Fields
Choice choice (may be none_of_these), probabilities (per option), confidence, abstain*
Score score (expected level, 0 = lowest), probabilities (per level), levels (the question’s levels, lowest first, also when it came from ask), confidence, abstain*
Noul noul = P(yes)
Multi selected, probabilities (independent, per option)
Text, Number, Integer value (null when the state has none, or the reply had no valid value), confidence = P(value is correct), abstain*

* only when min_confidence or target_accuracy was set. Multi-model plans and explain may add agreement, answered_by and explain. With depends_on, every answer has stage (0-based). A question skipped by its when, or whose dependency was skipped, is {"skipped": true}. A question answered by one of its rules has all probability on that answer (confidence: 1.0), calibrated: false and rule: the index of the rule that matched. With sources, every answer the model gave has evidence: a list of {"file", "name", "page", "bbox", "snippet"} (page is null for a picture), empty when the answer rests on no passage, and then abstain: true.

An answer has unstable: true when its question was asked in both option orders in this request (see debias) and the two orders gave different most likely answers: the model’s answer depended on how the options were listed. That is another top option or level for a choice or score (an exact tie counts as shared), P(yes) on different sides of 0.5 for a noul or for any option of a multi, and two values that are not the same answer for a text, number or integer (text ignoring case and spacing, numbers within a relative 1e-6). If the question set min_confidence or target_accuracy, an unstable answer has abstain: true whatever its confidence. The field is absent in every other case: the orders agree, or only one order was asked (debias: false, debias: "auto" skipping the reversed order, options keyed A, B, … which are never reordered, a request of text, number and integer questions only, one of the two orders failed, or a rule answered). A cached answer keeps the flag it was computed with. A council answer is unstable when more than half of the members that answered were; a cascade answer carries the flag of the model in answered_by. probabilities and confidence are computed as before, and what is stored for calibration does not change.

A question that set coverage echoes it and adds guaranteed. With 30 or more labels for this exact question, guaranteed is true and set lists the option keys (choice, multi) or the "true"/"false" values (noul) that contain the true answer with probability ≥ coverage. With fewer labels, guaranteed is false and set is absent. A Multi reports guaranteed: false for now, because a Multi takes no feedback yet.

A question that set target_accuracy is not judged against a fixed min_confidence. Its answer has abstain decided by a threshold learned from feedback, and carries the evidence:

"promise": { "target": 0.99, "threshold": 0.93, "labels": 1000, "accuracy": 0.9986 }
  • The labelled answers are the project’s feedback for this exact question (the most recent 5,000 at most), each with the confidence it would be returned with today: calibrated by the question’s calibrator when it has one, raw otherwise.
  • threshold is the lowest confidence at which the labelled answers at or above it number at least 30 and have a one-sided 95% Wilson lower bound on their accuracy that reaches target. Answers with the same confidence are kept or left out together. accuracy is the measured accuracy of the answers at or above it, and labels is how many labelled answers were used.
  • With a threshold, abstain is confidence < threshold. Without one, threshold and accuracy are null and every answer has abstain: true: Curva does not act on its own until the labels prove the target. Answers that are all correct prove 0.9 from 30 labels, 0.95 from 52, 0.99 from 268 and 0.999 from 2,703. A target above 0.9994 can never be proven, because at most 5,000 labels are used.
  • The threshold is kept per project, question and target. It is read again as soon as the question’s calibrator is refitted, and at most 5 seconds after a new label once it rests on 30 labels or more (at once below that).
  • An answer given by one of the question’s rules has abstain: false and no promise: a rule is your own answer, not the model’s.

Text, number and integer questions go into the same verbal call as the label questions, each with its own reply schema {"value": <typed>, "confidence": number}. A value of the wrong type, out of range, too long, or null when not nullable counts as no answer (value: null, confidence: 0). With debias, they are not reordered; if the two calls disagree, the original-order value is kept at the lower confidence. A council takes the majority value (agreement = its share; confidence = the agreeing members’ mean × agreement; a tie goes to the more confident side); a cascade escalates when confidence < escalate_below; explain skips them. See Extraction.

Every error has the shape {"error": {"type": "...", "message": "..."}}. When a decision fails at the model (502, 504, or 429 from the provider) and some questions needed no model, the body also has answers with those: rule answers and skipped questions, as in a decision. Keep them and fall back only for the rest; the SDKs do this for a fallback.

Status type When
400 invalid_json The body is not JSON, or has an unknown mode or question type
401 unauthorized The server has API keys and none (or an unknown or revoked one) was sent
404 not_found Unknown decision, question or route
413 too_large The request body is over the server’s limit (curva serve --max-body-mb, default 16 MB)
422 invalid_request Too few or too many options, bad max_length/min/max, target_accuracy out of range or together with min_confidence, mode: logprobs with a text, number or integer question, more than 64 questions, state too large, more than 8 images or an invalid one; the message names the question or image
429 rate_limited The API key is over its requests per minute, the model provider is rate-limiting, or the server’s daily budget is spent. Always carries Retry-After (seconds)
502 model_error Every model in the chain failed after retries (details stay in the server log)
502 model_unavailable The model doesn’t exist, was retired or isn’t open to the server’s provider account: check the model id or your access (details stay in the server log)
504 timeout The request took longer than the 120 s deadline
504 deadline No model answered within the request’s deadline_ms

Records the true answer for one question of a past decision. From 30 labels for the same exact question in a project, a calibrator is fitted, and future answers come back with calibrated: true whenever it makes them more accurate. It is refitted as labels arrive. Sending feedback again for the same decision and question replaces the earlier label.

{ "decision_id": "dec_…", "question": "department", "label": "billing" }
{ "decision_id": "dec_…", "question": "department", "labels": 31, "min_labels": 30, "calibrated": true }
  • label: option key (Choice), level index (Score), true/false (Noul), or the true value (Text, Number, Integer; null only when nullable). A Multi takes no feedback yet (422); to label each option, ask it as its own Noul. It counts as correct when it matches the answer’s value: text ignoring case and extra whitespace, numbers within a relative 1e-6.
  • Errors: 404 for an unknown decision or question, 422 for a label that isn’t a valid answer.
  • A whole call. Send call (and project, default default) instead of decision_id to label every decision of a listened call that answered question: {"call": "call_123", "question": "verdict", "label": "block"} gives {"call", "project", "question", "decisions", "labels", "min_labels", "calibrated"}, where decisions is how many were labelled. Fallbacks are not labelled; 404 when no decision of the call answered the question.

GET /v1/calibration?question=<key>&project=<name>&model=<model>&target=<0.5..1>

Each model has its own calibration. model picks one; without it, the report covers the model that answered the question last. For the most recent wording of the question, returns:

  • model: the model this report covers
  • labels, min_labels: labels of that model’s answers
  • calibrator: {"kind": "temperature", "t": 1.8} for Choice and Score, or {"kind": "platt", "a": …, "b": …} for Noul, Text, Number and Integer
  • before: raw probabilities
  • after: held out. Each half of the labels is calibrated by a fit on the other half.

before and after each contain accuracy, ece, brier, automated and accuracy_when_automated (at 0.9), plus reliability bins.

With target (strictly between 0.5 and 1; 422 otherwise, and for a noul or multi question), the response also has promise: the threshold that a question with that target_accuracy is decided by right now.

"promise": { "target": 0.99, "threshold": 0.93, "labels": 1000, "accuracy": 0.9986, "automated": 0.71, "lower_bound": 0.9937 }

automated is the share of the labelled answers at or above the threshold (0 without one) and lower_bound the one-sided 95% Wilson lower bound of accuracy. Without a threshold, threshold, accuracy and lower_bound are null.

GET /v1/audit?project=<name>&limit=100&before=<decision id>&call=<call id>&node=<node name>

Every decision, newest first: {"project", "entries": [...], "next_before"}. Pass next_before as before for the next page (at most 1,000 per page). Each entry has id, project, api_key (the key id), state_hash (a salted SHA-256 of the state; the state itself is never stored), model, mode, config, privacy, answers (as returned), latency_ms, cost_usd, cached, created_at (unix ms) and, for decisions with images, images (a salted SHA-256 of each image as sent; the images themselves are never stored). A decision that carried a deadline also has its deadline_ms, one sent with a call id has its call, and one sent with a node name has its node. Every entry also has its wall_ms, the whole time the decision took (latency_ms is the model time only); decisions recorded before wall_ms existed have no wall_ms. A decision from /v1/listen has mode live (or fallback) and, when it fired actions, actions: [{"name", "id", "because"}], kept in the audit hash chain.

With call=<id>, only the decisions sent with that call id are returned, in the same order and with the same paging. node=<name> does the same for one node, and with both only the decisions that match both are returned.

GET /v1/summary?project=<name>&days=30

What a project used over the last days UTC days, today included (1 to 1825, default 30), added up from the audit log: {"project", "days", "totals", "by_day": [...], "by_model": [...], "by_node": [...], "projects": [...]}. totals and every row have decisions, cached, cost_usd, latency_ms (the mean model time of the decisions that were not served from the cache; null without any) and wall_ms (the mean whole time of the same decisions, counting only those that have a wall_ms; null without any, as when every decision is from before it was recorded). Rows of by_day have a UTC day (YYYY-MM-DD, only days with decisions or missed deadlines); rows of by_model have the model; rows of by_node have the node, one per node name that decisions or missed deadlines were sent with (decisions without a node are in totals, by_day and by_model only). projects lists the projects with decisions that this key may read. The dashboard’s overview is drawn from this.

totals and every row also have timed and late, for requests sent with a deadline_ms: timed counts the decisions answered within their deadline and late the requests that missed it (504 deadline). The share answered in time is timed / (timed + late). A missed deadline is not a decision: it adds to late only, under the first model of its plan and under its node when the request had one, so a day, a model or a node with nothing but missed deadlines still gets a row, with decisions: 0.

voice counts the calls listened to through /v1/listen over the same days: {"calls", "decisions", "missed", "median_ms", "actions": {"warn_user": 3, ...}}, where decisions counts utterances answered, missed those answered with the fallback, and median_ms is the median time from the end of an utterance to its answer (null without any).

With a library, the response also has library: documents and pictures read, pages indexed, searches run since the server started and their search_ms_median (time inside the engine), and reading_usd, what reading cost over the same days (pictures are paid vision calls; text is free). null on a server without a library.

Files go in once and are found in milliseconds, for free. See the Library guide.

Route What it does
POST /v1/files multipart/form-data with a part named file, streamed to disk → {"id", "sha256", "bytes", "mime", "name"}. The type comes from the bytes. The same bytes in the same project give the same id. Each project’s files share the --library-mb limit (default 10240 MB); an upload that would pass it, counting the bytes of the project’s other uploads still arriving, gets 413 too_large
DELETE /v1/files/{id} Removes the file, and its items, cards and vectors in every collection
POST /v1/collections/{name}/items {"files": [ids], "max_cost_usd"?, "model"?} → {"job"}. PDFs and text are read locally at no cost; PNG, JPEG, WebP and GIF pictures are described by a vision model (model, default the server’s --model), up to 8 pictures a call, into a card: caption, objects with boxes, text in the picture, people, colours, scene and quality. A picture this project already has a card for is not sent again. The job stops before a call would pass max_cost_usd and ends stopped
POST /v1/collections/{name}/estimate Same body → {"files", "bytes", "pages", "cost_usd"}. Pictures are priced at this project’s average so far, else $0.0004 each
GET /v1/collections/{name} The items, with status, pages and cards
DELETE /v1/collections/{name} Removes the collection with its cards and vectors (the files stay)
GET /v1/jobs/{id}, DELETE /v1/jobs/{id} {"status", "done", "total", "eta_ms", "cost_usd", "max_cost_usd", "error"}; status is queued, running, done, failed, cancelled or stopped
POST /v1/find {"collection", "query", "k"?, "filter"?: {"file", "pages", "kind"}, "verify"?, "model"?} → {"hits", "took_ms", "cost_usd"}

A hit is {"item", "file", "name", "kind", "page", "bbox", "snippet", "score", "match"}. kind is text or image; a picture has page: null and, when the query names one of its objects, that object’s bbox (left, top, right, bottom as 0 to 1 fractions). verify is a yes-or-no question about each picture hit, as text or {"type": "noul" | "box", "instructions"}: the hits go to the vision model 8 to a decision through the normal decision path (calibration, cache, audit), each gets p (and box for a box question), and they come back most likely first. With verify, k is at most 24, the response adds decisions (their ids), and cost_usd and took_ms include those decisions.

GET /v1/drift?question=<key>&project=<name>&weeks=8

One question’s answers per ISO week, oldest first: {"project", "question", "weeks": [{"week", "decisions", "mix", "confidence"}, ...]}. mix is the share of decisions per top answer and confidence the average probability of the top answer (raw). The latest week also has mix_change (total-variation distance from the earlier weeks’ average mix), confidence_change, and drift: true when the mix moved by more than 0.2 or confidence by more than 0.1. For text, number and integer questions mix is null, there is no mix_change, confidence is the average P(value is correct), and only confidence can flag drift. weeks counts the current week (default 8, at most 53). See Drift.

{"models": [{"name", "description", "release_date"}], "default_model": {"model", "previous", "changed_at"}}: curva-latest and every pinned config, and the server’s default model. previous and changed_at (Unix ms) are set once a start picked a different default model than the last one, for example after a provider retired it.

Shows what Curva understands from an ask file, or turns plain words into one. Body: {"text": "...", "model"?, "project"?}. An ask file (at most 32 KB and 64 rules) is read with no model call (cost_usd 0). Plain words (at most 2,000 characters) are sent to the model once, which writes the file; when that file does not parse, the model gets one more try with the problem shown.

{"markdown": "## Smoke\nSmoke or flames are visible anywhere in the picture.\n", "title": null,
"questions": {"smoke": {"type": "noul", "instructions": "Smoke or flames are visible anywhere in the picture."}},
"triggers": {"smoke": {"if": {"@smoke": true}, "min_p": 0.8}},
"summary": "...each rule in plain words...", "written": false, "cost_usd": 0.0}

written is true when the model wrote the file, and then decisions lists the model calls it took.

A file that does not parse gets 422 with the line and the change to make. The SDKs read a path given as ask and send its text; the server never reads your files.

A compatible alias of /v1/decide that accepts the criteria request shape used by many typed-decision clients, so they work by changing only their base URL and API key.

  • Request: {"state": ..., "model": "...", "questions": {...}}, plus any /v1/decide field (project, debias, privacy, …).
    • Choice: criteria = key → description (text, null or JSON). No escape option unless the question sets "escape": true.
    • Score: criteria = level descriptions, lowest first.
    • Noul: optional criteria: {"true": ..., "false": ...}.
    • {"type": "string"} without enum is a text question (its answers come back with type: "string"); number and integer work as is.
    • instructions may be omitted, or be JSON (sent to the model as text).
    • model: curva-x.y.z or curva-latest selects that config; a name without a provider prefix means the server default; anything else is a model id, list or plan as in /v1/decide.
  • Response: the /v1/decide response plus usage: {"input_tokens", "output_tokens"} (output is not tracked and is always 0). Every answer has type; a Score’s probabilities and legend (the level descriptions) are keyed by level: {"0": ..., "1": ...}. It carries a receipt as /v1/decide does, signed over the answers in the /v1/decide shape (see Signed receipts).

Curva listens to the caller’s side of a live call and answers after each utterance. Open a WebSocket; the first message is JSON:

{"type": "start", "key": "curva_…", "call": "call_123", "sample_rate": 16000, "encoding": "pcm16",
"ask": "scam", "deadline_ms": 1500,
"fallback": {"pressure": false, "impersonation": false, "asks_for_money_or_code": false, "synthetic_voice": false, "verdict": "warn"},
"triggers": {"warn_user": {"if": {"@verdict": "warn"}, "min_p": 0.7},
"end_call": {"if": {"@verdict": "block"}, "min_p": 0.9, "webhook": "https://app.example/hooks/end"}}}

Then send binary frames of audio (20–100 ms each, at most 256 KiB), {"type": "ask", ...} to change the questions, and {"type": "stop"} to end. On a video call, also send the caller’s camera as {"type": "frame", "data_base64": "<JPEG, PNG or WebP>"} (see Video on the call).

  • key: the API key, unless it is in the Authorization header. Never in the URL. The key’s rate is counted once per utterance and once per ask; an utterance over it gets the fallback, marked "rate_limited": true, fires no action and is not stored or audited (the receipt counts it in rate_limited), and an ask over it gets a rate_limited error. A key has at most 64 calls open at once (CURVA_LIVE_CALLS_PER_KEY); one more gets an error event of type too_large naming the limit. A dropped call keeps its place for the 30 s it can be resumed.
  • call (1–64 characters, made up when absent), project, node: as in /v1/decide.
  • encoding: pcm16 (little-endian) or mulaw; sample_rate 8000 to 48000 (16000 by default, 8000 for mulaw); channels 1 or 2 (stereo is mixed to mono).
  • ask (a built-in set: scam, hear, support, sales, booking, consent, verify, health, collections) or questions (choice, score and noul).
  • on: names of actions the client handles. A name that is not a trigger becomes one: a noul question’s key fires when it is true, question.option when that option is chosen, both at min_p 0.8. Any other name is an error that lists the names it could be.
  • deadline_ms with fallback (one answer per question, as a rule answer): when no answer comes within the limit after an utterance, the fallback is the answer.
  • triggers (at most 16): if holds rule conditions on choice, score and noul answers; min_p (0–1, default 0) is the lowest calibrated confidence of the matched answers; webhook an https URL on a public address; repeat: true fires on every utterance it holds, not once per call; on_fallback: true also fires on a fallback answer (other triggers never do). With ask: "scam" and no triggers, warn_user (verdict warn or block, 0.7) and end_call (verdict block, 0.9) are used; with the other call sets, one trigger per noul question, named after it, at 0.8. "triggers": {} turns them off.
  • model: the upstream live model, default gemini-3.1-flash-live-preview. The server needs GEMINI_API_KEY.
  • vision_model: the model that answers each utterance again with the newest camera frame on a video call; the server’s default model when absent. Ignored until a frame arrives.

Curva cuts utterances where the caller pauses (600 ms of silence) and every 4 s of unbroken speech. Events, as JSON text:

{"type": "decision", "utterance": 3, "id": "dec_…", "answers": {...}, "latency_ms": 812, "after_speech_ms": 1412, "forced": false, "receipt": {"signed": "…", "sig": "…"}}
{"type": "action", "name": "warn_user", "id": "act_…", "because": {"verdict": "warn", "p": 0.91}, "utterance": 3, "decision": "dec_…", "after_speech_ms": 1412}
{"type": "asked", "from_utterance": 4, "questions": ["complaint", "escalate", "refund", "churn_risk"]}
{"type": "resumed", "call": "call_123"}
{"type": "receipt", "call": "call_123", "utterances": 5, "decisions": [...], "actions": [...], "fallbacks": 0, "rate_limited": 0,
"median_latency_ms": 840, "median_action_ms": 1100, "sessions": 1, "notes": []}
{"type": "error", "error": {"type": "invalid_request", "message": "..."}}
  • latency_ms runs from the end of the utterance to its answer; after_speech_ms from the end of the speech (it adds the 600 ms pause unless the utterance was cut); forced marks an utterance cut while the caller kept talking; a fallback decision has "fallback": true. Every decision written to the audit log has a signed receipt, as on /v1/decide, and the end-of-call receipt lists each decision’s id with that same receipt (see Signed receipts). When the model’s answer to that utterance comes after the fallback, it is sent too, as a decision with "late": true, and its actions fire marked "late": true, except a trigger that already fired on that utterance’s fallback: it does not fire again, so one utterance gives a trigger at most one action id.
  • ask messages take ask or questions, with fallback, triggers and on, and apply from the next utterance (the asked event). A bad one gets an error and the call keeps its questions.
  • Each trigger fires once per call unless repeat. With webhook, the action (plus call, project and at) is also POSTed with x-curva-idempotency-key: <action id> and x-curva-signature: t=<unix seconds>,v1=<HMAC-SHA256 of "<t>.<action id>.<body>" with the project's webhook secret> (curva keys webhook-secret <project>), retried up to 3 times under the same id.
  • After stop comes the receipt, and the socket closes. An error in start closes the socket after the error event; later errors (one utterance) leave the call open.
  • Limits: 30 s without a message closes the call; more than about 30 s of audio waiting to be heard closes it too. A client that reads none of its events for 30 s is let go as if its connection dropped (see below). Without API keys, a page on another site cannot open the socket (403).
  • Dropped connections: when the client’s socket drops, the call waits 30 s; a new socket whose start names the same call (with the same key) resumes it, gets resumed and any event it missed; another key’s call of the same name is a different call. When the live model’s session drops, Curva opens a new one and sends the utterance again (after 0.5, 1, 2 and 4 s when sessions keep dropping before an answer, then the call ends with an error); sessions are renewed between turns after 9 minutes or when the model says it is going away. Each of these is a line in the receipt’s notes. When the model misses deadlines again and again with no answer in between, its session is replaced and the audio it had not answered is heard by the new one, so those utterances still get their late answers. When no session can be opened, the call ends with a model_unavailable error that says how many tries were made, over how long, and why the last one failed.

For a video call (support, telehealth, KYC, a scam on video), send camera frames between the audio frames, about one a second:

{"type": "frame", "data_base64": "/9j/4AAQSkZJRgABAQ…"}
  • A frame is a JPEG, PNG or WebP of at most 2 MiB. Frames are numbered from 1 in the order sent. One that is too big, not base64 or not a picture gets an error with its frame number, and the call goes on.
  • The newest frame wins: Curva reads at most 4 frames a second, and a frame that arrives while another is waiting replaces it. Frames alone decide nothing.
  • Every utterance is answered from its sound exactly as on an audio-only call; that answer never waits for a picture. When a frame came in the 10 s before the utterance ended, the vision_model answers the same questions again from what the caller said and the newest frame, within 10 s. What the caller said is the live model’s transcript of the utterance; when none came, a Gemini vision model gets the sound instead and others get the frame alone. That second decision has "seen": true:
{"type": "decision", "utterance": 2, "seen": true, "frame": 7, "frame_sha256": "9f2c…", "changed": true, "id": "dec_…", "answers": {...}, "latency_ms": 1650, "receipt": {...}}
  • frame is the frame’s number, frame_sha256 the SHA-256 of its bytes and changed whether it differed from the frames before it. The decision is audited and signed like the others; the signed state holds the frame’s hash, never its pixels.
  • Triggers fire on both decisions, and an action from the frame has "seen": true. A trigger fires at most once per utterance across the two, even with repeat.
  • The second decision counts once against the key’s rate. When the vision model is still busy with an earlier utterance, only the newest waiting one is judged next, and the receipt says which were judged by their sound alone. An error from the vision model comes as an error with "seen": true and the utterance.
  • The end receipt adds seen (decisions with a frame), median_seen_ms, and frames: {"sent", "kept", "gated", "refused", "dropped"} (kept changed the picture, gated did not, dropped were replaced by a newer frame). median_latency_ms counts sound decisions only.
  • A client that sends no frames sees no difference.

Curva watches a live video stream and acts on it. Open a WebSocket; the first message is JSON:

{"type": "start", "key": "curva_…", "stream": "cam_7", "fps": 5, "state": {"speed_kmh": 42},
"questions": {"phone_in_hand": {"type": "noul", "instructions": "The driver holds a phone"},
"moving": {"type": "noul", "instructions": "The vehicle is moving",
"rules": [{"if": {"speed_kmh": {"gt": 20}}, "answer": true}, {"if": {}, "answer": false}]}},
"deadline_ms": 2500, "fallback": {"phone_in_hand": false, "moving": false},
"triggers": {"phone": {"if": {"@phone_in_hand": true, "@moving": true}, "min_p": 0.8,
"webhook": "https://app.example/hooks/phone"}}}

Then send each frame as one binary message (JPEG, PNG or WebP, at most 2 MiB), {"type": "state", ...} to replace the readings merged into every later frame’s state, and {"type": "stop"} to end. Or give a camera URL as source and the server reads the frames itself (pull mode, below); then send only state and stop.

  • key, project, node, deadline_ms, fallback, triggers and on: as in /v1/listen. The key’s rate is counted once per hosted-model decision; a frame over it gets the fallback marked "rate_limited": true (an error without a fallback) and fires nothing, and the receipt counts it in refused and rate_limited.
  • stream (1–64 characters from A-Z a-z 0-9 . _ : -, made up when absent): decisions are logged with it as their call, so /v1/audit?call=cam_7 and /v1/feedback with call work.
  • ask (a set; driving is experimental) or questions (noul, choice, score, box, extract). With neither, the auto set: happening, attention, event and where, with an attention trigger at 0.8 (confirmed like any trigger: 2 of 3 judged frames, or one at 0.95).
  • fps (0.1 to 30, default 10): frames arriving faster, beyond a second’s worth of jitter, are dropped before decoding.
  • max_quiet_s (1–3600, default 10): a frame goes on at least this often even when nothing changes.
  • state: readings for rules and triggers (at most 16 KiB of JSON), such as a speed from the vehicle’s telemetry. Never guessed from the video.
  • model: a vision-capable model; the server’s default otherwise. A model that no configured provider serves is refused at start, with the configured providers in the message.
  • triggers also take confirm ({"k": 2, "n": 3} by default, 1 ≤ k ≤ n ≤ 30): fire when the trigger holds on k of the last n judged frames, and min_p_single (default 0.95): fire on one frame this sure. Gated frames are no new evidence, but when a trigger held on the last judged frame and needs more, the next frame is judged even if unchanged, up to k - 1 times. A fired trigger fires again only after it held on none of the last n judged frames. Both fields are refused on /v1/listen.
  • speculative (default true): act on the local model’s first frame where a trigger holds, at once, marked "confirmed": false; false waits for k of n or one frame at min_p_single, counted over the local and the hosted model’s answers. Local actions count against the key’s rate like model decisions (one over it fires nothing and gets a rate_limited error), and a key revoked during the stream ends it within a second.
  • source (pull mode): an rtsp://, rtsps://, http:// or https:// camera URL (an MJPEG camera, an HLS playlist, an RTSP camera). The server reads it with ffmpeg at fps, at most 1280 px on the long side, through the same tiers as pushed frames. Pushed frames on such a stream get an error. Only public addresses are read: the host is resolved and every address is checked at start (a private, loopback or link-local one gets a forbidden error), and again for every connection ffmpeg makes, redirects and HLS segments included, so a name that changes its address later is caught too. The server’s owner allows a private network with CURVA_WATCH_ALLOW (networks, addresses or host names, comma-separated, such as 10.0.0.0/8,192.168.1.20,cam-7.local). Any other scheme (file:, concat:, …) is refused. RTSP runs over TCP only, and a camera that answers with an RTSP redirect is not followed (the stream ends saying so). A user name, password or query in the URL never appears in events, errors, logs or the receipt: they show rtsp://cam.example.com/live?…. A camera that drops after sending frames is reopened up to 6 times (0.5 s, then doubling to 8 s); one that never sends a frame, refuses, sends no frame for 10 s (20 s for the first), sends something that is not video or is refused by the address check ends the stream with one source_error sentence and the receipt. A camera that ends its stream ends the watch the same way, without an error. 8 cameras per API key and 64 per server; each runs one ffmpeg, which stops when the stream stops or the client goes away.

Each frame goes through up to four tiers:

tier What answers When
gate the change gate: a 64×64 grey thumbnail against the last frame kept, with a threshold that follows the scene’s own noise every frame; an unchanged frame stops here and repeats the last answers
local the server’s local vision model, when it has one and a camera’s head has switched on (see Known limits) a changed frame
cache the hosted model’s answer to a near-identical frame of the same stream in the last 30 s a changed frame no head could answer
model the hosted vision model, in the background a changed frame; at most one call per stream at a time

Events, as JSON text:

{"type": "decision", "frame": 118, "at_ms": 59000, "tier": "model", "id": "dec_…", "answers": {...}, "latency_ms": 1140, "receipt": {"signed": "…", "sig": "…"}}
{"type": "decision", "frame": 119, "at_ms": 59200, "tier": "gate", "answers": {...}, "latency_ms": 1, "change": 0.4, "noise": 0.6}
{"type": "action", "name": "phone", "id": "act_…", "because": {"phone_in_hand": true, "moving": true, "p": 0.93}, "frame": 118, "at_ms": 59000, "latency_ms": 1141, "decision": "dec_…"}
{"type": "action", "name": "phone", "id": "act_…", "because": {...}, "frame": 120, "latency_ms": 4, "confirmed": false}
{"type": "confirmed", "action": "act_…", "name": "phone", "frame": 120, "by_frame": 120, "decision": "dec_…", "after_ms": 870}
{"type": "receipt", "stream": "cam_7", "frames": 7200, "gated": 6890, "sent_to_model": 302, "local": 0, "dropped": 8, "refused": 0,
"decisions": [...], "actions": [...], "checked": [...], "unconfirmed": 0, "fallbacks": 0, "rate_limited": 0,
"fired": 3, "confirmed": 2, "retracted": 1, "median_latency_ms": 1100, "median_check_ms": 910}
{"type": "error", "error": {"type": "invalid_request", "message": "..."}, "frame": 12}
{"type": "error", "error": {"type": "source_error", "message": "the camera can't be read: can't connect to cam.example.com:554: connection refused"}}
  • latency_ms runs from the frame’s arrival at the server to the event. The hosted model never holds up the next frame: while it thinks, newer frames still pass the gate and the local model, and the newest changed frame waits for the next call (an older one waiting is replaced and counted as dropped).
  • With a local model and speculative, an action goes out before its decision is signed and stored; when the hosted model has judged that frame or a later one, a confirmed or retracted event follows (retracted when the trigger does not hold on the hosted model’s answer), with after_ms from the frame’s arrival to the check. A trigger the hosted model would fire again is not fired twice. A trigger with a webhook gets the check as a second signed POST: the event plus confirmed (true or false), stream, project and at, with the idempotency key <action id>.confirmed or <action id>.retracted.
  • A decision from the hosted model, or a local one that fired an action, is signed and stored in the audit log with a salted hash of the frame; frames themselves are never stored.
  • The receipt lists the last 1,000 decisions, actions and checks; its counts cover the whole stream: fired (actions), confirmed, retracted, unconfirmed (fired, not yet checked) and median_check_ms.
  • Limits: 2 MiB and 9 million pixels a frame (DCI 4K, 4096×2160, fits; a larger frame gets an error read from its header, before decoding; a message over 4 MiB closes the socket); a start message of 64 KiB and other text messages of 32 KiB, refused before they are parsed; 30 s without a frame closes the stream (not in pull mode), and so does a client that reads none of its events for 30 s; 64 open streams per API key and 1,024 per server; 512 MiB of frames held at once across the server and 128 MiB per API key (a frame over it is dropped and counted). Decoding runs on a fixed pool of threads, one per core, and one API key uses at most half of them (at least 2); when either is full a frame is dropped and counted, never queued. When the server shuts down, each stream gets an error and its receipt.

The delivery log of fired actions, newest first, per project: every attempt to send an action to a webhook, Slack, Teams, Discord or Telegram. Query: project, status (failed or delivered; leave it out for both) and limit (1 to 500, default 100).

{"project": "default", "deliveries": [{"id": "dlv_9c2e41d07b3a5f86", "project": "default", "action": "act_5f1c...",
"kind": "slack", "to": "https://hooks.slack.com", "status": "failed", "attempts": 3,
"last_error": "the receiver answered HTTP 503", "latency_ms": 5012, "created_at": 1792519527805, "updated_at": 1792519529310}]}

to is the scheme and host only, because the path of a Slack, Discord or Telegram URL is its token; the full URL is kept encrypted with CURVA_MASTER_KEY. The newest 10,000 deliveries a project are kept, for up to 30 days. A key limited to another project gets 403.

Sends a logged delivery again: the same body, to the same destination, with the same x-curva-idempotency-key, signed again with a fresh t, and answers the delivery’s row after the attempt. 404 for an unknown id; 422 when the server has no CURVA_MASTER_KEY, since the URL could not be stored. The CLI has the same: curva webhook log [--failed] and curva webhook replay <id>.

The Ed25519 public keys that sign decision receipts, newest first, with keys rotated out kept so their receipts still verify: {"keys": [{"id", "public", "created_at"}]}. Never needs an API key. Every /v1/decide and /v1/systemone response, and every audited decision of a live call, carries receipt: {"signed", "sig"}; see Signed receipts.

{"status": "ok", "version": "0.1.0"}. Never needs an API key.

Prometheus text format: curva_decisions_total, curva_cache_hits_total, curva_answers_total, curva_abstains_total, the curva_decide_duration_seconds histogram, curva_http_responses_total{status} (502 = provider error) and, with CURVA_DAILY_LIMIT, curva_daily_quota_remaining. For /v1/watch: curva_watch_streams, curva_watch_frames_total{outcome} (in, gated, dropped, refused, sent_to_model, local), curva_watch_actions_total, the same two per open stream (curva_watch_stream_frames_total{stream,outcome}, curva_watch_stream_actions_total{stream}), the curva_watch_frame_seconds{tier} histogram from a frame’s arrival to its decision, speculative actions checked (curva_watch_checked_total{outcome} and curva_watch_stream_checked_total{stream,outcome}, outcome confirmed or retracted) and the curva_watch_check_seconds histogram from the action’s frame to its check. The numbers cover every project, so an API key limited to one project gets 403.

Once any API key exists (curva keys create --name <who> [--rpm 600] [--project <p>]), every route except /health, GET /v1/receipts/keys, the dashboard page (GET /dashboard) and GET /openapi.json (neither holds any data) needs Authorization: Bearer curva_…. Keys are stored as SHA-256 hashes and rate-limited per key (bursts up to 10 seconds’ worth). A key made with --project works only for that project: other projects get 403, and another project’s decisions look like they don’t exist (404). Without keys, the server only listens on localhost unless started with --no-auth; it then answers only under a localhost name and refuses writes from a web page on another site (403). See Self-hosting.