Python API Reference
ReasonKit provides high-performance Python bindings to the core Rust reasoning engine.
Installation
uv pip install reasonkit
Note: The package requires a Python environment (3.8+).
Quick Start
from reasonkit import Reasoner, Profile
# Initialize the reasoner
reasoner = Reasoner()
# Run a quick analysis
result = reasoner.think_with_profile(Profile.Quick, "What are the risks of AI development?")
if result.success:
print(f"Confidence: {result.confidence * 100:.1f}%")
print(f"Perspectives: {result.perspectives()}")
else:
print(f"Error: {result.error}")
Classes
Reasoner
The main interface for executing ThinkTools and reasoning profiles.
class Reasoner:
def __init__(self, use_mock: bool = False, verbose: bool = False, timeout_secs: int = 120):
"""
Create a new Reasoner instance.
Args:
use_mock (bool): If True, use a mock LLM for testing (no API calls).
verbose (bool): If True, enable verbose logging.
timeout_secs (int): Timeout for LLM calls in seconds.
"""
Methods
run_gigathink(query: str, context: str = None) -> ThinkToolOutput
Generates 10+ diverse perspectives on a topic using the GigaThink protocol.
run_laserlogic(argument: str) -> ThinkToolOutput
Analyzes logical structure, detects fallacies, and validates arguments using LaserLogic.
run_bedrock(statement: str, domain: str = None) -> ThinkToolOutput
Breaks down statements to fundamental axioms using First Principles decomposition.
run_proofguard(claim: str, sources: List[str] = None) -> ThinkToolOutput
Verifies claims against multiple sources using the ProofGuard triangulation protocol.
run_brutalhonesty(work: str) -> ThinkToolOutput
Performs adversarial self-critique to find flaws and weaknesses.
think(protocol: str, query: str) -> ThinkToolOutput
Execute a generic protocol by its ID string.
think_with_profile(profile: Profile, query: str, context: str = None) -> ThinkToolOutput
Execute a pre-defined reasoning profile (chain of tools).
list_protocols() -> List[str]
Returns a list of available protocol IDs.
list_profiles() -> List[str]
Returns a list of available profile names.
Profile
Enum defining reasoning depth and rigor.
class Profile:
None = 0 # No ThinkTools (baseline)
Quick = 1 # Fast 2-tool chain (GigaThink + LaserLogic)
Balanced = 2 # Standard 4-tool chain
Deep = 3 # Thorough 5-tool chain (adds BrutalHonesty)
Paranoid = 4 # Maximum verification (95% confidence target)
ThinkToolOutput
Structured output from a reasoning session.
class ThinkToolOutput:
# Properties
protocol_id: str # The protocol that was executed
success: bool # Whether execution succeeded
confidence: float # Confidence score (0.0 - 1.0)
duration_ms: int # Execution time in milliseconds
total_tokens: int # Total tokens consumed
error: str | None # Error message if failed
Methods
data() -> dict
Returns the full structured output as a Python dictionary.
perspectives() -> List[str]
Helper to extract perspectives (for GigaThink results).
verdict() -> str | None
Helper to extract the final verdict (for validation protocols).
steps() -> List[StepResultPy]
Returns the list of individual steps executed in the chain.
to_json() -> str
Returns the raw JSON output string.
Convenience Functions
These functions allow you to run protocols without explicitly instantiating a Reasoner.
import reasonkit
# Run specific tools
reasonkit.run_gigathink("Topic", use_mock=False)
reasonkit.run_laserlogic("Argument", use_mock=False)
reasonkit.run_bedrock("Statement", use_mock=False)
reasonkit.run_proofguard("Claim", use_mock=False)
reasonkit.run_brutalhonesty("Work", use_mock=False)
# Run profiles
reasonkit.quick_think("Query", use_mock=False)
reasonkit.balanced_think("Query", use_mock=False)
reasonkit.deep_think("Query", use_mock=False)
reasonkit.paranoid_think("Query", use_mock=False)
Error Handling
All errors raised by ReasonKit are wrapped in ReasonerError.
from reasonkit import ReasonerError
try:
result = reasoner.run_gigathink("Query")
except ReasonerError as e:
print(f"Reasoning failed: {e}")