paybondpaybond
Sign in

Vercel AI SDK spend controls

Guard Vercel AI SDK tools with Paybond toolApproval and wrapped execute — Harbor verify before side effects and auto-evidence after paid tool calls.

The Vercel AI SDK runs tools through generateText / streamText with optional toolApproval. Paybond supplies that approval hook and wraps execute on side-effecting tools — keep your provider client for inference; Paybond guards paid tool calls only.

TypeScript only. Python Kit does not ship a Vercel AI adapter. Use agent-agnostic spend controls for Python parity.

Try it

Terminal
Terminal commandSwipe to inspect long lines
paybond login
paybond agent demo vercel-ai smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format table

Scaffold

Terminal
Terminal commandSwipe to inspect long lines
paybond init agent-middleware --framework vercel-ai --out paybond-vercel-ai.ts
paybond policy init --preset travel --out paybond.policy.yaml
import { generateText, tool } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";
import { Paybond } from "@paybond/kit";

const paybond = await Paybond.open({ apiKey: process.env.PAYBOND_API_KEY! });

const { agentTools: tools, toolApproval } = await paybond.agent({
  policy: "travel",
  framework: "vercel-ai",
  tools: {
    bookHotel: tool({
      description: "Book a hotel room",
      inputSchema: z.object({
        city: z.string(),
        estimatedPriceCents: z.number().int().nonnegative(),
      }),
      execute: async (args) => bookHotel(args),
    }),
    searchWeb: tool({
      description: "Search the web",
      inputSchema: z.object({ query: z.string() }),
      execute: async (args) => searchWeb(args),
    }),
  },
});

const result = await generateText({
  model: openai("gpt-4.1"),
  tools,
  toolApproval,
  prompt: "Find hotels in Lisbon and book one under budget.",
});

Already bound a run? paybond.wrapTools(run, tools, { framework: "vercel-ai" }) returns { tools, toolApproval } without reloading policy.

Next.js route handler

For a full App Router example with request-scoped bind, see Next.js agent checkout.

Production bind

const instrumented = await paybond.instrument({
  policy: "./paybond.policy.yaml",
  framework: "vercel-ai",
  tools: { /* ... */ },
});
const runtime = await instrumented.bind({ intentId, capabilityToken });
// runtime.agentTools + runtime.toolApproval → pass to generateText

Developer reference: /docs/kit/vercel-ai.