Skip to content

Client

The Client class (alias for CRPOrchestrator) is the main entry point for the CRP protocol.

Constructor

from crp import Client

client = Client(
    provider="openai",      # Provider name or LLMProvider instance
    config=None,            # Optional dict of configuration overrides
    llm=None,               # Optional pre-configured LLM provider instance
    model="gpt-4o",         # Model name (passed to provider)
    **init_kwargs,          # Additional provider-specific kwargs
)

Parameters

Parameter Type Default Description
provider str \| LLMProvider Required Provider identifier or instance
config dict \| None None Configuration overrides
llm LLMProvider \| None None Pre-configured provider (overrides provider)
model str \| None None Model name for the provider
**init_kwargs Any Additional provider-specific arguments

Provider Strings

String Provider Class
"openai" OpenAIAdapter
"anthropic" AnthropicAdapter
"ollama" OllamaAdapter
"llamacpp" LlamaCppAdapter

Configuration Options

config = {
    "max_continuations": 10,          # Max continuation windows
    "extraction_stages": [1,2,3,4,5], # Which stages to run (1-6)
    "ckf_enabled": True,              # Enable cross-session knowledge
    "ckf_path": "./my_kb",            # CKF storage path
    "ckf_max_size_mb": 500,           # CKF size limit
}

Core Methods

ingest()

Ingest raw text into the session's warm state:

result = client.ingest(
    raw_text="Kubernetes is an open-source container orchestration platform...",
    source_label="k8s-docs",
)

Returns: ExtractionResult

Field Type Description
facts_extracted int Number of facts extracted
source_label str Source identifier
fact_ids list[str] IDs of extracted facts

session_status()

Get current session status:

status = client.session_status()
print(f"Session: {status.session_id}")
print(f"Windows: {status.windows_completed}")
print(f"Facts:   {status.facts_in_warm_state}")
print(f"Cost:    ${status.total_cost:.4f}")

Returns: SessionStatus

Field Type Description
session_id str Session identifier
windows_completed int Total windows dispatched
total_input_tokens int Cumulative input tokens
total_output_tokens int Cumulative output tokens
facts_in_warm_state int Facts in warm store
overhead_ratio float CRP overhead as fraction of total time
remaining_budget int \| None Remaining token budget
total_cost float Estimated cost in USD

preview_envelope()

Preview envelope construction without dispatching:

preview = client.preview_envelope(
    system_prompt="You are a technical writer.",
    task_input="Explain Kubernetes networking.",
)
print(f"Saturation: {preview.saturation:.1%}")
print(f"Facts:      {preview.facts_included}/{preview.facts_available}")

Returns: EnvelopePreview

Field Type Description
total_tokens int Total context window use
envelope_tokens int Tokens used by envelope
generation_reserve int Tokens reserved for generation
facts_included int Facts packed into envelope
facts_available int Total facts in warm state
saturation float Envelope fill ratio (0.0–1.0+)

Compliance Properties

All compliance components are accessible as public properties:

Property Type Purpose
client.risk_classifier RiskClassifier EU AI Act risk assessment
client.human_oversight HumanOversightController Human oversight levels
client.compliance_audit ComplianceAuditTrail HMAC audit trail
client.pii_scanner PIIScanner PII detection
client.consent_manager ConsentManager GDPR consent tracking
client.processing_records ProcessingRecordKeeper GDPR Art. 30 records
client.retention_manager RetentionManager Data retention
client.compliance_reporter ComplianceReporter Report generation
client.lineage_tracker DataLineageTracker Data lineage

See Compliance API for detailed documentation.

Lifecycle

from crp import Client

# Create
client = Client(provider="openai", model="gpt-4o")

# Use
client.ingest(text, "source")
output, report = client.dispatch(system_prompt, task_input)
status = client.session_status()

# Close
client.close()

Session cost

The first dispatch() or ingest() call triggers model loading (GLiNER, embeddings). This takes ~10–15 seconds. Subsequent calls are fast.