API reference

API reference

Base URL: https://cci.gitdate.ink/api/v1 (or your self-hosted deployment’s URL). Every body is JSON.

Authentication

Authorization: Bearer <CLI_API_KEY>

The Python SDK reads the key from CLI_API_KEY and the base URL from CLI_BASE_URL. A self-hosted deployment on localhost accepts requests without a key.

Evaluate

POST /v1/evaluate
Content-Type: application/json
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>YesOne or more named queries. Each query is a flat object, described below.

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.", "account_tier": "enterprise"},
    "backend": {"provider": "openai", "model": "gpt-4.1-2025-04-14", "access_hint": "auto"},
    "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": "Auto-route this ticket without human review?",
        "calibration_profile": "support-routing-v3",
        "guarantee": "fdr",
        "target": 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.

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
setinstructions, options (2 or more), calibration_profilealpha, method (LAC, APS, RAPS), group_by, backend_access_hint
intervalinstructions, levels (2 to 10), calibration_profilealpha, method (CQR, ordinal-aps)
gateinstructions, calibration_profile, guarantee (risk, risk_high_probability, fdr), targetdelta (required for risk_high_probability), loss
claiminstructions, calibration_profilealpha, support_source
judgeinstructions, calibration_profilealpha, cascade
routecascade, calibration_profile, guarantee (cost_budget, 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 stages, each {"backend": <backend object> | "human_queue"}.

Backend objects

FieldDescription
provideropenai, azure-openai, anthropic, gemini, bedrock, openrouter, vllm, sglang, or client_evidence
modelModel identifier (hosted providers)
access_hintauto (default), sampling, logprobs, prompt-scoring, exact, hidden-state
connectionStored provider credential to use
provider fieldsFor example deployment, api_version, reasoning_effort, effort, sample_count, thinking_level, region, custom_model_import, pin_upstream, upstream, quantization, base_url, engine_version, logprobs_mode, deterministic (see 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 non-route 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
level_probabilitiesinterval at L1 and above
samplesThe same queries at L0, and claim at every level
hidden_statesAdded at L4 when the backend implements it
claim_scoring"client" on claim queries at L2 and above

Response

FieldDescription
answersMap from query id to answer object. Every answer has type and guarantee.
backendThe backend that served the request.
usagebackend_calls and backend_tokens.
warningsArray of strings, for example a fingerprint mismatch on a non-strict profile.
request_idAlso returned in the x-request-id header.
Answer typeFields
beliefprobability, venn_abers ([p0, p1])
setset, probabilities, venn_abers (per option)
intervalpoint_estimate, interval, legend
gatedecision (auto_approve, escalate, abstain)
claimretained_claims, dropped_claims (objects with text, reason, score)
judgewinner, escalated_to
routeoutput, served_by, escalated, cost_cents

The guarantee object is specified on Guarantee reference.

Calibration profiles

MethodPathBodyReturns
POST/v1/calibration-profilesname, backend, method, alpha, strict_fingerprint, optional group_by, prompt_template_hashProfile
GET/v1/calibration-profiles{"profiles": [...]}
GET/v1/calibration-profiles/{name}Profile
POST/v1/calibration-profiles/{name}/examples{"examples": [{context, label, source?, group?, metadata?}]}Profile
POST/v1/calibration-profiles/{name}/label-with-judgejudge, unlabelled_examples ([{context}]), human_labelled_sample_sizeLabelling job
POST/v1/calibration-profiles/{name}/audit{"examples": [...]}Audit result
POST/v1/calibration-profiles/{name}/monitorstype, false_alarm_rate, optional target, labelled_sample_rate, use_judge_pseudo_labelsMonitor
GET/v1/calibration-profiles/{name}/monitors{"monitors": [...]}
GET/v1/calibration-profiles/{name}/monitors/{id}/alerts{"alerts": [...]}

A profile object has name, version, method, alpha, n, minimum_n, recommended_n, realized_coverage_ci, last_audit, backend_fingerprint, group_by, groups ({group: {n, status}}), and status (collecting, serving, stale).

An audit result has result (pass or fail), realized_coverage, ci ([lower, upper]), sample, target, and date.

A monitor has id, profile, type, target, false_alarm_rate, labelled_sample_rate, and status. An alert has type, severity, n, e_value, target, false_alarm_rate, detected_at, and message.

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..."
  }'

Backends

MethodPathReturns
GET/v1/backends{"backends": [...]}: configured backends and their detected access level

Errors

Error bodies carry a human-readable message (or detail / error); 422 bodies also name the offending field.

StatusMeaningSDK exception
401 UnauthorizedMissing or invalid API keyAuthenticationError
422 Unprocessable EntityRequest failed validationValidationError (.field)
424 Failed DependencyA query’s profile does not yet have enough examples for the requested guarantee; the body still contains heuristic-labelled answersReturned as heuristic answers; InsufficientCalibrationError in strict mode
429 Too Many RequestsRate limit exceeded; honor retry-afterRateLimitError (.retry_after) after retries
502 Backend ErrorThe model backend errored, or reached a lower access level than the query requiredBackendError after retries
529 OverloadedThe service is temporarily overloadedBackendError after retries

The Python SDK retries 429, 502, and 529 with full-jitter exponential backoff by default. See Errors and retries.