/api/debate
Runs the full 4-phase adversarial protocol (FOR/AGAINST openings, deterministic quote-hash gate, cross-examination rebuttals, blind judge verdict) and streams NDJSON events.
POST a question and source document to /api/debate. Receive structured NDJSON events with server-verified UTF-16 quote offsets, SHA-256 digests, rebuttals, and a calibrated verdict.
Works with standard HTTP streaming, our zero-dependency Python client, or browser fetch. Every quote hash can be re-checked offline.
curl -N -sS -X POST https://bedirsavasi.com/api/debate \
-H "content-type: application/json" \
-d '{
"lang": "en",
"question": "Can the tenant end the lease early without paying the penalty?",
"document": "Clause 7.2 ... Clause 12.1 ... Clause 15.3 ... (min 200 chars)"
}'
from bedir.client import debate
from bedir.verify import check
events = list(debate(
question="Can the tenant end the lease early without paying the penalty?",
document=doc_text,
lang="en",
))
verdict = next(e for e in events if e["type"] == "verdict")
print(verdict["p_for"], verdict["verdict"])
const res = await fetch("https://bedirsavasi.com/api/debate", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ lang: "en", question, document }),
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
// Parse one JSON event per newline: start -> sides -> rebuttals -> verdict -> done
{"type":"start","remaining":11,"engine":{"debater":"@cf/qwen/qwen3.8-27b","judge":"@cf/google/gemma-4-26b-a4b-it"}}
{"type":"sides","for":{"thesis":"...","claims":[{"text":"...","quote":"...","verified":true,"start":214,"end":368,"sha256":"9f3a..."}]},"against":{"thesis":"...","claims":[...]}}
{"type":"rebuttals","for":{"target":1,"text":"...","verified":true,"sha256":"4c8e..."},"against":{...}}
{"type":"verdict","p_for":75,"verdict":"...","cruxes":["..."],"flip":"..."}
{"type":"done","verified":8,"total":8,"ms":15420,"remaining":11}
Ping /api/health or fire a real streaming POST /api/debate request right from your browser and inspect every raw NDJSON frame as it arrives.
{
"lang": "en",
"question": "Can the tenant end the lease early without paying the penalty?",
"document": "COMMERCIAL LEASE EXTRACT (synthetic). Clause 7.1: Landlord keeps the roof in good repair. Clause 7.2: If a roof defect makes part of the Premises unusable and Landlord fails to repair within 30 days of written notice, Tenant may terminate without penalty. Clause 12.1: Early termination otherwise incurs 3 months' rent. Clause 15.3: Termination notice must be delivered by registered mail or by hand. File notes: 5 June written notice emailed; 2 July roof still leaks; 14 July surveyor confirms active leaks; 20 July Tenant emails termination with no registered mail on file."
}
// Click 'Ping GET /api/health' or 'Send live POST /api/debate' to inspect raw output.
All API responses use UTF-8 JSON or NDJSON with no-store cache headers and open CORS for quick prototyping.
/api/debate
Runs the full 4-phase adversarial protocol (FOR/AGAINST openings, deterministic quote-hash gate, cross-examination rebuttals, blind judge verdict) and streams NDJSON events.
/api/health
Returns edge runtime status, API version, active debater and judge model IDs, supported languages, and input limits.
/api/waitlist
Registers an email and role for API keys, design-partner pilots, or compute collaboration inquiries.
start | Emitted immediately with remaining daily quota and active debater/judge model identifiers. |
|---|---|
sides | Parallel FOR and AGAINST theses and claims, each annotated with verified (bool), UTF-16 start/end offsets and sha256. |
rebuttals | Targeted cross-examination responses attacking the opponent's weakest verified claim, independently quote-checked. |
verdict | Calibrated probability p_for (0–100), two-sentence verdict, up to 3 cruxes, and the flip condition from the blind judge. |
done | Summary telemetry: verified quote count, total quotes checked, elapsed ms, and remaining quota. |
error | Structured error code if an upstream model or rate limit interrupts the stream. |
| Question length | 8 to 300 characters (UTF-8) |
|---|---|
| Document length | 200 to 12,000 characters (40 KB max body) |
| Languages | en, tr, de (defaults to en) |
| Public demo quota | 12 debates / day per hashed IP (HTTP 429 when exceeded) |
| Error codes | 400 bad_json · 413 too_large · 422 input · 429 daily_limit |