Skip to content
Get started

Getting started

Use with an AI tool
Terminal window
pip install curva-ai
export GEMINI_API_KEY=... # one key of any provider, e.g. OPENROUTER_API_KEY (free models work)

A .env file works too: put the key in it (GEMINI_API_KEY=..., or one key of any provider such as OPENROUTER_API_KEY, OPENAI_API_KEY or AWS_BEARER_TOKEN_BEDROCK) in the folder you run from, and skip the export. Curva then picks a model of that provider for you.

import curva
d = curva.decide("I was charged twice for order A-104, please refund me",
{"team": ["billing", "technical"], "refund": "Asks for a refund?", "order": str})
print(d.team, d.refund, d.order) # billing True A-104

There is nothing to set up. The first curva.decide starts a private server for this Python process, reuses it for every later call and stops it when Python exits. With CURVA_BASE_URL set, it talks to that server instead.

Shorthand questions. Each value in the questions dict can be:

Shorthand Question
["billing", "technical"] or {"billing": "payments", "technical": "bugs"} Choice
"Asks for a refund?" (a string ending in ?) Noul (yes/no)
bool Noul, asked with the key: "is_urgent": bool asks “Is urgent”
float, int, str Number, Integer, Text, asked with the key: "total_due": float asks “Total due”, and the answer is None when the state has no such value
Choice(...), Score(...), … or {"type": ...} used as is

Anything else raises a ValueError with an example.

Plain answers. d.team is the chosen option, d.refund is True when P(yes) ≥ 0.5, d.order is the value or None, and d.to_dict() returns all of them as a dict. d["team"] is still the full answer, with confidence and probabilities. The decision’s own fields (id, model, project, mode, error, fallback, receipt, …) come first, so for a question with such a name use d["error"].plain; the SDK warns when a question’s key hides it this way.

Feedback. curva.feedback(d.id, "team", "billing") and curva.calibration("team") use the same server. See Teach it your data.

Other providers. Without OPENROUTER_API_KEY, the first key set among OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY (or GOOGLE_API_KEY), GROQ_API_KEY, MISTRAL_API_KEY, DEEPSEEK_API_KEY, ZAI_API_KEY, DASHSCOPE_API_KEY, TOGETHER_API_KEY, FIREWORKS_API_KEY, XAI_API_KEY and AWS_BEARER_TOKEN_BEDROCK (Amazon Bedrock, region from AWS_REGION, default ap-south-1) picks a small, fast model that the provider lists for your key, such as @openai/gpt-4.1-mini, @anthropic/claude-haiku-4-5 or @bedrock/moonshotai.kimi-k2.5. Providers rename models often: check the current names, and set CURVA_MODEL to choose, e.g. CURVA_MODEL=@groq/openai/gpt-oss-20b or CURVA_MODEL=@ollama/qwen3:4b for a local model (see Model providers). With no key at all, curva.decide raises an error naming the variables to set.

When something fails. An error that points to the server log names its file (~/.curva/server.log for the private server), where the model provider’s own words are.

TypeScript. The TypeScript SDK doesn’t start a server. Run one with curva serve (from pip install curva-ai, with the same key set; it picks the model the same way) or with Docker:

Terminal window
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

Then, with the same shorthand (Number, String and Boolean stand for the types):

import { decide } from "curva-ai"; // CURVA_BASE_URL, default http://localhost:7777
const d = await decide("I was charged twice for order A-104, please refund me",
{ team: ["billing", "technical"], refund: "Asks for a refund?", order: String });
d.values; // { team: "billing", refund: true, order: "A-104" }
d.answers.team.confidence;

The rest of this page is the full API, for when you want more control.

The Python SDK and the curva server come in one package:

Terminal window
pip install curva-ai
curva --version # curva 0.3.1

Platform wheels for Linux (x86_64, aarch64), macOS (Apple Silicon, Intel) and Windows include the server binary, so you don’t need Rust. The SDK itself uses only the Python standard library (Python 3.9 or newer).

Curva needs one model key, of any provider listed above. OpenRouter gives one key for many models, and its free models are fine for trying Curva out:

Terminal window
export OPENROUTER_API_KEY=sk-or-v1-...

To use a different OpenAI-compatible endpoint, set CURVA_PROVIDER_URL (see Self-hosting).

curva.local() starts a private server for this Python process on a free localhost port, and stops it when Python exits:

import curva
from curva import Choice, Score, Noul
client = curva.local()
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
print(d["refund"].noul) # 0.999
print(d.mode, d.latency_ms, d.cost_usd, d.cached)
  • state is any JSON value: a string, an object or an array. It is treated as data, never as instructions.
  • questions maps your own keys to typed questions. All of them are answered in one request.
  • curva.local() keeps its database at ~/.curva/curva.db, so calibration learned in one run is there in the next. Pass model= to change the default model and db= to use another file.

Use it as a context manager to stop the server early:

with curva.local() as client:
...

When you learn the true answer, send it back. This is what makes the probabilities trustworthy:

client.feedback(d.id, "team", "billing")

From 30 labels for a question, Curva calibrates its answers whenever that makes them more accurate (calibrated=True); a model that is already well calibrated is left as it is. See Calibrate with feedback.

Run one server for a team or a service, and point clients at it:

Terminal window
curva serve --addr 127.0.0.1:7777 --db curva.db
from curva import Curva
client = Curva("http://your-server:7777") # or set CURVA_BASE_URL

The client reads CURVA_BASE_URL (default http://localhost:7777) and CURVA_API_KEY when they aren’t passed. Once the server has API keys, every request needs one; see Self-hosting.

Any language can call the server directly:

Terminal window
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": ""}}}
}'

The full contract is in the HTTP API reference.

The same kind of call takes other inputs, and each guide starts with a short example:

You have Call Guide
Pictures: ID cards, receipts, claim photos curva.decide(state, questions, images=["photo.jpg"]) Images and recordings
PDFs, photos and long recordings to search curva.library(name).add(...), then decide(..., sources=name) Library
A live call curva.listen(ask="scam", on={...}) Voice calls
A camera or a stream curva.watch(source) Watch live video
A short clip decide(Asset.video("clip.mp4")) Video clips
An action to run from an answer triggers on a decision Actions
An agent about to act curva.check(action), curva.guard(text) AI agents
A need for proof of what was decided verify_receipt(d.receipt, keys) Signed receipts
Answers on a phone, with no network learn=True, then curva pack Learned answers, On a phone

Before you rely on one of them, read Known limits: it says where each is weak.