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"}.fieldnames the offending field as a dotted path, for examplequeries.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
/v1prefix.
Routes
| Method | Path | Scope | Returns |
|---|---|---|---|
POST | /v1/evaluate | evaluate | Answers with guarantee cards |
GET | /v1/backends | any | Providers, your connections, and access levels |
POST | /v1/calibration-profiles | profiles:write | A profile card (201 new, 200 identical) |
GET | /v1/calibration-profiles | any | {"profiles": [...]} |
GET | /v1/calibration-profiles/{name} | any | A profile card |
PATCH | /v1/calibration-profiles/{name} | profiles:write | A profile card (only retention can change) |
DELETE | /v1/calibration-profiles/{name} | profiles:write | {"name", "deleted": true, "generation"} |
POST | /v1/calibration-profiles/{name}/examples | profiles:write | A profile card |
POST | /v1/calibration-profiles/{name}/outcomes | profiles:write | {"accepted", "rejected", "monitors"} |
POST | /v1/calibration-profiles/{name}/calibrate | profiles:write | 200 completed, or 202 with a job |
POST | /v1/calibration-profiles/{name}/label-with-judge | profiles:write | 202: a labelling job |
GET | /v1/calibration-profiles/{name}/label-with-judge/{job_id} | any | The labelling job |
POST | /v1/calibration-profiles/{name}/audit | profiles:write | 200 an audit result, or 202 with a job |
GET | /v1/calibration-profiles/{name}/audits | any | {"audits": [...]} |
POST | /v1/calibration-profiles/{name}/monitors | profiles:write | 201: a monitor |
GET | /v1/calibration-profiles/{name}/monitors | any | {"monitors": [...]} |
GET | /v1/calibration-profiles/{name}/monitors/{monitor_id} | any | A monitor |
DELETE | /v1/calibration-profiles/{name}/monitors/{monitor_id} | profiles:write | {"id", "deleted": true} |
GET | /v1/calibration-profiles/{name}/monitors/{monitor_id}/alerts | any | {"alerts": [...]} since the last poll |
GET | /v1/calibration-profiles/{name}/monitors/{monitor_id}/points | any | {"points": [...]} |
GET | /v1/calibration-profiles/{name}/events | telemetry:read | The profile’s history (Events API) |
GET | /v1/jobs | any | {"jobs": [...]} |
GET | /v1/jobs/{job_id} | any | A job |
POST | /v1/jobs/{job_id}/cancel | profiles:write | The job |
GET | /v1/requests | telemetry:read | Request records (Events API) |
GET | /v1/requests/{request_id} | telemetry:read | One request’s trace |
GET | /v1/usage | telemetry:read | Grouped usage |
GET | /v1/events | telemetry:read | Guard events |
POST | /v1/events | events:write | 202 {"accepted", "rejected"} (guard events) |
POST | /v1/traces | events:write | OTLP/HTTP ingest (OTLP) |
GET | /v1/healthz | none | {"status": "ok"} |
GET | /v1/readyz | none | 200, 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| Field | Type | Required | Description |
|---|---|---|---|
context | string | object | array | Yes | The content every query is evaluated against. |
backend | object | See note | The model backend. Required unless every query declares its own cascade (every route query, and a judge query with cascade). |
queries | map<string, Query> | Yes | 1 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.
| Status | When |
|---|---|
200 | Every answer carries a guarantee |
424 | At least one answer is heuristic; the body still holds every answer, and warnings says why (calibrating, stale, too few examples) |
422 | profile_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, 529 | The 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.
type | Required fields | Optional fields |
|---|---|---|
belief | instructions, calibration_profile | criteria (an object) |
set | instructions, options (2 to 256), calibration_profile | alpha, method (LAC, APS, RAPS), group_by, backend_access_hint |
interval | instructions, levels (distinct strings), calibration_profile | alpha, method (CQR, ordinal-aps) |
gate | instructions, calibration_profile, target | guarantee (risk, the default, risk_high_probability, fdr), delta, loss (zero_one only) |
claim | instructions (a string), calibration_profile | alpha, support_source |
judge | instructions (a string), calibration_profile | alpha, cascade |
route | cascade, calibration_profile, task | guarantee (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 query | On a bound profile |
|---|---|
type, instructions, options, levels, criteria, support_source, task | Must stay the same, or 422 query_mismatch |
alpha, target, delta, method, guarantee, target_cents | May 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
| Field | Description |
|---|---|
provider | openai, azure-openai, anthropic, gemini, vertex, bedrock, openrouter, vllm, sglang, openai-compatible, mistral, groq, together, fireworks, deepseek, xai, cerebras, or client_evidence |
model | Model identifier (an imported model’s ARN for Bedrock Custom Model Import) |
access_hint | auto (default), sampling, logprobs, prompt-scoring, exact, hidden-state |
connection | The name of a provider connection; the provider’s default when omitted |
| Provider | Extra fields |
|---|---|
openai | reasoning_effort (none, minimal, low, medium, high, xhigh, max) |
azure-openai | deployment, api_version, reasoning_effort |
anthropic | effort (low, medium, high, xhigh, max), sample_count |
gemini, vertex | thinking_level (minimal, low, medium, high), sample_count |
bedrock | region, custom_model_import, sample_count |
openrouter | pin_upstream (default true), upstream, quantization, reasoning_effort |
vllm | base_url, engine_version, quantization, logprobs_mode (raw_logprobs, processed_logprobs) |
sglang | base_url, engine_version, deterministic |
openai-compatible | base_url, use_logprobs, reasoning_effort |
mistral, groq, together, fireworks, deepseek, xai, cerebras | reasoning_effort, sample_count |
client_evidence | name, 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 key | Sent when |
|---|---|
option_probabilities | set, belief, gate, judge at L1 and above (keys: the options; true/false; response_a/response_b) |
level_probabilities | interval at L1 and above (keys: level indices as strings, or level names) |
samples | The same queries at L0: 1 to 256 sampled replies |
claims | claim: 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 type | Fields |
|---|---|
belief | probability, venn_abers ([p0, p1]), raw_score |
set | set, probabilities, venn_abers (per option) |
interval | point_estimate, interval (level indices), levels (the names at both ends), legend |
gate | decision (auto_approve or escalate), confidence, threshold, venn_abers |
claim | retained_claims, dropped_claims (objects with text, reason, score), threshold |
judge | winner, escalated_to, decided_by |
route | output (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 field | Description |
|---|---|
answers | Map from query id to answer. |
backend | provider, model, access_level, and connection when one was used; stages for cascades. |
usage | backend_calls, backend_tokens, input_tokens, output_tokens, reasoning_tokens, calibration_calls (calls spent calibrating inside this request), answer_calls, cost_usd_est. |
warnings | Strings: calibration jobs, stale profiles, underpowered groups, ignored correlation headers. |
request_id | Also in the x-request-id header. |
Calibration profiles
Create
POST /v1/calibration-profiles| Field | Default | Description |
|---|---|---|
name | required | Letters, digits, ., _ or -, at most 128 characters, starting with a letter or digit. Names are unique per organization, ignoring case |
backend | required | A backend object |
method | "APS" | One of LAC, APS, RAPS, CQR, ordinal-aps, CRC, RCPS, LTT, IVAP, CVAP, conformal-factuality, trust-or-escalate, calibrated-cascade |
alpha | 0.1 | In |
strict_fingerprint | true | What a different backend does (details) |
group_by | none | Context field for group-conditional calibration |
prompt_template_hash | none | Recorded in the fingerprint (at most 256 characters) |
retention | the 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.
| Field | Meaning |
|---|---|
name, version, method, alpha | Identity. 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_ci | Size of the calibration behind the current threshold, the hard floor for the bound query, the recommended size, and the realized-coverage interval |
status | collecting, calibrating, serving or stale |
pending_n | Human-labelled examples stored but not yet scored |
counts | raw, human, judge, scored_human, pending_human, ineligible (rows whose label does not fit the query, or that lack evidence) |
binding | The bound query (query_type, query_fingerprint), its backend, cascade stages, sample_count, access_level and bound_at; null before the first evaluate |
backend_fingerprint | What the profile was calibrated against |
strict_fingerprint, prompt_template_hash, retention | Configuration (retention is standard or zero) |
group_by, groups | The 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_error | The calibration job running now ({id, kind, status, progress}), and the last job failure |
registered | The configuration given at creation |
monitors_count, served_count | Monitors on the profile, and guaranteed answers served |
created_at, updated_at, last_calibrated_at | Timestamps |
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": "..."}]}| Field | Description |
|---|---|
context | Required. The same shape you pass to evaluate. |
label | Required. 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"}. |
source | human (default) or judge. Judge-labelled rows are stored but never set conformal thresholds. |
group | The Mondrian group, when group_by is not in context. |
metadata | An object of at most 8 KB. |
evidence | Required on every human row of a client-evidence profile (recipe). |
id | Your 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 asineligible). - On a calibrated profile, labels are checked against the bound query
(
422on a misfit), and the new rows are scored and appended:ngrows andversionstays. Small appends run inline; larger ones run as a job, and the card showspending_nandjob. 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.
| Field | Default | Meaning |
|---|---|---|
strategy | uniform | uniform 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) |
seed | random | Recorded 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.
| Status | When |
|---|---|
202 {"status", "job"} | "async": true |
422 audit_too_large | More than about 1,500 estimated model calls without "async": true |
422 audit_not_supported | A belief profile: audit a Gate or Set on the same question |
422 contexts_required | "async": true on a zero-retention profile |
424 insufficient_calibration | The 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"}| Field | Default | Meaning |
|---|---|---|
type | coverage | coverage (for set, interval, claim, judge, route profiles), risk (for gate profiles) or fingerprint (any profile) |
target | required except for fingerprint | In |
false_alarm_rate | 0.05 | In ; the alarm threshold is 1 / false_alarm_rate |
labelled_sample_rate | none | Recorded with the monitor, for your own sampling |
use_judge_pseudo_labels | false | Record judge-sourced outcomes as assisted points (they never move the e-value) |
on_alarm | alert_only | stale 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.