# KPN Advisory — x402 quickstart for AI agents

KPN gives an AI agent a **verified, machine-readable judgment** on Korea‑specific business
matters — market entry, legal/contract, tax/settlement, K‑beauty/content, policy — cross‑verified
by a **DID‑verified expert committee**. Pay per call with **x402 (Base USDC)**.

**Honest by design:** scores are never inflated. Unverifiable estimates (ROI, success‑rate, future
numbers) are **not asserted** — they are separated into `needsVerification` with *how to verify*.
Every judgment carries an **audit URL** you can machine‑re‑verify.

---

## TL;DR

| | |
|---|---|
| Discover | CDP **x402 Bazaar** — search `korea advisory`, or `GET /ai/discovery` |
| Free preview (no payment, no LLM) | `POST /ai/preview` |
| Trust metadata (live, DB‑computed) | `GET /ai/trust` |
| Pay & get judgment | `POST /ai/advisory` with `X-PAYMENT` — **from $1** |
| Network / Asset | **Base** (`eip155:8453`) / **native USDC** `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
| Pay to | `0x63fFCA01D352A245f9D5cF372380966814D3Ee5e` |

Base URL: `https://persona-mcp-server.onrender.com`

---

## 1) Preview before paying — free, no LLM

```bash
curl -s -X POST https://persona-mcp-server.onrender.com/ai/preview \
  -H 'Content-Type: application/json' \
  -d '{"question":"Verify our Korean cosmetics OEM partner trust before signing"}'
```

Returns the **output structure**, **STOP/HOLD flag labels** (sample from a real judgment),
**trust metadata** (DID‑verified committee, expert count, completed cases, evidence level), and the
**price for your query**. Enough to decide before spending $1.

## 2) Pay with x402 — gasless for you (EIP‑3009)

You only need **USDC on Base** (no ETH — the facilitator pays gas).

```js
import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);     // your funded Base wallet
const payFetch = wrapFetchWithPayment(fetch, account);

const res = await payFetch("https://persona-mcp-server.onrender.com/ai/advisory", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ question: "Verify our Korean cosmetics OEM partner trust before signing" }),
});
const { ref_code, access_token, status_url } = await res.json();
// The x402 client auto: 402 -> sign EIP-3009 authorization -> retry -> facilitator settles.
```

## 3) Poll for the judgment JSON

```js
let judgment;
for (;;) {
  const p = await fetch(status_url);            // GET /report/{ref}/json?token=...
  if (p.status === 200) { judgment = await p.json(); break; }
  await new Promise(r => setTimeout(r, 15000)); // 202 = still generating (a few minutes)
}
```

## 4) Act on the result — machine‑readable

```jsonc
{
  "decision": "hold",
  "decisionByIssue": [ { "issue": "...", "verdict": "STOP|HOLD|CONDITIONAL_GO|GO", "reason": "..." } ],
  "trustScore": 54,
  "trustDimensions": { "A": 0.82, "C": 0.55, "E": 0.18, "V": 0.48 },
  "businessRisk": "High",
  "needsVerification": [ "unverified variable + how to verify ..." ],
  "requiredActions": [ "..." ],
  "citations": [ { "title": "...", "url": "...", "official": true } ],
  "officialSourceRatio": 0.45,
  "confidence": "low|medium|high",
  "auditId": "aud_...",
  "auditVerifyUrl": "https://persona-mcp-server.onrender.com/ai/audit/aud_..."
}
```

Re‑verify any judgment: `GET auditVerifyUrl` → committee DIDs + cited sources + dimensions.

---

## Pricing (dynamic, honest)

| Tier | Price | When |
|---|---|---|
| classification | **$1** | general / simple judgment |
| committee | **$3** | legal / tax / contract — committee cross‑verified |
| deep | **$5** | legal citation **+** source documents |

Send `classification_only: true` to force the $1 tier. The 402 response tells you the exact price.

## Why pay vs free web search
- **DID‑verified committee cross‑verification** — not a single model's guess.
- **Audit ID → machine re‑verifiable** (committee DIDs, sources).
- **Honest quantification** — STOP/HOLD with reasons & legal basis; ROI/success‑rate are *not*
  fabricated — separated into `needsVerification`. Small real numbers over big fake ones.

*KPN is a committee judgment‑verification service. It does not act on your behalf (no payments,
transfers, or device control) — it returns a verified judgment for your agent to act on.*
