All integrations
Vercel AI SDK

Use 402.report with the Vercel AI SDK

Route your Vercel AI SDK agent's HTTP through 402.report and expose its x402 spend as MCP tools — set one API key.

The Vercel AI SDK speaks MCP (@ai-sdk/mcp / experimental_createMCPClient) and accepts a custom fetch. 402.report plugs into both: expose your spend as tools, and observe the payments your agent makes.

1. Install

npm install @402report/sdk ai

Set your key as REPORT402_API_KEY (create one in the dashboard).

2. Add the spend tools

import { experimental_createMCPClient as createMCPClient, generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { aiSdkMcpTransport } from "@402report/sdk";

const mcp = await createMCPClient({
  transport: aiSdkMcpTransport({ apiKey: process.env.REPORT402_API_KEY! }),
});

const { text } = await generateText({
  model: openai("gpt-4o"),
  tools: await mcp.tools(),
  prompt: "How much have my agents paid this week, and did any payments fail?",
});

await mcp.close();

3. Observe the payments your agent makes

Route model/tool HTTP through the proxy with a drop-in fetch so every x402 challenge and payment is recorded:

import { createProxyFetch } from "@402report/sdk";
import { createOpenAI } from "@ai-sdk/openai";

const openai = createOpenAI({
  apiKey: process.env.OPENAI_API_KEY!,
  fetch: createProxyFetch({ apiKey: process.env.REPORT402_API_KEY! }),
});

402.report is non-custodial — it observes x402 activity, it never holds or settles funds.