Unfork
Docs / API API REFERENCE

API Reference

POST /v1/systemone — one forward pass returns a structured decision. No generation, no hallucination.

01

Endpoint Overview

ENDPOINT

One endpoint, one forward pass: the request carries a task primitive and text, and the service returns the argmax decision, probability distribution, and calibrated confidence — with no free-form text generated.

ItemValue
MethodPOST
Path/v1/systemone
Public endpointhttps://api.unfork.ai/v1/systemone
Content-Typeapplication/json
AuthThe public evaluation endpoint needs no auth; private deployments can add an intranet gateway or gateway key
InterfaceNative systemone interface; an OpenAI-compatible wrapper is also provided for drop-in replacement
DeterminismSame input, same output; no sampling, no stochastic decoding, fully auditable
02

Primitive Interfaces

PRIMITIVES

Switch primitives via the task field: use choice for multiple-choice, score for ordered scoring, and noul for open judgment without preset options. All three share one endpoint and the same response shape.

choice

Multiple-choice over a candidate set: returns option probabilities and the argmax decision.

score

Ordered scoring: returns numerical scores and distribution over buckets.

noul

Open judgment without preset choices: returns label confidence probabilities.

03

Request Parameters

REQUEST

The request body is a JSON object. Besides task and text, choice requires candidates; score / noul take candidates or labels as defined by the task.

FieldTypeRequiredDescription
taskstringYesTask primitive: choice / score / noul
textstringYesRaw text input to decide on, effective length ≤ 896 tokens
candidatesstring[]ConditionalCandidate array; required for choice, optional labels for score

Response Fields

The response body is a JSON object; everything is a structured number or label with no free text, ready for persistence and audit.

FieldTypeDescription
decisionstringReturns: argmax decision (a candidate or label)
probabilitiesnumber[]Returns: normalized probability distribution over candidates / buckets (100% structured)
calibrated_confidencenumberReturns: temperature-calibrated confidence (0–1); 0.85 recommended as the human-routing threshold
latency_msnumberReturns (optional): latency of this decision, for observability

All fields are deterministic outputs; route low-confidence requests to human triage.

04

Call Examples

EXAMPLES

Three common client patterns. Point ENDPOINT at the public endpoint or your private intranet address — the request and response shapes are identical.

1. CURL — Minimal Request
bashcurl -X POST https://api.unfork.ai/v1/systemone \
  -H "Content-Type: application/json" \
  -d '{
    "task": "choice",
    "text": "Refund request is 3 days overdue, but credit history is excellent. Approve automatically?",
    "candidates": ["approve", "reject", "escalate_to_human"]
  }'
2. Python (requests) — With Confidence Routing
pythonimport requests

ENDPOINT = "https://api.unfork.ai/v1/systemone"

def decide(text, candidates, threshold=0.85):
    res = requests.post(ENDPOINT, json={
        "task": "choice",
        "text": text,
        "candidates": candidates,
    }, timeout=12).json()

    decision = res["decision"]
    confidence = res["calibrated_confidence"]
    probs = res.get("probabilities", [])

    # Low confidence → escalate to human; high confidence → execute directly
    if confidence < threshold:
        return {"route": "human_review", "reason": "low_calibrated_conf",
                "confidence": confidence, "probs": probs}
    return {"route": "execute", "decision": decision, "confidence": confidence}

print(decide("Large withdrawal request from an unusual location",
             ["allow", "challenge_otp", "block_and_alert"]))
3. Node.js / TypeScript (fetch) — Batch Concurrency
javascriptconst ENDPOINT =
  "https://api.unfork.ai/v1/systemone";

async function decide(text, candidates) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ task: "choice", text, candidates }),
  });
  if (!res.ok) throw new Error(`decide failed: ${res.status}`);
  const data = await res.json();
  return { decision: data.decision, confidence: data.calibrated_confidence };
}

// Batch concurrency: each text is decided independently; results can go straight into the audit table
const texts = ["Ticket A content", "Ticket B content", "Ticket C content"];
const results = await Promise.all(
  texts.map((t) => decide(t, ["route_billing", "route_tech", "escalate"]))
);
console.log(results);

Set a 12-second timeout and a retry cap per request; if the endpoint is unavailable, degrade by business criticality (e.g. route to a human or use a cached decision).

05

Primitive Request / Response Examples

PAYLOADS
choice — Candidate Selection (request)
json{
  "task": "choice",
  "text": "Refund request is 3 days overdue, but credit history is excellent. Approve automatically?",
  "candidates": ["approve", "reject", "escalate_to_human"]
}
Response (choice)
json{
  "decision": "approve",
  "probabilities": [0.91, 0.04, 0.05],
  "calibrated_confidence": 0.91,
  "latency_ms": 31
}
score — Ordered Scoring (request)
json{
  "task": "score",
  "text": "The support agent was accurate, friendly, and resolved the issue on the first try.",
  "candidates": ["1 star", "2 stars", "3 stars", "4 stars", "5 stars"]
}
Response (score)
json{
  "decision": "5-star",
  "probabilities": [0.01, 0.01, 0.04, 0.19, 0.75],
  "calibrated_confidence": 0.93,
  "latency_ms": 28
}
noul — Open Judgment (request)
json{
  "task": "noul",
  "text": "This is an urgent!!! reminder to verify your account at http://x.co",
  "candidates": ["spam", "legit", "unknown"]
}
Response (noul)
json{
  "decision": "spam",
  "probabilities": [0.95, 0.03, 0.02],
  "calibrated_confidence": 0.95,
  "latency_ms": 26
}

score / noul share the same response shape as choice: decision returns the top bucket or label, probabilities holds the bucket probabilities, and calibrated_confidence is the calibrated score.

06

Status Codes & Errors

ERRORS

Standard HTTP status codes are used; on failure a JSON error object is returned with an error field describing the cause, making unified client handling straightforward.

StatusMeaningDescription
200SuccessReturns decision / probabilities / calibrated_confidence
400Invalid requestIllegal task value, or choice without candidates
413Text too longExceeds the 896-token effective context; split first
429Rate limitedToo many requests; retry with exponential backoff
500Server errorInternal inference error; safe to retry (idempotent)
503UnavailableEndpoint under maintenance or overloaded; consider degrading to human or a cached decision
Error Response Example
json{
  "error": "invalid_candidates",
  "message": "choice primitive requires at least 2 candidates",
  "status": 400
}

Confidence Routing Guidance

Use calibrated_confidence for single- or dual-threshold routing: execute at high confidence, escalate at low confidence to System 2 or a human, and sample-review the middle band.

Confidence rangeRecommended action
≥ 0.85Execute the decision directly; enter routine audit sampling
0.60 – 0.85Execute but flag; sample a proportion for human review
< 0.60Escalate to a System 2 reasoning model or a human; do not auto-execute

Calibrate thresholds against business risk and human cost; public benchmarks show good calibration, so 0.85 is a sensible general starting point.