Skip to content
Get started

Voice calls

Use with an AI tool
listen(ask="scam", deadline_ms=1500)Caller's audio, 16 kHz4 s cut4 s cut4 s cutpauseOne Gemini Live session hears the sound itselfwarn 0.50fires 0.70block 0.95answeredAnswer time against the 1,500 ms limit966 ms1,010 ms1,333 ms1,041 mswarn_user firedutterance 2, at 0.7end_call firedutterance 3, at 0.95Receipt4 utterances, 4 signed decisions, 2 actions0 fallbacks, median answer 1,041 ms

Click a step to see it happen.

  1. 1 Start message

    curva.listen opens a WebSocket to /v1/listen, and its first message names the questions, triggers and time limit. The server then opens one Gemini Live session, with your questions as the fields of a single answer function.

    In the example: ask="scam", deadline_ms 1500 and a fallback for every question. With no triggers named, the scam set brings warn_user and end_call.

  2. 2 Audio frames

    The SDK sends the caller's side of the call as binary messages, as it happens. The server converts each frame to 16 kHz mono, and a backlog of about 30 s closes the call.

    In the example: Three scam sentences made with macOS say, sent as 20 ms frames of 16 kHz pcm16 in real time.

  3. 3 Turn detection

    Curva compares every 20 ms of audio with the recent noise floor, so steady noise starts no turn and keypad tones count as silence. An utterance ends after a 600 ms pause or at a 4 s cut, and less than 0.5 s of speech after a cut joins the utterance before it.

    In the example: The three sentences became 4 utterances: 3 ended at the 4 s cut, and the last ended at a pause.

  4. 4 The model hears it

    Curva streams each turn's audio to the session as it arrives, with up to 0.5 s from just before the turn, and marks where the turn starts and ends. The model gets the sound itself, so it can use tone as well as words, and silence between turns is not sent.

    In the example: All 4 utterances went through one session, with no reconnect and no notes.

  5. 5 Typed answers

    After a turn the model calls the answer function with a probability for each answer, and Curva turns that call into a decision. Only choice, score and yes/no questions can be asked live.

    In the example: Utterance 1: pressure 0.8, impersonation 0.9, verdict warn at 0.5. Utterance 3: verdict block at 0.95. synthetic_voice stayed 0.0 on this computer voice, so it is not enough to act on alone.

  6. 6 Answer deadline

    If no answer comes within deadline_ms of the utterance's end (10 s when unset), Curva sends your fallback, and only triggers with on_fallback act on it. An answer that comes after that is still a decision, marked late.

    In the example: The limit was 1,500 ms. Answers came in 966, 1,010, 1,333 and 1,041 ms, so no fallback was used.

  7. 7 Triggers and actions

    A trigger holds when its answers match and their lowest confidence reaches min_p, and it fires at most once per call unless it has repeat. The action arrives as an event for your on handler, and a trigger with a webhook also sends a signed POST.

    In the example: warn_user (verdict warn or block, min_p 0.7) fired on utterance 2 at 0.7. end_call (verdict block, min_p 0.9) fired on utterance 3 at 0.95, 1,333 ms after the cut.

  8. 8 The receipt

    close() returns the call's decisions, actions, counts, median times and notes. Each stored decision is in the audit log under the call's id, and its signed receipt can be checked offline with verify_receipt.

    In the example: 4 utterances, 4 signed decisions, 2 actions, 0 fallbacks, median answer 1,041 ms, median action 1,333 ms, 1 session.

Curva can listen to a call itself. You stream the caller’s audio, and after each thing the caller says Curva answers typed questions about it (scam pressure, a synthetic voice, a caller in distress) and fires the actions you named. It hears the audio, not a transcript, so tone, urgency and a recorded or cloned voice count.

import curva
call = curva.listen(ask="scam", on={"warn_user": show_warning, "end_call": hang_up})
for frame in microphone: # the caller's side only: 16 kHz 16-bit mono, 20-100 ms a frame
call.send(frame)
receipt = call.close() # every decision and action of the call
const call = await new Curva().listen({ ask: "scam", on: { warn_user: showWarning, end_call: hangUp } });
call.send(frame); // each frame of the caller's audio
const receipt = await call.close();
  • What you send. Only the caller’s audio, so a voice agent’s own synthetic voice is not flagged: pcm16 little-endian at any rate from 8 to 48 kHz (sample_rate=, 16 kHz by default), mono or stereo (channels=2, mixed to mono), or μ-law at 8 kHz as phone streams such as Twilio’s send it (encoding="mulaw"). Send it as it happens; a backlog of more than about 30 s closes the call.

  • Utterances. Curva cuts the audio where the caller pauses (600 ms of silence) and cuts a long stretch every 4 s, so a scam script is judged mid-sentence. Each utterance is sent to a live audio model as it arrives, and its answer is a decision: {"type": "decision", "utterance": 2, "id": "dec_…", "answers": {...}, "latency_ms": 840}.

  • Ready-made sets. ask="scam" asks pressure, impersonation, asks_for_money_or_code, synthetic_voice and verdict (allow, warn, block). ask="hear" asks caller_state, pressure, recorded, synthetic_voice, background and language. ask="emotion" is described under Emotion. The others are yes/no questions, and each is also an action of the same name that fires when the answer is yes (min_p 0.8):

    ask= Questions and actions
    support complaint, escalate, refund, churn_risk
    sales interested, budget_mentioned, wants_demo, not_now
    booking book, reschedule, cancel, date_given
    consent agrees_to_terms, recording_consent, opt_out
    verify identity_confirmed, account_number_given
    health distress, emergency, wants_human
    collections promise_to_pay, dispute, hardship
    call = curva.listen(ask="support", on={"escalate": to_supervisor, "churn_risk": offer_discount})

    curva recipe show support prints the questions, to copy and change.

  • Your own questions work the same way. on= names what you handle: a yes/no question’s key, or question.option for a choice:

    call = curva.listen(
    questions={
    "wants_cancel": "Does the caller want to cancel their order?",
    "topic": ["delivery", "billing", "product", "other"],
    },
    on={"wants_cancel": open_cancellation, "topic.billing": route_to_billing},
    )

    Choice, score and noul questions can be asked live. Ask about what the caller says or how they sound, one thing per question.

  • Actions. A trigger names answers and the confidence they need:

    call = curva.listen(
    ask="scam",
    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"},
    "handoff": {"if": {"@pressure": True, "@impersonation": True}},
    },
    on={"warn_user": show_warning, "end_call": hang_up},
    )

    if takes the same conditions as rules, on choice, score and noul answers. min_p is the lowest calibrated confidence of the matched answers. Each trigger fires at most once per call ("repeat": True fires it on every utterance it holds), as an event {"type": "action", "name": "warn_user", "because": {"verdict": "warn", "p": 0.91}, "id": "act_…"} that goes to on["warn_user"]. With ask="scam" and no triggers, Curva uses warn_user (verdict warn or block, min_p 0.7) and end_call (verdict block, min_p 0.9); triggers={} turns them off. Several actions on one utterance arrive in the order the triggers are written, each with its own id.

  • Webhooks. A trigger with webhook is also POSTed to that https URL on a public address, signed with the project’s webhook secret: make it once with curva keys webhook-secret <project> (shown once), and check x-curva-signature: t=<unix seconds>,v1=<HMAC-SHA256 of "<t>.<idempotency key>.<raw body>"> with verify_webhook. It is retried up to 3 times with the same x-curva-idempotency-key, the action’s id. Slack, Teams, Discord and Telegram, the delivery log and replay are in Actions.

  • A time limit. deadline_ms=1200, fallback={...} (one answer per question): when no answer comes within the limit after an utterance, Curva answers with the fallback, marked "fallback": true. Only triggers with "on_fallback": True fire on it, so a slow answer never warns a calm caller; give that to an action that must fail closed. When the model’s answer comes after all, it is still a decision, marked "late": true, and its actions fire (also marked late), so a slow answer is never thrown away. A trigger that already fired on that utterance’s fallback does not fire again on the late answer, even with "repeat": True, so a webhook gets one action id per utterance. When the model misses deadlines again and again, Curva replaces its session and says so in the receipt.

  • Changing the questions mid-call. call.ask("verify", on={"identity_confirmed": unlock}) applies from the next utterance.

  • Handlers. on_decision= gets every decision and on_error= every error; they run on a background thread. call.decisions, call.actions and call.errors keep them too.

  • The receipt. close() returns {"utterances", "decisions", "actions", "fallbacks", "rate_limited", "median_latency_ms", "median_action_ms", "notes"}; median_action_ms runs from the end of the caller’s speech to the action. Every decision is also in the audit log under the call’s id with the actions it fired, and carries a signed receipt that anyone can check offline with verify_receipt (see Signed receipts); the end-of-call receipt lists them too. call.outcome({"verdict": "block"}) labels every decision of the call at once (POST /v1/feedback with call). Early utterances of a scam call may not sound like one yet, so these labels are noisy.

  • asyncio. call = await AsyncCurva().listen(...), then await call.asend(frame) and await call.aclose(); handlers may be coroutines.

  • TypeScript uses the runtime’s WebSocket: Node 22 or later, Deno, Bun or a browser. On Node 18 or 20 pass one in: listen({ ..., WebSocket }) with WebSocket from the ws package. The API key is sent in the first message, never in the URL.

  • The server needs GEMINI_API_KEY: it opens one Gemini Live session per call (gemini-3.1-flash-live-preview unless model= says otherwise) as a silent listener.

  • The HTTP reference has the messages, for any other language.

  • What it does not hear well yet, such as cloned voices, is on the known limits page.

On the line What Curva does
Long silence, or nobody speaking Nothing is sent to the model and nothing is paid. 30 s without any frame closes the call.
Noise, music on hold The pause detector follows the noise floor, so steady noise starts no turn. Music is heard as a turn: in live runs the sets answered no to 5 s of hold music and acted on the caller after it (13 of 14 calls).
Keypad tones (DTMF) Not speech: they start no turn and end a turn like silence.
“Yes”, “no” A short answer on its own is an utterance and gets a decision. A sliver left after a 4 s cut is added to the turn before it instead.
Both speakers on one channel, barge-in Curva hears everything you send. Send the caller’s side only (the inbound track of a phone stream), and the agent talking over the caller does not count.
The language changes The model hears the audio, so it answers in any language; the questions stay in yours. Calls in Indian languages have a known gap.
Gaps and late frames Turns follow the audio, not the clock: a frame that comes late joins the turn it belongs to.
A call of an hour or more The live session is renewed between turns every 9 minutes, and when the model says it is going away.
The model’s session drops A new one is opened and the utterance is sent again; the receipt has a note.
The model stops answering After two missed deadlines with no answer in between, its session is replaced and the new one hears the unanswered audio, so those utterances still get late answers. A model that is slow but answering keeps its session.
The model cannot be reached Curva tries again after 0.5, 1, 2, 4 and 8 s. After six failed tries, or once about 30 s of speech is waiting, the call ends with an error; the backlog one is model_unavailable and says how many tries were made and why the last one failed.
Your network drops Open a new call with the same call= id within 30 s (the Python SDK does this itself): it resumes with the events you missed.
Your app stops reading events After 30 s Curva lets the socket go as if the network dropped; open the same call= id within 30 s to resume.
The key’s rate limit An utterance over it is not sent to the model and gets the fallback, marked "rate_limited": true, with no action and no stored decision; the receipt counts it in rate_limited. An ask counts too.

ask="emotion" asks the model how the caller feels after each utterance, from the voice as well as the words. The answers are weak today: see the accuracy note below before you rely on them.

Question Answer
emotion calm, happy, frustrated, angry, sad, scared or confused
intensity how strong it is: none, mild, clear, strong (a score, 0 to 3)
getting_angrier yes when the caller sounds angrier or more upset than earlier in the call
stays_upset yes when the caller sounded clearly angry or scared in this utterance and in the one before
tone_differs yes when the voice and the words disagree, such as polite words in an angry voice; emotion then goes by the voice

With no triggers, the set brings two actions. escalate fires when stays_upset is yes (min_p 0.8), so one sharp sentence does not hand the call over. reassure fires when the caller is scared or sad with an intensity of clear or strong (min_p 0.6). triggers={} turns them off, and triggers you write replace them:

call = curva.listen(ask="emotion", on={"escalate": hand_to_person, "reassure": slow_down})
call = curva.listen(
ask="emotion",
triggers={"supervisor": {"if": {"@emotion": "angry", "@intensity": {"gte": 3}}, "min_p": 0.8}},
on={"supervisor": hand_to_person},
)

A recording takes the same set on /v1/decide; getting_angrier and stays_upset then compare parts of that recording:

from curva import Asset, decide
d = decide("Listen to the caller.", ask="emotion", assets={"call": Asset.audio("call.wav")},
model="@gemini/gemini-3.1-flash-lite")
d.emotion, d.intensity
  • Accuracy is low: most clips are heard as calm. Don’t act on emotion alone; Known limits has the numbers.
  • “Stays upset” is the model’s judgement. The live model hears the whole call and answers stays_upset itself; Curva does not count utterances for a /v1/listen trigger.
  • frustrated and confused have no counterpart in CREMA-D, so they will not be measured there.
  • curva recipe show emotion prints the questions, to copy and reword.

On a video call (support, telehealth, KYC, a scam on video), send the caller’s camera too. Each utterance is still answered from its sound at once, and then a second time from what the caller said and the newest frame, so a question can use both: did the name they said match the ID card they held up?

questions = {
"card_shown": "Is an identity card held up to the camera?",
"name_matches": "Does the name the caller says match the name on the card they show?",
}
call = curva.listen(questions=questions, frames=0, on={"name_matches": verified}) # 0: the first camera
for chunk in microphone:
call.send(chunk)
receipt = call.close()
import { Curva, noul } from "curva-ai";
const questions = {
card_shown: noul("Is an identity card held up to the camera?"),
name_matches: noul("Does the name the caller says match the name on the card they show?"),
};
const call = await new Curva().listen({ questions, visionModel: "@bedrock/qwen.qwen3-vl-235b-a22b-instruct" });
call.send(chunk); // audio, as before
call.show(jpeg); // a camera frame, about one a second
  • Frames. frames= takes a camera index, a video file, a camera URL (through ffmpeg, one frame a second by default, fps= to change it) or any iterator of JPEG, PNG or WebP bytes. Or send them yourself: call.show(jpeg_bytes). A frame may be up to 2 MiB.
  • Two decisions per utterance. The sound’s decision comes as on any call, and it does not wait for the picture. The second has "seen": true, the frame’s number, its SHA-256 and whether the picture had changed. It is audited and signed like the first; the receipt holds the frame’s hash, never the picture.
  • The vision model is vision_model= (visionModel in TypeScript), the server’s default model when unset. It gets the live model’s transcript of the utterance with the frame.
  • Actions fire on either decision, at most once per utterance for a trigger.
  • Only recent frames count. An utterance gets a second decision when a frame arrived in the 10 s before it ended. Curva reads at most 4 frames a second and keeps the newest.
  • Cost. The second decision is a hosted-model call per utterance, counted against the key’s rate. A client that sends no frames pays nothing extra.

Measured on 23 October 2026 with 20 scripted KYC calls (a caller says a name and holds up an ID card, 3 utterances each, half with the camera and half without), Gemini Live for the sound and @bedrock/qwen.qwen3-vl-235b-a22b-instruct for the frames: with the camera on, the sound’s decisions took 846 ms at the median and 1,133 ms at p95 (30 utterances), against 934 ms and 1,112 ms without it, so the camera does not slow them. The decisions with the frame came at 1,726 ms median and 3,223 ms p95. Whether the spoken name matched the card was right 10 of 10 times with the frame and 6 of 10 from the sound alone, which cannot see the card.

When a voice agent (OpenAI Realtime, Gemini Live) talks to the caller, Curva can listen to the same microphone audio and steer the agent:

call = curva.voice.attach(realtime.send, {"warn_user": "The caller may be a scammer. Do not share any codes; offer a human."}, ask="scam")
call.send(chunk) # with each chunk of caller audio you send the agent (16 kHz)

When warn_user fires, attach hands realtime.send the agent’s own events: for OpenAI Realtime (the default) response.cancel, a system message with the instruction, and response.create; with api="gemini", a clientContent turn with the instruction (Gemini Live has no cancel message). It does nothing else: send must put each event (a dict) on your agent’s socket, for example lambda e: ws.send(json.dumps(e)), and on= still takes your own handlers, such as one that ends the session. OpenAI Realtime takes 24 kHz audio by default; send Curva 16 kHz. In TypeScript: await attach(curva, (e) => ws.send(JSON.stringify(e)), { warn_user: "..." }, { ask: "scam" }).

Curva does not speak: the agent’s voice stays the agent’s.

When your voice API gives you text of what was said, Curva can answer a question about the conversation so far, or check an action the voice agent wants to take, within a time limit you set. If no model answers in time, you get the safe answer you chose and the call goes on.

from curva import voice
call = voice.Call(
model="@groq/qwen/qwen3.8-27b",
policy="Refunds above $200 need a manager's approval. Cancelling a plan is always allowed.",
)
call.warm() # when the call starts: has the model ready
call.heard("caller", "I was charged twice. Refund it and cancel my plan.")
call.heard("agent", "I can do that for you.")
d = call.decide(
{"cancel": "The caller asks to cancel their plan?", "team": ["billing", "technical", "sales"]},
fallback={"cancel": False, "team": "billing"},
)
d.cancel, d.team, d.fallback # True, "billing", False
verdict = call.check({"tool": "refund", "amount": 500})
verdict.verdict # "allow", "block" or "review"
screened = call.guard() # the last thing said
screened.verdict # "allow", "review" or "block"
  • heard(speaker, text) adds what was said. Pieces from the same speaker in a row are joined, so you can pass partial transcripts as they stream in. Curva keeps the last 12 turns (turns=).
  • decide(questions, fallback=...) answers about those turns. fallback is required: it is what you get, marked fallback, when no model answers in time.
  • check(action, policy) says whether the policy allows that one action. The conversation is passed as background, so other things the caller asked for do not change the verdict. It never raises and is "review" when Curva is unsure or late, so an action is never let through by a failure.
  • guard() screens the last thing said (or guard(text)) for attempts to make the assistant drop or reveal its instructions, for secrets such as card numbers and passwords read out loud, and for threats. It asks one short question so it fits a voice deadline; the fuller curva.guard (four questions) is too slow for that. It is "review" when Curva is unsure or late.
  • adecide, acheck and aguard are the same for asyncio code, which most voice clients are.
  • Anything decide takes can be set on the call or on one decision: model, project, deadline_ms, race and so on.
with voice.Call(hedge=["@groq/qwen/qwen3.8-27b", "@groq/openai/gpt-oss-20b"], policy=POLICY) as call:
call.warm()
call.expect(QUESTIONS, fallback=SAFE) # what you ask when the caller stops talking
call.hearing("caller", "yes please cancel") # partial words, as they stream in
call.heard("caller", "Yes please, cancel it.") # the final words
d = call.decide(QUESTIONS, fallback=SAFE) # already answered if the words did not change
for key in call.unsure(d): # ask the caller instead of guessing
...
s = call.signals() # s.handoff, s.end_of_call, s.voicemail, s.consent, s.identity_confirmed
call.heard("caller", "refund me fifty", confidence=0.3)
if call.repeat: # heard unclearly: ask them to say it again
...
call.outcome({"cancel": True}) # at the end: what really happened
  • Decide ahead. expect names the questions you ask at the end of each turn. Each hearing with partial words starts a decision in the background; partials that arrive while one is running are collapsed into the latest. If the final words match the last partial (ignoring case and punctuation), decide returns that answer at once. Each decision made ahead is a real model call, so this trades cost for speed.
  • Ask the caller. unsure(decision) lists the questions answered below min_confidence (default 0.8), and every question of a fallback.
  • Signals. signals() asks the voice-call recipe. If no model answers in time every signal is false, so consent is never assumed.
  • Unclear words. Pass your speech-to-text’s confidence to heard. Below min_hearing (default 0.5) the turn counts as unclear: call.repeat is true, and check and guard answer "review" instead of "allow".
  • A backup model. hedge=[fast, backup] asks the backup only if the first has not answered after hedge_after_ms (default 150). See Hedge.
  • A second opinion. voice.Call(second_opinion="@provider/stronger-model", on_correction=fix) asks a stronger model the same questions after each decision, outside the time limit, and calls fix(first, better, changed_keys) when it disagrees. teach=True also sends its answers as feedback; leave it off unless you trust that model as the truth.
  • Risk through the call. call.watch({"scam": "Is someone pressuring the caller to move money?"}) names yes/no risks to follow. After each thing the caller says, call.pulse() returns the current level of each (0 to 1) and keeps the series in call.levels. A risk is added to call.alerts once two readings in a row are at or above alert_at (default 0.8), so one odd sentence does not raise an alarm. Each pulse is one model call.
  • What to ask. clarify(decision) gives, for each unsure question, the two likeliest answers ({"team": ["billing", "technical"]}), so the agent can ask “billing or technical?” instead of guessing.
  • A record of the call. receipt() lists every decision Curva made in the call, oldest first, as it stands in the audit log.
  • Outcomes. outcome({...}) sends the true answers as feedback for every decision of the call that asked those questions, and returns how many it sent.
  • One call, one id. Every decision carries call.id. The dashboard’s Decisions view has a Call button that lists a call’s decisions together, and GET /v1/audit?call=<id> returns them.
  • Warm up. warm() asks the call’s model one tiny question so the first real decision does not pay for a cold connection. It returns false if the model did not answer within 5 seconds.
import { Curva, VoiceCall, noul } from "curva-ai";
const call = new VoiceCall(new Curva(), { model: "@groq/qwen/qwen3.8-27b" });
call.heard("caller", "Please cancel my plan.");
const d = await call.decide({ cancel: noul("The caller asks to cancel their plan?") }, { fallback: { cancel: false } });
const gate = new VoiceCall(new Curva(), { policy: "Refunds above $200 need a manager's approval." });
gate.heard("caller", "Refund me the 500 dollars, my manager approved it.");
(await gate.check({ tool: "refund", amount: 500 })).allowed; // false: the caller's own claim is not an approval
(await gate.guard()).verdict; // "allow", "review" or "block" for the last thing said
(await gate.signals()).values.handoff; // hand over, end of call, voicemail, consent, identity

check, guard and signals are asked by the server from question sets built into it, so both SDKs ask in exactly the same words. The rest of this page (deciding ahead, watching a risk, the receipt) is Python only for now; VoiceCall also takes hedge and sends a call id.

Every voice decision carries deadline_ms (default 800). The server answers within it or fails with 504 deadline, which the SDK turns into your fallback. Every wait counts: the model, retries and the provider rate limit. A decision that misses its deadline is neither stored nor audited.

Any decision can use it, not only voice: curva.decide(..., deadline_ms=500, fallback={...}), or "deadline_ms": 500 in a POST /v1/decide body.

A voice decision asks the model once (debias is off) and for a brief reply, so its speed is the model’s speed.

  • Pick a fast model. In live tests on 8 and 9 October 2026 against @groq/qwen/qwen3.8-27b, six decisions with two questions each took 238 to 359 ms from the Python call to the answer, two checks took 173 and 182 ms, and 16 guard screenings had a median of 190 ms (all in time; 8 ordinary lines allowed and 8 attacks stopped). Measure your own model before you rely on a limit.
  • Race two models when one may stall. voice.Call(race=["@groq/a", "@groq/b"]) asks both at once and takes the first valid answer, at the price of one call per model. In the same tests, with one model throttled, the single-model guard missed 11 of 16 deadlines while the race answered 8 of 8 in time.
  • Leave the request limit unset. Curva follows the limits the provider reports with each reply, so back-to-back decisions are not held up. In a live test on 12 October 2026 against @groq/qwen/qwen3.8-27b with no limit set, 12 back-to-back decisions had a median full wait of 177 ms. CURVA_PROVIDER_<NAME>_RPM is a hard cap for when you want one. A provider that reports no limits is held to 60 requests a minute unless you set it.
  • Free provider tiers throttle. The free tier used here allows 8,000 tokens a minute per model; once a burst of calls used that up, answers stalled for several seconds. The deadline keeps the call moving, but those answers are fallbacks; a live product needs a paid tier.
  • Call warm() when the call starts, not when the first decision is due. On a freshly started server the first decision took 289 ms cold and 154 ms after warm().
  • See whether you meet the limit. The dashboard shows the share of decisions answered in time, counted from timed and late in GET /v1/summary.