Self-hosting

Self-hosting

CLI can run with no CLI-hosted component in the loop. There are four levels, from least to most isolated:

OptionWhat leaves your processWhat leaves your networkNeeds
Hosted service with a CustomBackendcontext, instructions, and evidence (probabilities, samples)the sameA cci_live_ API key
Self-hosted service in your VPCrequests to your own deploymentnothing (model calls go to the providers you configure)The service images (Enterprise plan)
Local mode (LocalCLIClient)calls to your modelcalls to your modelpip install cci-sdk
Offline engine (cli_sdk.stats)nothingnothingpip install cci-sdk

Running the service inside your VPC

The service ships as two images: cci-stats-api (the API service: the statistics engine, calibration store, jobs, monitors, audits, provider connections and telemetry) and cci-website (the dashboard, and the reverse proxy that serves the public /api/v1 routes). Two compose files cover the two ways to run them.

Compose fileRunsAuthenticationUse it for
deploy/docker-compose.ymlapp (dashboard and proxy), stats-api, caddy (TLS on ports 80 and 443)Accounts, organizations, API keys, SSO, as on the hosted serviceA shared deployment for teams
deploy/docker-compose.selfhost.ymlstats-api only, on 127.0.0.1:8000None (CCI_AUTH_MODE=none): every request acts as one local organizationOne machine, CI, or a service next to your code

Both expose the same /v1 API as the hosted service, so SDK code does not change; only the base URL does.

The full stack

deploy/docker-compose.yml starts three services on one Docker network. caddy terminates TLS and forwards to app; app serves the dashboard and proxies /api/v1/* to stats-api, which is never published on a host port. They share one data volume. Three secrets go in the .env file next to the compose file:

VariableUsed byWhat it is
AUTH_SECRETappSigns dashboard sessions
CCI_INTERNAL_TOKENapp, stats-apiAt least 32 random characters; authenticates the dashboard’s internal calls
CCI_SECRETS_KEYstats-api onlyThe AES-256-GCM key ring that seals provider credentials and other secrets
printf 'AUTH_SECRET=%s\n' "$(openssl rand -hex 32)" >> .env
printf 'CCI_INTERNAL_TOKEN=%s\n' "$(openssl rand -hex 32)" >> .env
printf 'CCI_SECRETS_KEY=%s\n' "$(docker run --rm cci-stats-api:latest python -m app.admin secrets generate)" >> .env
docker compose -f deploy/docker-compose.yml up -d

Edit deploy/Caddyfile to your own hostname. Then sign in, create API keys and provider connections in the dashboard exactly as on the hosted service, and point the SDK at your deployment:

export CLI_BASE_URL=https://cli.internal.example.com/api/v1
export CLI_API_KEY=cci_live_...        # created in your deployment's dashboard

The single-container service

deploy/docker-compose.selfhost.yml runs stats-api alone, with CCI_AUTH_MODE=none, published on the loopback interface only. There is no dashboard and there are no API keys.

CCI_SECRETS_KEY=$(docker run --rm cci-stats-api:latest python -m app.admin secrets generate) \
CCI_INTERNAL_TOKEN=$(openssl rand -hex 32) \
docker compose -f deploy/docker-compose.selfhost.yml up -d
from cli_sdk import CLIClient
 
client = CLIClient(api_key="local", base_url="http://127.0.0.1:8000/v1")

With CCI_AUTH_MODE=none anyone who can reach the port acts as the one local organization. Keep the port on 127.0.0.1 (as the compose file does), or on a private network you trust. The service refuses to start in this mode on a non-loopback address unless CCI_ALLOW_ANONYMOUS=1 is set, which the compose file sets because the container binds 0.0.0.0 behind a loopback-only host port.

Provider connections without the dashboard

Model calls still use provider connections. Without the dashboard, manage them through the service’s internal API, which the dashboard uses. It is reachable only with the CCI_INTERNAL_TOKEN; in CCI_AUTH_MODE=none, use local for the user and organization ids:

Create the connection

curl -s http://127.0.0.1:8000/internal/connections \
  -H "X-CCI-Internal-Token: $CCI_INTERNAL_TOKEN" -H "X-CCI-User-Id: local" -H "X-CCI-Org-Id: local" \
  -H "Content-Type: application/json" \
  -d '{"provider": "vllm", "name": "gemma", "config": {"base_url": "http://vllm.internal:8000/v1"}}'

The body is {"provider", "name", "config": {...}, "secret": {...}}, with the fields listed on Provider connections (for example "secret": {"api_key": "..."} for OpenAI). The response carries the connection’s id; secrets are never returned.

Test it

curl -s -X POST http://127.0.0.1:8000/internal/connections/<id>/test \
  -H "X-CCI-Internal-Token: $CCI_INTERNAL_TOKEN" -H "X-CCI-User-Id: local" -H "X-CCI-Org-Id: local" \
  -H "Content-Type: application/json" -d '{"model": "google/gemma-4-12B-it"}'

vLLM, SGLang, OpenAI-compatible and Azure connections must pass a test before use. GET /internal/connections lists connections, and POST /internal/connections/<id>/default makes one the default.

On the hosted service, endpoints you supply must be https and resolve to public addresses. Inside your own network you will want private ones, such as the http://vllm.internal:8000/v1 above: add these variables to the stats-api service’s environment in the compose file before you create the connection.

VariableEffect
CCI_ALLOW_PRIVATE_BACKENDS=1vLLM, SGLang, OpenAI-compatible and Azure endpoints may resolve to private addresses (implies the next one)
CCI_ALLOW_HTTP_BACKENDS=1Those endpoints may use plain http
from cli_sdk import CLIClient, VLLMBackend
 
backend = VLLMBackend(
    model="google/gemma-4-12B-it",
    base_url="http://vllm.internal:8000/v1",     # the same origin as the "gemma" connection
    engine_version="0.11.0",
    quantization="fp8",
)
 
with CLIClient(api_key="local", base_url="http://127.0.0.1:8000/v1", backend=backend) as client:
    print(client.list_backends())

A self-hosted service next to self-hosted vLLM or SGLang keeps every model call inside the VPC.

Configuration

VariableDefaultNotes
CCI_ENVproduction (in the image)production refuses to start without CCI_SECRETS_KEY and CCI_INTERNAL_TOKEN, with the mock provider enabled, or with any provider base URL override
CCI_AUTH_MODEdbnone accepts every request as one local organization
CCI_SECRETS_KEYnoneKey ring kid:base64key[,kid:base64key...], newest first
CCI_INTERNAL_TOKENnone32 or more characters, shared with the dashboard
DATABASE_PATH, CCI_STATS_DB_PATH, CCI_OBSERVABILITY_DB_PATH, CCI_PROFILES_DIRunder /app/dataThe data files (below)
CCI_SAMPLE_COUNT8Samples per score at L0 (at most CCI_MAX_SAMPLE_COUNT, 32)
CCI_INLINE_CALIBRATION_MAX_CALLS200Larger calibrations run as background jobs
CCI_RATE_PER_SEC, CCI_RATE_BURST10, 60Token bucket per API key
CCI_ALLOW_PRIVATE_BACKENDS, CCI_ALLOW_HTTP_BACKENDSoffPrivate or plain-HTTP model endpoints
CCI_ENABLE_MOCK_PROVIDERoffThe keyless mock provider; refused in production
Data fileContents
cci.dbUsers, organizations, memberships, API keys, settings, alert rules and channels, the audit log (owned by the dashboard)
cci-stats.dbProfile state, jobs, idempotency keys, audits, monitors with their points and alerts, label jobs, sealed provider connections, OTLP destinations
cci-observability.dbRequests, spans, answers, payloads, profile and monitor history, rollups, incidents, guard events
cci-profiles/Per-profile metadata, example rows, calibration records and archived versions

Back up the data volume (sqlite3 ... '.backup ...' for the databases, and the cci-profiles directory) before upgrades.

Operator commands

docker compose exec stats-api python -m app.admin secrets generate        # a new CCI_SECRETS_KEY entry
docker compose exec stats-api python -m app.admin secrets rotate          # re-seal stored secrets under the active key
docker compose exec stats-api python -m app.admin migrate --dry-run DIR   # run startup migrations on a copy of a data directory
docker compose exec stats-api python -m app.admin fingerprint-check       # bound profiles still produce their calibrated fingerprint

To rotate the encryption key: prepend a new entry to CCI_SECRETS_KEY, restart, run secrets rotate, then drop the old entry at the next restart. Run fingerprint-check after upgrading the image: it reports any bound profile whose calibrated backend would now produce a different fingerprint, so you find out before a request marks the profile stale.

  • API keys. The SDK sends a key whenever one is configured. It only allows a missing key when base_url is on localhost, 127.0.0.1, 0.0.0.0 or ::1. Any other hostname needs a key.
  • Proxies and TLS. Pass your own httpx.Client for corporate proxies or a private certificate authority: CLIClient(http_client=httpx.Client(verify="/etc/ssl/internal-ca.pem")).
  • Engine version. Guarantee cards report stats_version. Keep the deployment and any cci-sdk installs on the same version so audit trails can be compared if a workload moves between them.

Zero-retention mode

Zero retention is a per-profile setting ("retention": "zero"), with an organization-wide default in Data settings. A zero-retention profile discards each calibration example’s raw context once it has been scored, keeping a salted hash, the label, the source, the group and the evidence, and payload capture is off for every request that touches it.

WorksUnavailable
evaluate with every primitive and guaranteeRe-scoring stored examples for a new backend: a backend change makes the profile stale (contexts_required) until you upload the examples again
add_examples (contexts are discarded once scored)Inspecting or exporting stored contexts
Audits against fresh examples you send (synchronous only)Audits and large label-with-judge pools as background jobs
Outcomes and drift monitors

Keep your own copy of every calibration set you upload if you may need to recalibrate against another backend, and run audits locally when examples cannot be sent at all (audit_coverage, or cli calibration audit-local). Details are on Observability: zero retention.

Air-gapped offline engine

The statistics engine is a pip-installable package with no network dependency. cli_sdk.stats, cli_sdk.LocalMonitor, and the audit and label-efficiency helpers in cli_sdk.calibration never import the HTTP client or open a connection. They need only NumPy.

Install from a wheelhouse built on a connected machine:

# on a connected machine
pip download cci-sdk -d wheelhouse/
 
# inside the air-gapped network
pip install --no-index --find-links wheelhouse/ cci-sdk

Then calibrate, predict, audit, and monitor with no service at all:

import json
 
import numpy as np
from cli_sdk import LocalMonitor
from cli_sdk.calibration import audit_coverage
from cli_sdk.stats.conformal import aps
 
cal_probs, cal_labels = np.load("cal_probs.npy"), np.load("cal_labels.npy")
q_hat = aps.calibrate(cal_probs, cal_labels, alpha=0.10, seed=0)
 
with open("support-routing-v3.json", "w") as handle:      # your own versioned "profile"
    json.dump({"method": "APS", "alpha": 0.10, "q_hat": q_hat, "n": len(cal_labels)}, handle)
 
sets = aps.predict(np.load("test_probs.npy"), q_hat)
audit = audit_coverage([y in s for y, s in zip(np.load("test_labels.npy"), sets)], target=0.90)
monitor = LocalMonitor(type="coverage", target=0.88, false_alarm_rate=0.05)

The offline calibration guide walks through a full run, including Venn-Abers intervals, group-conditional thresholds, and the local drift monitor.

Offline, you own the pieces the calibration store normally enforces: minimum-nn checks (minimum_calibration_size), versioning of thresholds, audits, and backend fingerprints. Calibrate on the exact artifact you deploy — same weights, quantization, prompt template, and decoding settings — because any change to the scoring pipeline breaks exchangeability.