API reference

API reference

Base URL: https://cci.gitdate.ink/api/v1 (or your self-hosted deployment’s URL). Every body is JSON. Keys, scopes, limits, idempotency and background jobs are described on Hosted API.

Conventions

Authorization: Bearer cci_live_...
Content-Type: application/json
Idempotency-Key: <a fresh value per logical POST>     (optional; the SDK sends one)
  • Every response carries x-request-id: req_<16 hex>, and every JSON body includes the same "request_id".
  • Every error body is {"message", "code", "field"?, "details"?, "request_id"}. field names the offending field as a dotted path, for example queries.department.calibration_profile. Codes are listed on Errors and retries.
  • Unknown fields are rejected with 422 unknown_field, so a typo never silently changes a guarantee.
  • A self-hosted service also serves every route without the /v1 prefix.

Routes

MethodPathScopeReturns
POST/v1/evaluateevaluateAnswers with guarantee cards
GET/v1/backendsanyProviders, your connections, and access levels
POST/v1/calibration-profilesprofiles:writeA profile card (201 new, 200 identical)
GET/v1/calibration-profilesany{"profiles": [...]}
GET/v1/calibration-profiles/{name}anyA profile card
PATCH/v1/calibration-profiles/{name}profiles:writeA profile card (only retention can change)
DELETE/v1/calibration-profiles/{name}profiles:write{"name", "deleted": true, "generation"}
POST/v1/calibration-profiles/{name}/examplesprofiles:writeA profile card
POST/v1/calibration-profiles/{name}/outcomesprofiles:write{"accepted", "rejected", "monitors"}
POST/v1/calibration-profiles/{name}/calibrateprofiles:write200 completed, or 202 with a job
POST/v1/calibration-profiles/{name}/label-with-judgeprofiles:write202: a labelling job
GET/v1/calibration-profiles/{name}/label-with-judge/{job_id}anyThe labelling job
POST/v1/calibration-profiles/{name}/auditprofiles:write200 an audit result, or 202 with a job
GET/v1/calibration-profiles/{name}/auditsany{"audits": [...]}
POST/v1/calibration-profiles/{name}/monitorsprofiles:write201: a monitor
GET/v1/calibration-profiles/{name}/monitorsany{"monitors": [...]}
GET/v1/calibration-profiles/{name}/monitors/{monitor_id}anyA monitor
DELETE/v1/calibration-profiles/{name}/monitors/{monitor_id}profiles:write{"id", "deleted": true}
GET/v1/calibration-profiles/{name}/monitors/{monitor_id}/alertsany{"alerts": [...]} since the last poll
GET/v1/calibration-profiles/{name}/monitors/{monitor_id}/pointsany{"points": [...]}
GET/v1/calibration-profiles/{name}/eventstelemetry:readThe profile’s history (Events API)
GET/v1/jobsany{"jobs": [...]}
GET/v1/jobs/{job_id}anyA job
POST/v1/jobs/{job_id}/cancelprofiles:writeThe job
GET/v1/requeststelemetry:readRequest records (Events API)
GET/v1/requests/{request_id}telemetry:readOne request’s trace
GET/v1/usagetelemetry:readGrouped usage
GET/v1/eventstelemetry:readGuard events
POST/v1/eventsevents:write202 {"accepted", "rejected"} (guard events)
POST/v1/tracesevents:writeOTLP/HTTP ingest (OTLP)
GET/v1/healthznone{"status": "ok"}
GET/v1/readyznone200, or 503 when a store is unavailable

“any” means any key whose scopes include profiles:read: keys with evaluate, profiles:write or telemetry:read.

Evaluate

POST /v1/evaluate
FieldTypeRequiredDescription
contextstring | object | arrayYesThe content every query is evaluated against.
backendobjectSee noteThe model backend. Required unless every query declares its own cascade (every route query, and a judge query with cascade).
queriesmap<string, Query>Yes1 to 16 named queries. Ids use letters, digits, _, - or . (at most 64).

Each query names its own calibration profile, and each profile calibrates exactly one query definition, so two different queries in one request name two profiles.

Example

curl https://cci.gitdate.ink/api/v1/evaluate \
  -H "Authorization: Bearer $CLI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "context": {"ticket": "My payouts have been failing for 3 days.", "proposed_queue": "billing"},
    "backend": {"provider": "openai", "model": "gpt-4.1-2025-04-14"},
    "queries": {
      "department": {
        "type": "set",
        "instructions": "Which team should handle this ticket?",
        "options": {
          "billing": "Payments, invoicing, refunds",
          "technical": "Bugs, outages, integrations",
          "sales": "Pricing, upgrades, new accounts"
        },
        "calibration_profile": "support-routing-v3",
        "alpha": 0.1,
        "method": "APS"
      },
      "route": {
        "type": "gate",
        "instructions": "Is proposed_queue the correct team for this ticket?",
        "calibration_profile": "support-auto-route-v3",
        "guarantee": "fdr",
        "target": 0.05,
        "delta": 0.05
      }
    }
  }'

The SDK emits exactly this body: each query object is what Query.to_payload() returns, with type first and every field left as None omitted.

StatusWhen
200Every answer carries a guarantee
424At least one answer is heuristic; the body still holds every answer, and warnings says why (calibrating, stale, too few examples)
422profile_not_found (the profile was never created), query_mismatch (the profile is bound to a different query), connection_required, unknown_field, unknown_query_type, unknown_provider, unsupported_option, or another invalid field
402, 429, 502, 529The provider failed, was rate-limited or overloaded, or the access level is unavailable (Errors)

Query objects

Every query has a type. The remaining fields are the primitive’s constructor arguments, at the top level of the query object.

typeRequired fieldsOptional fields
beliefinstructions, calibration_profilecriteria (an object)
setinstructions, options (2 to 256), calibration_profilealpha, method (LAC, APS, RAPS), group_by, backend_access_hint
intervalinstructions, levels (distinct strings), calibration_profilealpha, method (CQR, ordinal-aps)
gateinstructions, calibration_profile, targetguarantee (risk, the default, risk_high_probability, fdr), delta, loss (zero_one only)
claiminstructions (a string), calibration_profilealpha, support_source
judgeinstructions (a string), calibration_profilealpha, cascade
routecascade, calibration_profile, taskguarantee (cost_budget, the default, or accuracy), target_cents (required for cost_budget), alpha

instructions may be a string, object, or array (claim and judge take a string). A cascade is an array of 1 to 6 stages, cheapest first, each {"backend": <backend object>, "cost_cents": <number>}; {"backend": "human_queue"} may be the last stage. A route query’s task is a set query: the decision every stage makes. With guarantee: "cost_budget", the stages need cost_cents, and the cost of a trailing human_queue stage counts toward the budget.

What a profile binds, and what may change between requests on the same profile:

Part of the queryOn a bound profile
type, instructions, options, levels, criteria, support_source, taskMust stay the same, or 422 query_mismatch
alpha, target, delta, method, guarantee, target_centsMay change per request: thresholds are recomputed from the stored scores
The backend (and each cascade stage)Compared with the calibrated fingerprint (backend changes)

Backend objects

FieldDescription
provideropenai, azure-openai, anthropic, gemini, vertex, bedrock, openrouter, vllm, sglang, openai-compatible, mistral, groq, together, fireworks, deepseek, xai, cerebras, or client_evidence
modelModel identifier (an imported model’s ARN for Bedrock Custom Model Import)
access_hintauto (default), sampling, logprobs, prompt-scoring, exact, hidden-state
connectionThe name of a provider connection; the provider’s default when omitted
ProviderExtra fields
openaireasoning_effort (none, minimal, low, medium, high, xhigh, max)
azure-openaideployment, api_version, reasoning_effort
anthropiceffort (low, medium, high, xhigh, max), sample_count
gemini, vertexthinking_level (minimal, low, medium, high), sample_count
bedrockregion, custom_model_import, sample_count
openrouterpin_upstream (default true), upstream, quantization, reasoning_effort
vllmbase_url, engine_version, quantization, logprobs_mode (raw_logprobs, processed_logprobs)
sglangbase_url, engine_version, deterministic
openai-compatiblebase_url, use_logprobs, reasoning_effort
mistral, groq, together, fireworks, deepseek, xai, cerebrasreasoning_effort, sample_count
client_evidencename, access_level (L0 to L4), fingerprint, evidence_version, sample_count

sample_count is 1 to 32 (8 by default) and applies at L0. For vllm, sglang and openai-compatible, the endpoint comes from the connection; a base_url you send must have the same origin. Access levels per provider are on Backends.

When your own model computes the evidence (the SDK’s CustomBackend), the backend object is {"provider": "client_evidence", "name": "...", "access_level": "L1"} and every query carries an evidence field:

{
  "type": "set",
  "instructions": "Which team should handle this ticket?",
  "options": {"billing": "Payments, invoicing, refunds", "technical": "Bugs, outages, integrations"},
  "calibration_profile": "support-routing-v3",
  "evidence": {"option_probabilities": {"billing": 0.81, "technical": 0.19}}
}
Evidence keySent when
option_probabilitiesset, belief, gate, judge at L1 and above (keys: the options; true/false; response_a/response_b)
level_probabilitiesinterval at L1 and above (keys: level indices as strings, or level names)
samplesThe same queries at L0: 1 to 256 sampled replies
claimsclaim: a list of {"text", "score"} with scores in [0, 1]. The SDK’s default collect_evidence sends samples for claims, so override it for Claim

route queries cannot use client evidence (their stages are hosted backends), nor can a judge with a cascade. Hidden-state vectors sent by a CustomBackend are validated but not used to build scores.

Answers

Answer typeFields
beliefprobability, venn_abers ([p0, p1]), raw_score
setset, probabilities, venn_abers (per option)
intervalpoint_estimate, interval (level indices), levels (the names at both ends), legend
gatedecision (auto_approve or escalate), confidence, threshold, venn_abers
claimretained_claims, dropped_claims (objects with text, reason, score), threshold
judgewinner, escalated_to, decided_by
routeoutput (an option of the task), served_by (backend, tier, provider, model), escalated, cost_cents, threshold, tiers (each stage tried, with its confidence, output and cost)

Every answer has a guarantee card, specified on Guarantee reference. A heuristic answer takes its safe form: a Set returns every option, a Gate escalates, a Belief returns [0, 1], an Interval every level, a Claim retains nothing, and a Judge or Route goes to the human queue.

Response fieldDescription
answersMap from query id to answer.
backendprovider, model, access_level, and connection when one was used; stages for cascades.
usagebackend_calls, backend_tokens, input_tokens, output_tokens, reasoning_tokens, calibration_calls (calls spent calibrating inside this request), answer_calls, cost_usd_est.
warningsStrings: calibration jobs, stale profiles, underpowered groups, ignored correlation headers.
request_idAlso in the x-request-id header.

Calibration profiles

Create

POST /v1/calibration-profiles
FieldDefaultDescription
namerequiredLetters, digits, ., _ or -, at most 128 characters, starting with a letter or digit. Names are unique per organization, ignoring case
backendrequiredA backend object
method"APS"One of LAC, APS, RAPS, CQR, ordinal-aps, CRC, RCPS, LTT, IVAP, CVAP, conformal-factuality, trust-or-escalate, calibrated-cascade
alpha0.1In (0,1)(0, 1)
strict_fingerprinttrueWhat a different backend does (details)
group_bynoneContext field for group-conditional calibration
prompt_template_hashnoneRecorded in the fingerprint (at most 256 characters)
retentionthe organization default"standard" or "zero" (zero retention)

201 with a Location header when the profile is new; 200 with the existing card when an identical profile exists; 409 profile_exists with details.differences (the fields that differ) when the name is taken by a different configuration. Profiles are versioned resources: use a new name for a new configuration. 422 profile_limit at 1,000 profiles.

curl https://cci.gitdate.ink/api/v1/calibration-profiles \
  -H "Authorization: Bearer $CLI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "support-routing-v3",
    "backend": {"provider": "openai", "model": "gpt-4.1-2025-04-14"},
    "method": "APS",
    "alpha": 0.1,
    "strict_fingerprint": true,
    "prompt_template_hash": "sha256:9f2c..."
  }'

The profile card

GET /v1/calibration-profiles/{name} returns the card; GET /v1/calibration-profiles returns {"profiles": [card, ...]}. An unknown name is 404 profile_not_found.

FieldMeaning
name, version, method, alphaIdentity. version is 0 until the first calibration and increments on every full recalibration; appended examples keep it. method and alpha come from the bound query once there is one
n, minimum_n, recommended_n, realized_coverage_ciSize of the calibration behind the current threshold, the hard floor for the bound query, the recommended size, and the realized-coverage interval
statuscollecting, calibrating, serving or stale
pending_nHuman-labelled examples stored but not yet scored
countsraw, human, judge, scored_human, pending_human, ineligible (rows whose label does not fit the query, or that lack evidence)
bindingThe bound query (query_type, query_fingerprint), its backend, cascade stages, sample_count, access_level and bound_at; null before the first evaluate
backend_fingerprintWhat the profile was calibrated against
strict_fingerprint, prompt_template_hash, retentionConfiguration (retention is standard or zero)
group_by, groupsThe Mondrian field, and {group: {n, status}} with status calibrated or underpowered
last_audit{id, date, at, sample, result, realized_coverage, ci, target, profile_version} of the latest audit
stale{reason, since, ...} when status is stale; reasons include backend_changed, monitor_alarm and contexts_required
job, last_job_errorThe calibration job running now ({id, kind, status, progress}), and the last job failure
registeredThe configuration given at creation
monitors_count, served_countMonitors on the profile, and guaranteed answers served
created_at, updated_at, last_calibrated_atTimestamps

Change retention, delete

PATCH /v1/calibration-profiles/{name} with {"retention": "zero"}, "standard", or null (inherit the organization default) returns the card. Any other field is a 422: a profile’s configuration never changes after creation. Switching a zero-retention profile back to standard needs an owner or admin.

DELETE /v1/calibration-profiles/{name} cancels the profile’s jobs and deletes its examples, versions, monitors and audits, returning {"name", "deleted": true, "generation"}.

Add examples

POST /v1/calibration-profiles/{name}/examples
{"examples": [{"context": ..., "label": ..., "source": "human", "group": ..., "metadata": {...}, "evidence": {...}, "id": "..."}]}
FieldDescription
contextRequired. The same shape you pass to evaluate.
labelRequired. A set or route option key, an interval level, true/false for belief and gate, response_a/response_b for judge, or for claim a list of {"text", "supported"}.
sourcehuman (default) or judge. Judge-labelled rows are stored but never set conformal thresholds.
groupThe Mondrian group, when group_by is not in context.
metadataAn object of at most 8 KB.
evidenceRequired on every human row of a client-evidence profile (recipe).
idYour own id for the row (at most 128 characters).

Up to 10,000 examples per call and 100,000 per profile. The response is the card, plus warnings. What happens to the rows:

  • Before the first evaluate, they are stored and scored when the query binds (labels are checked then; misfits count as ineligible).
  • On a calibrated profile, labels are checked against the bound query (422 on a misfit), and the new rows are scored and appended: n grows and version stays. Small appends run inline; larger ones run as a job, and the card shows pending_n and job. Each appended row is first scored against the calibration as it was, and fed to the profile’s monitors as an outcome.

Feed outcomes

POST /v1/calibration-profiles/{name}/outcomes
{"outcomes": [{"request_id": "req_...", "query_id": "department", "label": "billing"},
              {"context": {...}, "label": "technical"}]}

Labelled production outcomes for the profile’s monitors, never for calibration. An outcome with request_id (and the query_id, when the request had several queries) reuses the answer that was served, with no model call; an outcome with context is answered against the current calibration first. At most 1,000 per call; source may be human (default) or judge. The response is {"accepted", "rejected": [{"index", "field", "message"}], "monitors": [...]}. A profile that has never been calibrated answers 422 profile_not_bound.

Recalibrate

POST /v1/calibration-profiles/{name}/calibrate
{"backend": {...}, "wait": true}

Re-scores every eligible example and promotes a new version: with the bound backend, or with backend to adopt a new one (which also clears a backend_changed stale state). With wait (default true) and at most 200 estimated model calls, it runs inline and returns 200 {"status": "completed", "result": {"version", "n", "ineligible"}, "profile": card}; otherwise 202 {"status", "job", "profile"}. Errors: profile_not_bound (never evaluated), profile_empty (no eligible examples), contexts_required (a new backend on a zero-retention profile).

Label with a judge

POST /v1/calibration-profiles/{name}/label-with-judge
{"judge": {...}, "unlabelled_examples": [{"context": ...}], "human_labelled_sample_size": 300,
 "strategy": "uniform", "seed": 1234}

The profile must be bound (422 profile_not_bound otherwise) and serve a belief, set, interval, gate, judge or route query. The judge is a hosted backend. Up to 20,000 unlabelled examples.

FieldDefaultMeaning
strategyuniformuniform selects the human subset uniformly at random (valid for prediction-powered inference); uncertainty picks the items the judge is least sure of (ppi_valid: false)
seedrandomRecorded in the result, so the selection can be reproduced

The response is always 202. A small pool is labelled within the request:

{
  "job_id": "job_01k...",
  "status": "awaiting_human_labels",
  "pool_size": 20000,
  "human_tasks": [{"id": 17, "context": {"...": "..."}, "judge_label": "billing", "judge_confidence": 0.81}],
  "selected_indices": [17, 203, 911],
  "strategy": "uniform",
  "seed": 1234,
  "ppi_valid": true,
  "judge_quality": {"agreement_with_humans": 0.91, "correlation": 0.72,
                    "effective_label_multiplier": 2.1, "scored_against_n_existing_examples": 300},
  "usage": {"backend_calls": 20300, "...": "..."}
}

A large pool returns {"job_id", "status": "queued", "pool_size", "background_job", "ppi_valid", "seed"} with a Location header; poll GET .../label-with-judge/{job_id} for the same result. The judge’s labels are stored on the profile as source: "judge" rows. judge_quality is measured against human-labelled examples already on the profile (null when there are none).

Audit

POST /v1/calibration-profiles/{name}/audit
{"examples": [{"context": ..., "label": ...}], "confidence": 0.95, "async": false}

Answers each fresh example with the profile’s calibrated runtime and checks realized coverage (or risk, for a Gate) with a Clopper-Pearson interval at confidence (0.5 to 1, default 0.95). Up to 2,000 examples.

{"id": "aud_01k...", "result": "pass", "realized_coverage": 0.903, "ci": [0.864, 0.934],
 "sample": 300, "target": 0.9, "date": "2026-09-18", "at": "2026-09-18T10:02:14.301Z",
 "kind": "coverage", "confidence": 0.95, "profile_version": 3}

kind is coverage, risk, fdr or cost_budget. For risk audits, realized_coverage is one minus the risk and target one minus the risk target, so every result reads the same way. The result is stored: it becomes the card’s last_audit, guarantee cards served from the same version carry last_audited, and GET .../audits lists every audit.

StatusWhen
202 {"status", "job"}"async": true
422 audit_too_largeMore than about 1,500 estimated model calls without "async": true
422 audit_not_supportedA belief profile: audit a Gate or Set on the same question
422 contexts_required"async": true on a zero-retention profile
424 insufficient_calibrationThe profile has not been calibrated yet

Monitors

POST /v1/calibration-profiles/{name}/monitors
{"type": "coverage", "target": 0.88, "false_alarm_rate": 0.05, "labelled_sample_rate": 0.02,
 "use_judge_pseudo_labels": false, "on_alarm": "alert_only"}
FieldDefaultMeaning
typecoveragecoverage (for set, interval, claim, judge, route profiles), risk (for gate profiles) or fingerprint (any profile)
targetrequired except for fingerprintIn (0,1)(0, 1)
false_alarm_rate0.05In (0,1)(0, 1); the alarm threshold is 1 / false_alarm_rate
labelled_sample_ratenoneRecorded with the monitor, for your own sampling
use_judge_pseudo_labelsfalseRecord judge-sourced outcomes as assisted points (they never move the e-value)
on_alarmalert_onlystale also marks the profile stale, so its answers are heuristic until it is recalibrated

201 with the monitor: id, profile, type, target, false_alarm_rate, labelled_sample_rate, use_judge_pseudo_labels, on_alarm, status (active, triggered or superseded), state, signal, n, n_assisted, n_skipped, e_value, threshold, profile_version, alarmed_at, created_at. A type that does not match the profile’s guarantee is a 422; at most 20 monitors per profile (monitor_limit).

GET .../monitors/{id}/alerts returns the alerts raised since the last poll of that monitor and advances its cursor; ?all=true returns every alert, and ?since=<ISO time or alert id> the alerts after that point without moving the cursor. An alert has id, type, severity (critical for an e-process alarm, warning for a fingerprint change), n, e_value, target, false_alarm_rate, detected_at, message, monitor_id, profile_version and details. Polling never calls a model.

GET .../monitors/{id}/points?after_step=0&limit=500 returns the monitor’s outcome stream (step, source, outcome, skip_reason, assisted, e_value, log_e_value, profile_version, observed_at; at most 5,000 per call). An unknown monitor is 404 monitor_not_found.

Jobs

GET /v1/jobs?profile=&status=&limit=50 (1 to 200), GET /v1/jobs/{id}, and POST /v1/jobs/{id}/cancel. A job has id, kind, status (queued, running, succeeded, failed, cancelled), profile, progress ({done, total}), estimated_calls, actual_calls, result, error, created_at, started_at, finished_at and request_id. An unknown job is 404 job_not_found. See background jobs.

Backends

GET /v1/backends returns {"backends": [...]}, one entry per provider: provider, label, configured (whether your organization has a connection for it), access_level (with auto), max_access_level, connections ([{name, default, status}]), example models, and notes. The SDK’s client.list_backends() returns the list.

The SDK raises CLIError("HTTP <status>: <message>") for statuses it has no dedicated exception for, including 404, 409 and 402; the exception carries the message, not the code. To branch on a code, call the route with httpx and read the error body. See Errors and retries.