# Curva documentation

> Curva turns any LLM into typed decisions with calibrated probabilities, on text, pictures, PDFs, recordings, live calls and camera video. Free to use, runs on your own servers.

Source: https://docs.tarkova.com/curva/

Text, pictures, PDFs, recordings, live calls and camera video all go through the same kind of call, and an AI agent can ask Curva before it acts.

*Curva* means "curve": the **calibration curve** is what keeps its probabilities honest. Once calibrated on your data, when Curva says 90%, it is right about 90% of the time.

Curva is a small Rust server with Python and TypeScript SDKs. It works with any OpenRouter or OpenAI-compatible model, free ones included, using your own key. It is free to use under the [Curva Free License](/curva/legal/license/), runs on your own servers, and its source code is not published.

## 30-second example

**Python**

```bash
pip install curva-ai
export GEMINI_API_KEY=...     # one key of any provider, e.g. OPENROUTER_API_KEY (free models work)
```

```python

from curva import Choice, Score, Noul

client = curva.local()      # starts a private server for this process
d = client.decide(
    state={"ticket": "I was charged twice for order A-104. Please refund the duplicate!"},
    questions={
        "team": Choice("Which team should handle this?",
                       {"billing": "payments, refunds", "technical": "bugs", "sales": "pricing"}),
        "frustration": Score("How frustrated is the customer?", ["calm", "annoyed", "angry"]),
        "refund": Noul("The customer explicitly asks for a refund"),
    },
)

print(d["team"].choice, d["team"].confidence)   # billing 0.9999
print(d["frustration"].score)                   # 0.65  (expected level, 0 = calm)
print(d["refund"].noul)                         # 0.999 (P(yes))
```

**TypeScript**

```bash
npm install curva-ai
```

```ts

const curva = new Curva();   // CURVA_BASE_URL (default http://localhost:7777), CURVA_API_KEY
const d = await curva.decide(
  { ticket: "I was charged twice for order A-104. Please refund the duplicate!" },
  {
    team: choice("Which team should handle this?", { billing: "payments, refunds", technical: "bugs", sales: "pricing" }),
    frustration: score("How frustrated is the customer?", ["calm", "annoyed", "angry"]),
    refund: noul("The customer explicitly asks for a refund"),
  },
);

d.answers.team.choice;        // "billing" | "technical" | "sales" | "none_of_these"
d.answers.team.confidence;
d.answers.frustration.score;
d.answers.refund.noul;        // P(yes)
```

The TypeScript SDK is a client for a running server. Start one with `curva serve` or with Docker. See [TypeScript](/curva/guides/typescript/).

**HTTP**

```bash
curl -s localhost:7777/v1/decide -H 'content-type: application/json' -d '{
  "state": {"ticket": "The app crashes on launch"},
  "questions": {"team": {"type": "choice", "instructions": "Which team?",
                         "options": {"billing": "", "technical": ""}}}
}'
```

Any language can call the server directly. The full contract is in the [HTTP API reference](/curva/reference/http-api/).

**Docker**

```bash
docker run --rm -p 127.0.0.1:7777:7777 -e GEMINI_API_KEY ghcr.io/itsmohitrohilla/curva \
  serve --addr 0.0.0.0:7777 --no-auth
```

This runs a local server without API keys, for trying things out. For production, create a key first: see [Self-hosting](/curva/self-hosting/).

## What it does today

Each number below was measured on the date and sample its guide gives. [Known limits](/curva/known-limits/) says where each of these is weak.

### Typed decisions

`curva.decide` answers typed questions about any data: Choice, Score, yes or no, Multi, numbers and short text. On a public test of 2,000 decisions, Kimi K2.5 was right on 72.1% with a calibration error of 0.085, at 326 ms a case. Two models in a council reached 75.9% with an error of 0.028, at 5.4 s a case. See [Questions and answers](/curva/concepts/questions/) and [Benchmarks](/curva/benchmarks/).

### Live calls

`curva.listen` hears a call as it happens and fires your actions, such as `warn_user` or `end_call`. With seven ready-made call sets on Gemini 3.1 Flash Live (preview), it took the right action on 64 of 70 calls and fired nothing on 21 of 21 neutral calls, a median 1.07 s after the speech ended. See [Voice calls](/curva/guides/voice/).

### Live video and clips

`curva.watch` reads a camera, a stream, a file or your own frames. It drops frames that did not change, sends the changed ones to a vision model and runs your actions. A frame judged by the hosted model took 811 ms at the median (n 18). Reusing answers for near-identical frames cut hosted-model calls by 8% to 16% on a lobby clip and 42% on a kitchen clip, both synthetic. On 94 short clips sent to `decide`, precision was 100%, recall 82% to 87%, and the median answer 2.8 to 3.7 s. See [Watch live video](/curva/guides/watch/) and [Video clips](/curva/guides/video/).

### PDFs and the library

`curva.library` reads PDFs, photos and long recordings, so you can search them and answer from them. A 2,131-page PDF was read in 2.3 s with no model call. On a 1,066-page novel the right page was in the top 5 for 90% of 50 scenes, with search under 4 ms at the median. Answers cite their page. Scanned pages are not read yet. See [Library](/curva/guides/library/).

### Photos

Send pictures with `images=` and ask about them. Yes or no about a photo was right on 87% (VQA v2, n 100), and 82% of boxes overlapped the true one by half or more (RefCOCO, n 125). Searching 300 photos in words in the library gave a precision at 5 of 94%, or 98% after checking the pixels, at $0.143 per 1,000 photos read. See [Images and recordings](/curva/guides/images/) and [Boxes](/curva/guides/boxes/).

### Actions

A trigger on any decision, call or camera posts to a webhook, Slack, Teams, Discord or Telegram, with retries, a delivery log and replay. Webhooks are signed. To a local receiver the POST leaves 1.4 to 2 ms after the decision at the median; real chat channels have not been tested yet. See [Actions](/curva/guides/actions/).

### Checks before an agent acts

`curva.check` judges an action before it runs, and `curva.guard` screens text before a model reads it. An approval claimed in text unlocked 0 of 40 destructive actions. Agents reach Curva through [`curva mcp`](/curva/guides/mcp/) or [tools for agent frameworks](/curva/guides/agent-frameworks/). See [AI agents](/curva/guides/agents/).

### Signed receipts

Every decision can carry an Ed25519 signature that anyone with the server's public key can check offline. Signing adds 0.015 ms a decision at the median. See [Signed receipts](/curva/guides/receipts/).

### Answers on a phone

Once Curva has [learned a question](/curva/guides/learned/) from your labels, `curva pack` writes a file that a small C library answers from with no network. On 1,552 held-out texts it gave the server's answer or abstain on 1,551, at 4.8 µs a text. Those timings are from a laptop; Android and iOS builds have not been run. See [Learned answers on a phone](/curva/guides/on-phone/).

## Start where you are

## How a decision flows

![How a Curva decision flows. Your app sends a state and typed questions. The server checks rules, then the cache, builds a prompt with the state fenced as data, asks the model with the options in both orders, reads the probabilities and calibrates them. Typed answers go back to your app, and feedback you send is stored and used to fit calibrators.](../../../assets/diagrams/decision-flow.svg)

1. **Rules** answer the cases you already know, with no model call. See [Instant decisions with rules](/curva/guides/rules/).
2. **The cache** returns identical requests in about 0 ms at $0.
3. **The prompt** wraps your state in a fenced block and tells the model it is data, not instructions.
4. **Both option orders** are asked concurrently and averaged, which cancels position bias. See [Debiasing, escape and abstain](/curva/concepts/trust/).
5. **Probabilities** are read from logprobs when the model has them, and asked for otherwise.
6. **Calibration** adjusts them once a question has 30 labels, whenever that makes them more accurate. See [Probabilities and calibration](/curva/concepts/calibration/).

## Why Curva

**Probabilities you can trust**
Send the true answer whenever you learn it. From 30 labels per question, Curva calibrates the answers when that helps, so a 0.9 means right about 90% of the time on *your* data. [Calibration →](/curva/concepts/calibration/)

**Never free text**
Every answer is a typed Choice, Score, Noul (yes/no) or Multi, mapped only onto the labels you declared and validated before it reaches you. [Questions →](/curva/concepts/questions/)

**Any model**
Any OpenRouter or OpenAI-compatible model, free or paid, with your own key. Curva reads probabilities from logprobs when the model has them, and asks for them otherwise.

**Stable and consistent**
Options are asked in both orders and averaged, which cancels position bias. An escape option means the model is never forced into a wrong pick. [Trust →](/curva/concepts/trust/)

**Fast and cheap on repeats**
Repeat decisions come from the cache in about 0 ms at $0. All questions for one state go in a single request.

**More than one model**
Blend models in a council, escalate only unsure answers in a cascade, or race models for the fastest valid answer. [Multi-model →](/curva/guides/multi-model/)

**Learns your decisions**
With `learn=True` and your labels, Curva trains a small model per question and answers by itself at $0, only once it is as accurate as your model. [Learned answers →](/curva/guides/learned/)

**Yours to run**
API keys, an audit log that never stores your data, `privacy: strict`, Prometheus metrics and a small Docker image. [Self-hosting →](/curva/self-hosting/)

## Where to next

- [Getting started](/curva/getting-started/): install, first decision, and a shared server.
- [What you can build](/curva/guides/use-cases/): 80 real problems, one snippet per kind of input.
- [Concepts](/curva/concepts/questions/): the question types and what the probabilities mean.
- [HTTP API](/curva/reference/http-api/): the full `v1` contract, for any language.
- [Benchmarks](/curva/benchmarks/): what has been measured so far, with sample sizes.
- [Known limits](/curva/known-limits/): where Curva is weak today and what to do about it.
- [Changelog](/curva/changelog/): what changed in each version, through 0.3.1.

Looking for Crowkis? Its documentation lives at [crowkis.com/docs](https://www.crowkis.com/docs).
