# How Curva works

> Why Curva exists, what it can do, and a 3D anatomy of one decision, layer by layer, with the numbers from a real run.

Source: https://docs.tarkova.com/curva/how-it-works/

Curva sits between your app and a language model. You give it some data and typed questions, and you get back typed answers with a probability on each one, so your code can act on them.

## Why Curva

A model is good at reading messy input. It's harder to build on directly, because it replies in free text and sounds equally sure when it's wrong. Curva adds what your code needs around it.

| When you call a model directly | When you call it through Curva |
|---|---|
| Free text that you parse yourself | A typed answer: an option, a level, yes or no, a number, a box on a photo |
| It sounds sure either way | A probability on each answer, and calibration against your own labels |
| The order of your options can sway the pick | Options asked in both orders and averaged |
| It has to pick something | A `none_of_these` option, and an abstain flag below the bar you set |
| Every answer costs a call | Rules, the cache and learned answers can answer with no model call |
| You have the reply and nothing else | An audit log, and signed receipts anyone can check offline |

## The anatomy of a decision

Eight layers, top to bottom, in the order a decision passes through them. Press **Follow one decision** to step through the real example below.

1. **Your app** (Python, TypeScript, HTTP, MCP): Your code calls Curva through an SDK, plain HTTP or MCP. Curva runs on your own machine or server, and it uses your own model key. In the example: A support app sends one ticket and three questions.
2. **Your data** (Text, JSON, Photo, PDF, Audio, Video): The state is whatever the decision is about: text, JSON, pictures, recordings or clips. For big PDFs, Curva finds the right passages in your library first. In the example: State: the ticket text, amount 40, plan free.
3. **Typed questions** (Choice, Score, Noul, Multi, Text, Number, Box): Each question fixes the shape of its answer, so your code never parses free text. A question can be skipped with when, or wait for another with depends_on. In the example: team is a Choice. refund and priority_support are yes or no.
4. **Rules and memory** (Rules, Learned, Cache): A rule you wrote answers without calling a model. If you switch on learned answers, a small model trained on your feedback can answer once it proves itself. A repeated question can come from the cache. In the example: The rule on plan free answers priority_support: no, with no model call.
5. **Any model** (Hosted, Local, Council, Race): The rest go to the model you chose. Curva asks with the options in both orders and averages them, so position can't sway the pick, and a Choice gets a none_of_these option so the model is never forced to guess. In the example: team: billing 0.9992. refund: yes 0.9999.
6. **Calibration** (Feedback, Calibrator, Per model): You send the true answers back as feedback. From 30 labels on a question, Curva tries a calibrator and keeps it only if it beats the raw probabilities on held-out labels, so a stated 90% moves closer to being right 90% of the time. In the example: calibrated: false. This question has no labels yet, so these are raw probabilities.
7. **Confidence check** (min_confidence, target_accuracy, abstain): You set the bar. An answer below it comes back with abstain: true, so your app can hand it to a person. A promised accuracy sets that bar from your own labels. In the example: team cleared the 0.8 bar: abstain is false.
8. **Proof and actions** (Audit chain, Signed receipt, Webhooks): The audit log records the decision with a salted hash of the state, not the state itself. A receipt that anyone can check offline can come back with the answer, and triggers can call your webhook or chat channel. In the example: Typed answers and a signed receipt returned in 690 ms, for $0.00021.

## How each part works

Each of these guides opens with the same kind of model, following one real case step by step.

| Part | See how it works |
|---|---|
| Hearing a live call | [Voice calls](/curva/guides/voice/) |
| Watching a camera or a clip | [Live video](/curva/guides/watch/), [Video clips](/curva/guides/video/) |
| Reading PDFs and photos | [Library](/curva/guides/library/), [Images](/curva/guides/images/), [Boxes](/curva/guides/boxes/) |
| Rules in plain words, and what fires next | [Ask files](/curva/guides/ask-files/), [Actions](/curva/guides/actions/) |
| Keeping an AI agent in check | [AI agents](/curva/guides/agents/), [Curva Router](/curva/guides/router/) |
| Getting better from your corrections | [Feedback](/curva/guides/feedback/), [Learned answers](/curva/guides/learned/), [On a phone](/curva/guides/on-phone/) |
| Proving what happened | [Signed receipts](/curva/guides/receipts/) |

## One real decision

This ran on 1 November 2026 on `moonshotai.kimi-k2.5` through Amazon Bedrock, from a laptop in India.

```python

from curva import Choice, Noul

d = curva.decide(
    {"ticket": "I was charged twice for order A-104. Please refund the duplicate.", "amount": 40, "plan": "free"},
    {
        "team": Choice("Which team handles this?", {"billing": "Payments and refunds", "technical": "Bugs and outages"}, min_confidence=0.8),
        "refund": Noul("Does the customer ask for a refund?"),
        "priority_support": Noul("Does this customer get priority support?").rule(False, plan="free"),
    },
)
```

| Question | Answer | Probability | Where it came from |
|---|---|---|---|
| `team` | `billing` | 0.9992 | The model, cleared the 0.8 bar |
| `refund` | Yes | 0.9999 | The model |
| `priority_support` | No | Certain | Your rule, with no model call |

The whole decision took 690 ms and cost $0.00021, and came back with a signed receipt. `calibrated` was false on every answer, because this question had no labels yet. Raw probabilities like these can be overconfident, which is why calibration exists.

## What it can do

| You have | Curva can | Read more |
|---|---|---|
| Text in any language | Route, score, pull out fields | [Questions and answers](/curva/concepts/questions/), [Any language](/curva/guides/languages/) |
| Photos | Answer questions, read fields, draw boxes | [Images](/curva/guides/images/), [Boxes](/curva/guides/boxes/) |
| Big PDFs and files | Find passages in a local library and answer with the page cited | [Library](/curva/guides/library/) |
| Live calls and recordings | Listen to the audio and act during the call | [Voice](/curva/guides/voice/) |
| Clips and live cameras | Watch for what you describe | [Video](/curva/guides/video/), [Live video](/curva/guides/watch/) |
| An AI agent | Check an action before it runs, screen input, pick a model | [Agents](/curva/guides/agents/), [Agent frameworks](/curva/guides/agent-frameworks/) |
| Things to do next | Call your webhook or chat channel when an answer fires | [Actions](/curva/guides/actions/) |
| A need for proof | Keep an audit log and sign receipts | [Receipts](/curva/guides/receipts/) |

To see these on real problems, read the [200 use cases](/curva/use-cases/), wrong answers included.

## Where it still falls short

A model can still be wrong, and instructions hidden in the input can still steer some answers. Live answers on camera video go through a hosted model and take about a second. The full list is on [Known limits](/curva/known-limits/).
