Skip to main content
This walkthrough takes you from pip install to a decision visible on the dashboard. Pick the SDK you prefer; the REST API is the same underneath.
The tokens used below (pq_test_demo_key_REPLACE_ME, agent_1, customer IDs) are placeholders. Replace them with values from your Precipiq dashboard before copy-pasting into real code.

Prerequisites

  • A Precipiq API key — grab one from the dashboard. Keys look like pq_live_... (production) or pq_test_... (sandbox).
  • Python 3.12+ or Node 18+.
  • 30 seconds of network access to api.precipiq.dev.

Steps

1

Install the SDK

Install the Precipiq package for your language.
pip install precipiq
2

Log your first decision

Create a client and call log_decision / logDecision. The call returns a receipt containing the decision’s UUID and its position on the hash chain.
# demo.py
from precipiq import Precipiq

# ``enable_batching=False`` for the demo so the call ships
# synchronously and ``log_decision`` returns the server receipt
# instead of ``None``.  In production, leave batching on for
# throughput and call ``pq.flush()`` at shutdown.
pq = Precipiq(
    api_key="pq_test_demo_key_REPLACE_ME",
    enable_batching=False,
)

receipt = pq.log_decision(
    agent_id="pricing-bot",
    action_type="discount_offer",
    inputs={"customer_id": "cust_123", "tier": "gold"},
    outputs={"discount_pct": 15},
    confidence=0.82,
    human_in_loop=False,
)
# ``receipt`` is a dict keyed by the server's snake_case schema.
print("decision id:", receipt["decision_id"])
print("chain hash:", receipt["hash"])
Run the script. You should see a UUID and a 64-character SHA-256 hash printed to stdout within ~200 ms.
3

See it in the dashboard

Open dashboard.precipiq.dev, sign in with the same API key, and the decision appears at the top of the Decisions timeline — usually within one second of the SDK call, thanks to the dashboard’s WebSocket stream.You should see a row whose timestamp matches the receipt.timestamp your SDK call just returned, with the pricing-bot agent label and a confidence badge at 82%.
4

Wrap a function with track

In production you rarely call log_decision directly. Instead, wrap the function that makes the decision — the SDK captures inputs, outputs, and any exception automatically.
@pq.track(agent_id="pricing-bot", action_type="discount_offer")
def compute_discount(customer_id: str, tier: str) -> dict:
    # Your real business logic:
    pct = 15 if tier == "gold" else 5
    return {"discount_pct": pct}

compute_discount("cust_456", "silver")
# The decision, inputs, and outputs are recorded on every call.
5

Link the decision to a financial outcome

When the customer gets charged — via a Stripe webhook, an internal event, or any other billing system — link the decision to the resulting financial event so the AI P&L can attribute dollars.
# ``receipt`` came from step 2.
# The second arg is the ``financial_event_id`` returned by your Stripe integration.
pq.link_outcome(
    receipt["decision_id"],
    "fev_abc",
    correlation_strength=1.0,       # 0..1 — strongest when directly caused
    link_type="revenue",            # "revenue" | "cost" | "liability" | "neutral"
)
For events that come from Stripe, the built-in webhook receiver auto-creates the financial event and the attribution engine proposes the link — see the Stripe integration guide.
6

Check your AI P&L

Query aggregated P&L for any date range. The same numbers appear on the P&L tab of the dashboard, live-updated as new events stream in.
pnl = pq.get_ai_pnl(start="2026-04-01", end="2026-04-30")
# ``pnl`` is a dict keyed by the server's snake_case schema.
if pnl is not None:
    print(pnl["total_revenue_attributed"], pnl["currency"])
    print(pnl["net_ai_impact"])
In about five minutes you now have a live SDK install, a chain-linked decision on the ledger, a linked financial event, and an attribution visible on the dashboard.

Next: understand the data model

Concepts — the six record types and how they compose.