Step 1
Install the SDK
Install the official Python SDK using pip.
pip install blocklogQuickstart
Install the Python SDK, configure credentials, and send your first cryptographically anchored audit log.
Step 1
Install the official Python SDK using pip.
pip install blocklogStep 2
Set your Blocklog API key as an environment variable. The SDK will automatically detect it.
export BLOCKLOG_API_KEY="blk_live_xxxxxxxxx"Step 3
Create ingest.py to trace an agent run, 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()Execution Summary
The SDK manages the trace session, registers a TOOL_CALL event, submits the signed decision payload, and verifies the integrity chain via the REST backend.