Local protocol mode — Anvil, development executor keys, and synthetic Nitro registration are not production trust assumptions.

Build with Takusen

Build your first judgement

Use the x402 flow to submit a typed question and follow it to a verifiable result.

Before you start

Set TAKUSEN_API_URL to the API origin and choose the EVM wallet that will pay for requests. Takusen uses prepaid USDC credits: the wallet deposits USDC into one settlement domain's escrow, and the API exposes the observed amount as credits on that domain. Credits never move between domains automatically.

1. Choose a settlement domain

Available domainssh
curl "$TAKUSEN_API_URL/v1/chain"

Choose a domain whose active and healthy fields are true. Save its domainId, chainId, USDC contract, escrow address, and one advertised depositMechanisms value. Your wallet needs that domain's USDC plus enough native gas for any wallet-submitted transactions.

2. Deposit USDC and receive credits

For an API integration, request a deposit plan. amountMicros uses micro-USDC, so 10000000 means 10 USDC. Use a mechanism advertised by /v1/chain.

Request a deposit plansh
curl --request POST "$TAKUSEN_API_URL/v1/credits/deposit" \
  --header 'Content-Type: application/json' \
  --cookie takusen.cookies \
  --data '{
    "settlementDomain": "0x<domainId>",
    "amountMicros": 10000000,
    "mechanism": "eip3009"
  }'
MechanismWhat the requester does
eip3009Sign the returned TransferWithAuthorization typed data, then POST settlementDomain, mechanism, the returned message as authorization, and the signature to /v1/credits/deposit/facilitate.
approveSubmit every returned wallet transaction in order, wait for confirmation, then POST the final deposit transaction hash with settlementDomain and amountMicros to /v1/credits/deposit/observe.

The deposit is spendable only after Native Chain observation. Poll /v1/credits with the session cookie until the selected account's availableMicros is at least the request's spendLimitMicros. depositedMicros includes observed funding; reservedMicros is committed to active requests; spentMicros is finalized execution cost.

Confirm spendable creditssh
curl --cookie takusen.cookies "$TAKUSEN_API_URL/v1/credits"

3. Discover models and output types

Request capabilitiessh
curl "$TAKUSEN_API_URL/v1/models"
curl "$TAKUSEN_API_URL/v1/output-schemas"

Choose active model IDs from /v1/models and a governed output type from /v1/output-schemas. Do not hard-code these values across protocol revisions.

4. Prepare the request

request.jsonjson
{
  "settlementDomain": "0x<domainId returned by /v1/chain>",
  "prompt": "Will the stated resolution condition be satisfied?",
  "outputType": "boolean",
  "models": ["openai/gpt-6-luna", "anthropic/claude-haiku-5.5"],
  "spendLimitMicros": 250000,
  "timeLimitSeconds": 90,
  "executionQuorum": 2,
  "visibility": "public"
}

spendLimitMicros is the maximum all-in reservation in micro-USDC: 250000 is 0.25 USDC. Keep the serialized body unchanged through the challenge and submission calls.

5. Request the payment challenge

Expected 402 challengesh
curl --request POST \
  --url "$TAKUSEN_API_URL/v1/x402/requests" \
  --header 'Content-Type: application/json' \
  --dump-header response.headers \
  --data @request.json

402 Payment Required is the expected response. Decode the PAYMENT-REQUIRED header or read the equivalent JSON body. It contains the exact network, asset, escrow, amount, one-use challenge ID, AuthorizeRequest typed data, and extensions.takusen.binding for an on-chain consumer. The challenge expires after ten minutes, leaving time to confirm the application binding before payment.

6. Sign and submit

  1. Sign the exact extensions.takusen.authorization EIP-712 typed data with the funded payer wallet.
  2. Create an x402 v2 PaymentPayload using the selected accepts entry. Set extensions.takusen.challengeId, requester, and requestSignature.
  3. Base64-encode that JSON payload as PAYMENT_SIGNATURE.
  4. POST the unchanged request.json again with PAYMENT-SIGNATURE. A successful response is 202 Accepted and contains the requestId.
Authorized submissionsh
curl --request POST \
  --url "$TAKUSEN_API_URL/v1/x402/requests" \
  --header 'Content-Type: application/json' \
  --header "PAYMENT-SIGNATURE: $PAYMENT_SIGNATURE" \
  --data @request.json

7. Follow the result

Public result readssh
curl --no-buffer "$TAKUSEN_API_URL/v1/requests/$REQUEST_ID/stream"
curl "$TAKUSEN_API_URL/v1/requests/$REQUEST_ID"
curl "$TAKUSEN_API_URL/v1/requests/$REQUEST_ID/answers"

Public requests need no session for streaming or reads. Reconnect the SSE stream with Last-Event-ID until the request reaches a terminal state, then inspect the aggregate record, model answers, evidence hashes, measured spend, and settlement transaction.