Skip to main content

Demo Agent Quickstart

See Treeship in action by deploying our demo loan processing agent.

What You’ll Build

A FastAPI agent that:
  • Processes loan applications
  • Creates Ed25519-signed attestations for each decision
  • Provides verification URLs clients can check

Prerequisites

Quick Start

1

Get the code

git clone https://github.com/zerkerlabs/treeship
cd treeship/examples/demo-agent
2

Install dependencies

pip install -r requirements.txt
3

Set your API key

export TREESHIP_API_KEY=ts_live_...
4

Run the agent

python agent.py
The agent starts at http://localhost:8000

Test It

Process a loan application:
curl http://localhost:8000/process \
  -H "Content-Type: application/json" \
  -d '{
    "applicant": "Jane Doe",
    "amount": 50000,
    "credit_score": 720,
    "income": 85000
  }'
Response:
{
  "decision": "approved",
  "amount": 50000,
  "reason": "Good credit score; Low debt-to-income ratio; Moderate loan amount",
  "verification_url": "https://treeship.dev/verify/demo-loan-agent/abc123",
  "timestamp": "2026-02-21T10:30:00.000Z"
}

Verify the Decision

Visit the verification_url in your browser. Anyone can verify:
  • The decision was made
  • When it happened
  • The cryptographic signature is valid
No login required. No trust in Treeship required.

Deploy

Docker

docker build -t demo-agent .
docker run -p 8000:8000 -e TREESHIP_API_KEY=ts_live_... demo-agent

Railway

Deploy on Railway Add TREESHIP_API_KEY as an environment variable.

Render / Fly.io / Heroku

  1. Fork the repo
  2. Connect your deployment platform
  3. Set TREESHIP_API_KEY environment variable
  4. Deploy

Customize

Edit agent.py to:
ChangeLocation
Agent nameAGENT_NAME constant
Decision logicanalyze_application() function
What gets attestedts.attest() call in /process
API endpointsFastAPI routes

What’s Being Attested

attestation = ts.attest(
    agent=AGENT_NAME,
    action=f"Loan {decision}: ${application.amount:,.0f} for {application.applicant}",
    inputs_hash=ts.hash({
        "applicant": application.applicant,
        "amount": application.amount,
        "credit_score": application.credit_score,
        "income": application.income
    }),
    metadata={
        "decision": decision,
        "risk_score": analysis["risk_score"]
    }
)
  • agent: Identifies this agent in the verification page
  • action: Human-readable description of what happened
  • inputs_hash: SHA-256 hash of the input data (data never sent to Treeship)
  • metadata: Optional additional context

Next Steps