Client¶
The SDKClient class (also exported as CRPClient) is the main entry point for the CRP progressive SDK. This page combines hand-written examples with auto-generated reference docs from the source code.
Quick example¶
import crp
client = crp.SDKClient()
response = client.complete("Summarise the EU AI Act")
print(response.text)
print(response.crp.risk) # LOW | MEDIUM | HIGH | CRITICAL
print(response.crp.grounded)
print(response.crp.fabrications)
Auto-generated reference¶
crp.sdk.client.CRPClient dataclass ¶
Progressive-disclosure SDK client (SPEC-032).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider | LLMProvider | None | An LLMProvider instance (optional - can set later). | None |
config | CRPConfig | None | A CRPConfig instance (optional - loads defaults or crp.config.yaml). | None |
safety | str | dict[str, Any] | Safety profile name ("balanced", "strict", etc.) or dict. | 'balanced' |
depth | str | Default query depth ("auto", "quick", "standard", "thorough", "exhaustive"). | 'auto' |
app_profile | ApplicationProfile | None | Optional application capability contract used to auto-select provider, relay strategy, and context behaviour. | None |
storage property ¶
Access storage visibility API.
knowledge property ¶
Access knowledge location.
audit property ¶
Access the tamper-evident compliance audit trail.
compliance property ¶
Access EU AI Act / ISO 42001 compliance helpers.
safety property writable ¶
Access the Safety Control Plane (SPEC-033, SPEC-034).
ckf property ¶
Access the Contextual Knowledge Fabric (SPEC-009, SPEC-025).
cso property ¶
Access the Cognitive State Object (SPEC-030).
provenance property ¶
Access the Decision Provenance Engine (SPEC-005).
reasoning property ¶
Access reasoning scaffolds, CQS, and cross-window validation.
activation property ¶
Access CRP activation-mode detection (SPEC-017).
agent property ¶
Access multi-agent safety budget and chain tools (SPEC-012).
events property ¶
Access the protocol event bus (§9).
providers property ¶
Access LLM provider registration (SPEC-008).
extract property ¶
Access the graduated extraction pipeline (§2.5).
gateway property ¶
Access CRP Gateway helpers (SPEC-016).
headers property ¶
Access the CRP HTTP header surface (SPEC-002).
observability property ¶
Access observability subsystems (audit, metrics, telemetry).
policy property ¶
Access the safety policy engine (SPEC-006).
scan property ¶
Access CRP Scan helpers (SPEC-013, SPEC-036, SPEC-039).
comply property ¶
Access CRP Comply helpers (SPEC-040, SPEC-042, SPEC-047, SPEC-048).
orchestrator property ¶
Access the live CRPOrchestrator instance directly.
This exposes every public orchestrator method and subsystem (e.g. client.orchestrator.dispatch(...), client.orchestrator.ckf).
modules property ¶
Access any public class or function in the crp package.
This dynamic mirror lets you reach the full CRP API without importing modules manually::
client.modules.envelope.cdr.cdr_rank(...)
client.modules.security.consent.ConsentManager(...)
core property ¶
Access core orchestrator, session, DAG, ledger, and facilitator.
continuation property ¶
Access continuation manager and helpers.
envelope property ¶
Access envelope builder, packer, reranker, CDR, and formatter.
state property ¶
Access warm store, cold storage, snapshots, event log, and router.
security property ¶
Access safety manifest, consent, RBAC, checkpoints, and audit trail.
resources property ¶
Access adaptive allocator, cost model, overhead, and resource manager.
advanced property ¶
Access curator, feedback, meta-learning, source grounding, and validator.
cli property ¶
Access CLI sidecar handler and startup result types.
errors property ¶
Access public CRP exception classes.
__init__(provider=None, config=None, safety='balanced', depth='auto', model=None, api_key=None, input_continuation_mode=None, app_profile=None) ¶
Manual init to allow a safety property on a dataclass.
configure(**kwargs) ¶
Apply runtime configuration overrides (Layer 5).
Unknown keys are stored in the unified config. Keys that map to core orchestrator settings are also forwarded when possible.
complete(prompt, system='You are a helpful assistant.', **kwargs) ¶
Single-turn completion with automatic governance (Level 0).
Returns:
| Type | Description |
|---|---|
CRPCompletionResponse | CRPCompletionResponse with |
stream(prompt, system='You are a helpful assistant.', *, depth=None, **kwargs) ¶
Stream a single-turn completion as StreamEvent objects.
Each event has ``event_type`` (``token``, ``extraction``,
``continuation``, ``window_complete``, ``done``, ``error``) and
``data``. Concatenating all ``token`` data values produces the same
text as :meth:`complete`.
Args:
depth: Override depth (``quick`` / ``standard`` / ``thorough`` /
``exhaustive``).
Example::
for event in client.stream("Explain CRP."):
if event.event_type == "token":
print(event.data, end="")
elif event.event_type == "done":
print("
Done")
ingest(path) ¶
Ingest documents into the Contextual Knowledge Fabric.
Accepts a file path, directory path, or list of paths.
ask(question, system='You are a helpful assistant.', depth=None, **kwargs) ¶
Multi-turn quality-aware query with source attribution (Level 1–2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth | str | None | Override depth for this query ("quick", "standard", "thorough", "exhaustive"). Level 2 control. | None |
Returns:
| Type | Description |
|---|---|
CRPAskResponse | CRPAskResponse with quality tier, sources, completeness, and |
CRPAskResponse | inspectable reasoning (Level 2). |
tool(fn) ¶
Decorator: register a tool for tool-mediated dispatch (Level 2).
Usage::
@client.tool
def get_metrics(service: str) -> dict:
return {"cpu": 0.5}
call_tool(name, *args, **kwargs) ¶
Call a registered tool by name (Level 2).
dispatch_positioned(user_request, *, fabric=None, executor=None, profile=None, governor=None, clarify_handler=None, policy=None, oversight_required=None, context_facts=None, max_operations=12, temperature=0.2, max_tokens=1024, prior_cso=None, max_continuation_windows=1) ¶
Run the positioned-tool-loop (CRP-SPEC-049/050) with this client's provider.
Positioning, not injection: each operation positions the model on only the 1–3 tools the protocol selected for it - never the full catalogue. Any @client.tool functions are auto-registered as capabilities when no explicit fabric is supplied.
For multi-turn workflows, pass the previous result's .cso as prior_cso so the follow-up turn is positioned with everything the prior turn established (facts, tool observations, decisions).
Returns a PositionedResult exposing .text, .cso, .event_stream, .observation_count, .headers, and .halted.
conversation(**defaults) ¶
Start a multi-turn positioned conversation that manages state for you.
Each .say(request) runs the positioned loop with the running CSO relayed forward automatically - no manual prior_cso threading::
convo = client.conversation()
r1 = convo.say("Look up the service on port 443.")
r2 = convo.say("Based on that, is it safe for a login page?")
defaults are passed to every dispatch_positioned call (e.g. profile=, max_continuation_windows=, clarify_handler=).
derive_profile(messages, tools=None) ¶
Derive an application capability contract from observed messages.
session() ¶
Return a live view of the current CRP session.
save_config(path) ¶
Save the current unified config to path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | Destination file path. | required |
config_hash() ¶
Return a deterministic hash of the loaded unified config.
Returns:
| Type | Description |
|---|---|
str | Hex digest string, or empty string if hashing is unavailable. |
__aenter__() async ¶
Async context manager entry - not yet implemented.
__aexit__(exc_type, exc, tb) async ¶
Async context manager exit - not yet implemented.
reset() ¶
Clear accumulated session facts (warm store + CKF).
close() ¶
Release orchestrator resources.
Response types¶
crp.sdk.response.CRPCompletionResponse dataclass ¶
Level 0 response - drop-in governance (SPEC-032 §2).
crp.sdk.response.CRPAskResponse dataclass ¶
Level 1+2 response - quality-aware with inspectable reasoning (SPEC-032 §3–4).
crp.sdk.response.CRPResponseMeta dataclass ¶
The one governance object - five fields, not 58 headers (SPEC-032 §2.3).
Provider selection¶
SDKClient auto-detects the LLM provider from the environment:
| Source | Provider selected |
|---|---|
OPENAI_API_KEY set | OpenAI |
ANTHROPIC_API_KEY set | Anthropic |
| Ollama reachable on localhost | Ollama |
Override explicitly when needed:
Session management¶
Configuration¶
Safety profiles adjust the trade-off between autonomy and oversight. See Safety and compliance and Configuration for details.