Sealgraf

Sealgraf for Vercel AI SDK

Add owner-set spending permissions and sealed purchase receipts to your Vercel AI SDK workflow through Sealgraf's hosted service. Your agent uses its own payment channel; Sealgraf never holds or moves money.

Published package: @sealgraf/ai-sdk-tools. This is a Sealgraf-maintained integration, not a claim of platform endorsement.

Before you start

Get a Vercel AI SDK key to set spending limits and copy an agent key. Set the purchase cap, rolling budget, allowed categories, and the threshold above which you want to approve a purchase. Keep the key in your server's environment or the platform's secret store; never put it in browser code or a public workflow.

Install and connect

npm install @sealgraf/ai-sdk-tools ai @ai-sdk/mcp zod

Set SEALGRAF_API_KEY in the server environment before running the example.

import { createSealgrafToolsFromEnv } from "@sealgraf/ai-sdk-tools";

if (!process.env.SEALGRAF_API_KEY) {
  throw new Error("Set SEALGRAF_API_KEY on the server");
}
const tools = createSealgrafToolsFromEnv();
console.log(Object.keys(tools));

The tools are sealgraf_check_permission, sealgraf_claim_decision_token, sealgraf_complete_purchase, and sealgraf_get_receipt. Reading a preauthorization through sealgraf_get_receipt lets a paused workflow recover its current status. Add a separately configured payment tool if the agent needs to make purchases.

Follow the purchase lifecycle

  1. Check the proposed purchase before using your own payment channel. A check can allow, deny, or require human approval.
  2. If approval is required, stop and notify the owner. Resume only after the owner has decided; read the original check's status and collect its decision token once authorized. Do not poll in a tight loop.
  3. A denial means no purchase. Approval thresholds do not override the mandate's hard limits.
  4. After a successful purchase, report its actual charged amount, the original preauthorization and decision token, and a stable completion nonce. Preserve these exact arguments if the response is lost.
  5. Read the sealed receipt. This integration reports a charge; it does not independently verify the payment.

Keep request identities stable when retrying. A lost check response is an unknown outcome: recover the original decision or stop. Never create a fresh decision to authorize a payment that already happened. If authorization expires after payment, preserve the original decision and payment evidence and surface the unsealed outcome.

What a receipt proves

A sealed receipt preserves the completion report and decision evidence. The amount supplied through these framework tools is reported by the caller, not independently verified against a payment rail. Public verification is masked: a stranger sees the kind of purchase, while the signed-in owner sees the amounts and details. Permission decisions, including denials, are recorded in decision history; they are not completed-purchase receipts.

Next steps