Skip to content
tokz

Vercel AI SDK integration

Keep Vercel AI SDK steps useful as tool context grows.

Tokz integrates with the Vercel AI SDK at tool and step boundaries. The wrapper can select verbose result content before it becomes the next model input, without changing the SDK's generation contract.

ai-sdk.ts
import { generateText } from "ai";
import { withTokz } from "@tokz/ai-sdk";

const result = await withTokz({ apiKey: process.env.TOKZ_API_KEY })
  .generateText({ model, tools, prompt });

Compress where the loop grows

A prepare-step hook can make context selection explicit at the point where the next model call is assembled. That is easier to test than trimming a transcript after the fact.

Keep application-owned instructions protected

Tokz can select data context, but your application should keep system instructions, policy text, and required tool fields under its own contract.

Limitations

The wrapper does not replace Vercel AI SDK telemetry or guarantee token savings. Compare provider cache economics and Tokz credit cost for your workload.