AxioRank Docs
Integrations

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/sdk

Guard 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.

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

On this page