Vercel AI SDK
Put every tool a Vercel AI SDK agent can call behind the AxioRank gateway.
The @axiorank/sdk/vercel adapter
wraps the tools object you already hand to generateText / streamText, so
every tool call is scored by AxioRank before it runs.
Install
npm install @axiorank/sdkGuard your tools
guardTools wraps each tool in a tools record; the record key is sent to AxioRank
as the tool name, so guarded calls line up with your audit log.
import { generateText, tool } from "ai";
import { openai } from "@ai-sdk/openai";
import { AxioRank } from "@axiorank/sdk";
import { guardTools } from "@axiorank/sdk/vercel";
import { z } from "zod";
const axio = new AxioRank({ apiKey: process.env.AXIORANK_API_KEY! });
const tools = guardTools(
{
deployToProd: tool({
description: "Deploy the current build to production",
parameters: z.object({ service: z.string() }),
execute: async ({ service }) => deploy(service),
}),
},
axio,
{ onDeny: "return" }, // let the model read the refusal and adapt
);
await generateText({ model: openai("gpt-4.1"), tools, prompt });guardTool(name, tool, axio, opts) wraps a single tool when you'd rather not wrap
the whole record. A tool with no execute (a client-side or provider-executed
tool) is returned unchanged.
Govern the whole model call
guardTools guards the tools an agent calls. To also inspect the prompt and
completion of every model call, wrap the model itself with the
@axiorank/ai-sdk middleware.
One wrapLanguageModel call governs generateText, streamText, and
generateObject: the prompt is inspected before it is sent, the completion is
inspected and optionally redacted before your app sees it, and proposed tool
calls are inspected before the SDK runs them.
npm install @axiorank/ai-sdk aiimport { wrapLanguageModel } from "ai";
import { openai } from "@ai-sdk/openai";
import { createAxioRankMiddleware } from "@axiorank/ai-sdk";
const model = wrapLanguageModel({
model: openai("gpt-4o"),
middleware: createAxioRankMiddleware({ apiKey: process.env.AXIORANK_API_KEY! }),
});Leave the API key off to run the detectors in-process as an advisory guard, with no signup and no network call.
Correlate a run
Pass axio.trace() instead of axio to give every call in one generateText
run a shared trace id on the gateway.
Next steps
- Framework integrations: the wrap-vs-callback model and
onDeny. - Content-inspection engine: what gets flagged.