BlocklogAI Compliance
Getting Started

Quickstart — 5 Minutes to First Log

Install the Python SDK, configure your credentials, and anchor your first cryptographically verified AI decision trail.

Step 01

Install the SDK

Install the official Blocklog Python SDK via pip.

terminal
bash
pip install blocklog
Step 02

Configure Credentials

Set your Blocklog API key as an environment variable.

env
bash
export BLOCKLOG_API_KEY="blk_live_xxxxxxxxx"
Step 03

Ingest and verify your first log

Create an ingest.py script to trace an agent execution, record a decision, and verify its integrity against the ledger.

ingest.py
python
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 SHA-256 hashed decision payload, and verifies the integrity chain via the Blocklog backend.