Backends

Backends

CLI is model-agnostic. Every backend reports the access level it reaches; the calibration engine is identical regardless of which one you use.

A backend can be passed as a typed object, as a plain dict with a "provider" key, or as a CustomBackend that runs your own model. Pass it to client.evaluate(backend=...), to the client constructor (CLIClient(backend=...)) as a default, to calibration_profiles.create(backend=...), or inside a Judge or Route cascade stage.

from cli_sdk import OpenAIBackend
 
backend = OpenAIBackend(model="gpt-4.1-2025-04-14")
# equivalent dict: {"provider": "openai", "model": "gpt-4.1-2025-04-14"}

Fields every hosted backend has

FieldTypeDefaultMeaning
modelstrrequiredModel identifier. Prefer dated snapshots over aliases.
access_hintstr"auto"Pin a score family: "auto", "sampling", "logprobs", "prompt-scoring", "exact", "hidden-state".
connectionstr, optionalthe organization’s default for the providerName of a stored provider connection.

These backends are configuration only: the hosted service calls the provider on your behalf, with a credential your organization stored as a connection. There is no shared provider key; without a connection a request fails with 422 connection_required. Constructing a typed backend without model, or with an unknown access_hint, raises ConfigurationError.

Hosted support matrix

ProviderSDK classauto reachesHighest level (with a hint)Notes
OpenAIOpenAIBackendL1 on non-reasoning configurations, else L0L1Details
Azure OpenAIAzureOpenAIBackendAs OpenAIL1v1 or versioned API
AnthropicAnthropicBackendL0L0Sampling only
Gemini APIGeminiBackendL0L0
Vertex AIdict, provider: "vertex" (or GeminiBackend on a Vertex-mode connection)L0L0Service account
AWS BedrockBedrockBackendL0L0Converse API
Bedrock Custom Model ImportBedrockBackend(custom_model_import=True)L1L2 (prompt-scoring)Probed by connection Test
OpenRouterOpenRouterBackendL1 for OpenAI models on a pinned openai, together or fireworks upstream, else L0L1Pinned by default
vLLMVLLMBackendL1L3 (prompt-scoring, exact)L4 is not available over HTTP
SGLangSGLangBackendL1L4 (hidden-state)L4 needs --enable-return-hidden-states
OpenAI-compatibledict, provider: "openai-compatible"L0, or L1 with use_logprobsL1Any Chat Completions server
Mistral, Groq, xAIdictL0L0Presets
Together, Fireworks, DeepSeek, CerebrasdictL1L1Presets
Your own modelCustomBackendas declaredas declaredClient evidence

A level above auto must be asked for with access_hint (or a Set’s backend_access_hint); a level the backend cannot reach fails with 502 access_level_unavailable before any model call. A Set with more than 20 options runs at L0 on providers whose auto level is L1, because first-token log-probabilities cover at most 20 option letters.

Closed APIs

OpenAI

from cli_sdk import OpenAIBackend
 
OpenAIBackend(model="gpt-4.1-2025-04-14")                        # L1
OpenAIBackend(model="gpt-6-luna", reasoning_effort="none")       # L1
OpenAIBackend(model="gpt-6-astra", reasoning_effort="medium")    # L0
Extra fieldMeaning
reasoning_effortnone, minimal, low, medium, high, xhigh or max. Part of the scoring function.

L1 (top-20 first-token log-probabilities) is reached by gpt-4.1 (and gpt-4o, gpt-4-turbo, gpt-3.5) and by GPT-5.x and GPT-6 Sol and Luna at reasoning_effort="none". Leaving reasoning_effort unset on those models gives L1 too: the service sends "none". Any other effort, and gpt-6-astra or gpt-6.1-sol at any effort, reaches L0, and CLI samples.

Azure OpenAI

from cli_sdk import AzureOpenAIBackend
 
AzureOpenAIBackend(model="gpt-4.1", deployment="gpt-4.1")
AzureOpenAIBackend(model="gpt-4.1", deployment="support-prod", access_hint="logprobs")
Extra fieldMeaning
deploymentThe Azure deployment name; else the connection’s default deployment; else model.
api_versionUse the versioned API with this api-version. Leave unset (and empty on the connection) for the v1 API.
reasoning_effortAs for OpenAI.

Same access levels as OpenAI, read from model (the model the deployment serves), whatever the deployment is called. Set the deployment’s version-upgrade policy to NoAutoUpgrade for any deployment backing a calibration profile; the fingerprint records the endpoint, the API version and the model.

Anthropic Claude

from cli_sdk import AnthropicBackend
 
AnthropicBackend(model="claude-sonnet-5-5", sample_count=8)
Extra fieldMeaning
effortlow, medium, high, xhigh or max. Part of the scoring function: hold it fixed between calibration and serving. Not sent to Haiku models.
sample_countSamples per score, 1 to 32 (8 when unset).

Reaches L0 only: the Messages API returns no token probabilities and has no n parameter, so CLI builds every score from repeated sampling (Set, Belief) or resampled claim support (Claim). Current Claude models reject non-default sampling temperature, so CLI never sets it. The service sends each model the thinking settings it accepts.

L0 backends need one backend call per sample. A Set or Belief query with sample_count=8 on Claude issues 8 backend calls per answer, and 8 per calibration example, reported in result.usage.backend_calls. Budget calibration runs accordingly.

Google Gemini and Vertex AI

from cli_sdk import GeminiBackend
 
GeminiBackend(model="gemini-3.8-flash", thinking_level="low")
vertex = {"provider": "vertex", "model": "gemini-3.8-flash", "connection": "vertex-eu"}
Extra fieldMeaning
thinking_levelminimal, low, medium or high.
sample_countDict form only (the SDK class has no field for it): samples per score.

The hosted service reaches Gemini through its OpenAI-compatible endpoints, at L0 for every model. A Gemini connection in Vertex mode (a service account, a project and a location) serves both provider: "gemini" and provider: "vertex" through Vertex AI. Use stable model codes, never -latest aliases. See Gemini and Vertex connections.

AWS Bedrock

from cli_sdk import BedrockBackend
 
BedrockBackend(model="us.amazon.nova-pro-v1:0", region="us-east-1")
BedrockBackend(model="arn:aws:bedrock:us-east-1:123456789012:imported-model/abc123",
               custom_model_import=True, access_hint="prompt-scoring")
Extra fieldMeaning
regionAWS region; else the connection’s region.
custom_model_importTrue for models imported through Bedrock Custom Model Import; model is then the imported model’s ARN.

Natively hosted models go through the Converse API at L0. Models you import through Custom Model Import (your own open weights) reach L1 from first-token log-probabilities, and L2 (prompt scoring of text you supply) with access_hint="prompt-scoring", when the connection’s Test found the model supports them.

OpenRouter

from cli_sdk import OpenRouterBackend
 
OpenRouterBackend(model="openai/gpt-4.1", upstream="openai", pin_upstream=True)
Extra fieldDefaultMeaning
pin_upstreamTrueRoute to one upstream only, with fallbacks off and required parameters on
upstreamthe model slug’s vendor prefixThe upstream provider to pin to
quantizationNoneUpstream quantization to require (fp8, bf16, int4, …)

L1 is reached only by OpenAI models that reach L1 themselves, on a pinned openai, together or fireworks upstream; everything else is L0. Keep pin_upstream on: without it, a silent fallback to another upstream would change the scoring model between calibration and serving and break exchangeability.

Self-hosted engines

The hosted service calls these servers over the network, at the base URL stored on their connection, which must pass Test before it is used. On the hosted service the URL must be https and publicly reachable; in a self-hosted deployment it can be a private address inside your VPC. Both SDK classes require base_url (they raise ConfigurationError without it), and it must have the same origin as the connection’s URL.

vLLM

from cli_sdk import VLLMBackend
 
VLLMBackend(
    model="meta-llama/Llama-3.3-70B-Instruct",
    base_url="https://vllm.example.com/v1",
    engine_version="0.11.0",
    quantization="fp8",
    access_hint="exact",
)
Extra fieldMeaning
base_urlRequired by the SDK; same origin as the connection.
engine_versionRecorded in the backend fingerprint.
quantizationRecorded in the backend fingerprint.
logprobs_moderaw_logprobs or processed_logprobs; recorded in the fingerprint.
LevelEvidenceHint
L1First-token log-probabilitiesauto, logprobs
L2Prompt scoring: the log-likelihood of each option’s full text (prompt_logprobs), with no top-k truncation or letter-position biasprompt-scoring
L3Exact probabilities of the label tokensexact
L4Not available: vLLM returns hidden states only to files or Python, not over HTTPhidden-state fails with 502 access_level_unavailable

L2 and L3 need the server’s /tokenize endpoint, which the connection Test looks for. Run the server with VLLM_BATCH_INVARIANT=1 for bitwise-reproducible calibration runs.

SGLang

from cli_sdk import SGLangBackend
 
SGLangBackend(
    model="meta-llama/Llama-3.3-70B-Instruct",
    base_url="https://sglang.example.com/v1",
    deterministic=True,
    access_hint="hidden-state",
)
Extra fieldMeaning
base_urlRequired by the SDK; same origin as the connection.
engine_versionRecorded in the backend fingerprint.
deterministicWhether deterministic inference is enabled on the server.

SGLang reaches L1 to L3 as vLLM does, and L4 when the server was started with --enable-return-hidden-states: the service reads hidden states from the native /generate endpoint, trains a probe on half of the calibration rows and conformalizes its scores on the other half, so split-conformal validity is kept. L4 serves Set, Belief, Gate and Interval queries. SGLang returns temperature-scaled log-probabilities by default and ignores per-request seeds unless deterministic inference is enabled.

OpenAI-compatible servers and presets

gateway = {"provider": "openai-compatible", "model": "llama-3.3-70b", "use_logprobs": True}
together = {"provider": "together", "model": "meta-llama/Llama-3.3-70B-Instruct-Turbo"}

openai-compatible is any server speaking the Chat Completions API at its connection’s base URL (L1 with "use_logprobs": true, else L0). The presets mistral, groq, together, fireworks, deepseek, xai and cerebras have fixed endpoints and take reasoning_effort and sample_count. There are no typed classes for them; pass a dict. Levels are on Provider connections.

Bring your own model

A CustomBackend runs your model inside your process. You implement the evidence methods your access level supports; the SDK calls them before sending the request and sends only the resulting evidence (probabilities or samples) with backend provider "client_evidence". The server never calls a model for these requests, so no provider connection is needed, and your model, its weights and its API credentials never leave your infrastructure.

from cli_sdk import CLIClient, CustomBackend, Set
 
class MyEngine(CustomBackend):
    access_level = "L1"
    name = "in-house-classifier-v7"
 
    def score_options(self, context, instructions, options):
        # a probability for each option key (need not sum to 1)
        return my_model.option_probabilities(context, instructions, list(options))
 
    def sample(self, context, instructions, n):
        # n independently sampled answers
        return [my_model.generate(context, instructions) for _ in range(n)]
 
client = CLIClient(backend=MyEngine(), sample_count=20)
MethodSignatureUsed for
score_options(self, context, instructions, options) -> dict[str, float]Set, Belief, Gate, Judge, Interval at L1 and above
sample(self, context, instructions, n) -> list[str]The same queries at L0, and Claim at every level
score_text(self, context, instructions, candidate) -> floatReserved: the SDK does not call it yet
hidden_states(self, context, instructions) -> list[float]Sent with Set/Belief/Gate/Judge evidence at L4 when implemented; the hosted service validates these vectors but does not use them to build scores

What each query type asks your methods for:

QueryOptions passed to score_options
SetThe query’s options
Belief, Gate{"true": None, "false": None}
Judge{"response_a": None, "response_b": None}
IntervalLevel indices as strings, for example {"0": "Calm", "1": "Frustrated"}

sample receives n = sample_count from the client (default 20). Route queries are skipped: they declare their own cascade of hosted backends, and the hosted service does not accept client evidence for them. A Claim needs {"claims": [{"text", "score"}]} evidence on the hosted service, which the default collect_evidence does not produce: override collect_evidence for claim queries. Methods you do not implement raise NotImplementedError, so a query that needs one fails with a clear error instead of silently downgrading its guarantee. The constructor accepts base_url=None and arbitrary keyword options (stored on self.base_url and self.options) for your own use, and validates access_level ("L0" to "L4"), raising ConfigurationError otherwise.

Calibration examples for a client-evidence profile carry the evidence too: see client-evidence examples.

The request still carries context and each query’s instructions, because the service hashes the context for the audit trail and reads group_by fields from it. If the context itself cannot leave your network, run the service inside it (Self-hosting), use local mode, or the offline engine. With AsyncCLIClient, the evidence methods are called synchronously; wrap slow models with asyncio.to_thread.

Pinning and fingerprinting

Every calibration profile records a backend fingerprint (profile.backend_fingerprint): the provider, the model, the access level and, at L0, the sample count; the prompt version; and, where they apply, the endpoint (Azure resource, self-hosted origin, Vertex location), the API version, the engine version, quantization, log-probability mode and deterministic flag, plus your prompt_template_hash. The connection’s credential is not part of it, so rotating a key does not change it.

When a request reaches a profile with a different fingerprint:

  • With strict_fingerprint=True (the default in calibration_profiles.create), the profile is marked stale (reason backend_changed) and that request’s answers fail closed (424, heuristic). Requests that use the calibrated backend keep being served. Recalibrate with POST .../calibrate to adopt the new backend.
  • With strict_fingerprint=False, a recalibration job for the new backend is queued (at most once every 10 minutes), and answers are heuristic until it finishes.

A fingerprint drift monitor alerts on either, and also when the provider reports serving a different model than at calibration. See Calibration profiles.

Listing configured backends

with CLIClient() as client:
    for backend in client.list_backends():
        print(backend["provider"], backend["configured"], backend["access_level"],
              backend["max_access_level"], [c["name"] for c in backend["connections"]])

Each entry also carries a label, example models and notes.