Vercel AI + Grantex

Authorization for Vercel AI SDK

Add scoped authorization to configured Vercel AI SDK tools with JWT verification, optional audit wrappers, and centrally managed grant state.

The Problem

Without Grantex

Your Vercel AI tools run with full access. Users can't see or control what the AI does on their behalf. No audit trail, no revocation.

With Grantex

Each configured protected tool call can require a scoped JWT. The host obtains grants, wrapped tools enforce them, and optional callbacks can record selected actions.

How Grantex Works with Vercel AI SDK

Install the integration

npm install @grantex/vercel-ai — TypeScript-native integration for Vercel AI SDK.

Define authorized tools

Wrap your AI SDK tools with Grantex scope requirements.

User consents

Request specific scopes through the application's configured authorization flow before protected tools run.

Configured wrappers verify

Each configured tool wrapper verifies the grant and required scope before execution.

Audit Support

Wrap authorized tools with withAuditLogging when tool-level audit records are required.

Quick Start

npm install @grantex/vercel-ai @grantex/sdk
import { createGrantexTool } from '@grantex/vercel-ai';
import { z } from 'zod';

const search = createGrantexTool({
  name: 'search_flights',
  description: 'Search available flights',
  parameters: z.object({ destination: z.string() }),
  grantToken: token,
  requiredScope: 'flights:read',
  execute: async ({ destination }) => searchFlights(destination),
});

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { search },
  prompt: 'Search for flights to Bengaluru',
});

Why Grantex for Vercel AI SDK

Vercel AI SDK Native

Returns a standard tool for the documented generateText and streamText integrations. Validate other AI SDK versions and tool patterns in your application.

TypeScript First

TypeScript types validate adapter configuration; authorization is enforced at runtime.

Runtime Compatible

Returns a standard AI SDK tool and verifies the grant token before each execution.

Streaming Support

The wrapped tool checks authorization before its execution. Streaming lifecycle and backpressure remain the host application's responsibility.

Multi-Step Flows

Authorize multi-step AI workflows where each step requires different scopes.

Next.js Ready

Integrate with a trusted Next.js server boundary and keep grant tokens out of client-side code.

Verification, revocation, and audit boundary

This integration enforces authorization only where its wrapper or middleware is installed. Local JWT verification checks signatures and claims after JWKS retrieval; it does not prove current revocation unless the verifier performs an online state check or synchronizes revocation data.

Token verification does not create a consent record or prove that a tool executed. Use the configured authorization flow for grant decisions and add an audit integration at the execution boundary when action records are required.

Ready to secure your Vercel AI agents?

Follow the integration guide and verify the package version before deployment. Apache 2.0.