Install the Python SDK, configure your credentials, and anchor your first cryptographically verified AI decision trail.
Install the official Blocklog Python SDK via pip.
pip install blocklogSet your Blocklog API key as an environment variable.
export BLOCKLOG_API_KEY="blk_live_xxxxxxxxx"Create an ingest.py script to trace an agent execution, record a decision, and verify its integrity against the ledger.
import os
import blocklog
# 1. Initialize the SDK (loads from environment variables)
blocklog.init(api_key=os.environ.get("BLOCKLOG_API_KEY", "blk_demo_key"))
# 2. Instrument a tool dependency
@blocklog.tool(name="fetch-spot-price")
def check_price(ticker: str) -> float:
return 412.50
# 3. Instrument the agent execution
@blocklog.agent(name="quickstart-trader")
def run_agent():
price = check_price("TSLA")
with blocklog.decision(type="BUY", asset="TSLA") as d:
d.record_input(price=price)
d.record_output(order_id="ord_123")
print(f"Decision recorded: {d.id}")
try:
verification = blocklog.verify.decision(d.id)
print(f"Verification status: {verification.get('status', 'verified')}")
except Exception as e:
print(f"Verification failed: {e}")
if __name__ == "__main__":
run_agent()The SDK manages the trace session, registers a TOOL_CALL event, submits the SHA-256 hashed decision payload, and verifies the integrity chain via the Blocklog backend.