Integrations
Loading
Loading
Integrations
Vercel AI SDK handles streaming and model access. Loop Engine governs when and whether model-requested tool actions are authorized. Use Vercel AI SDK for model execution; use Loop Engine for guard enforcement, actor attribution, and audit trails.
Install
1npm install @loop-engine/adapter-vercel-ai aiWrap a tool with governance
1import { z } from "zod";2import { streamText, tool } from "ai";3import { actorId, type ActorRef } from "@loop-engine/core";4import { wrapTool, type CoreTool } from "@loop-engine/adapter-vercel-ai";5 6const baseTool = tool({7 description: "Submit purchase order",8 inputSchema: z.object({ vendor: z.string(), amount: z.number() }),9 execute: async ({ vendor, amount }) => ({ orderId: "PO-0042", vendor, amount })10});11const submitPurchaseOrder = wrapTool(baseTool as unknown as CoreTool<{ vendor: string; amount: number }, { orderId: string; vendor: string; amount: number }>, {12 loopDefinition: purchaseOrderLoop,13 engine,14 actor: {15 type: "ai-agent",16 id: actorId("ai:vercel-tool"),17 modelId: "gpt-4o",18 provider: "openai"19 } as ActorRef,20 requiresApproval: (input) => input.amount > 500021});Run with streaming
1await streamText({2 model: openai("gpt-4o"),3 tools: { submitPurchaseOrder },4 prompt: "Submit a PO to Acme Medical for $9,200"5});