HomeDocsAdapters › Vercel AI SDK

Vercel AI SDK Adapter

agent402-ai-sdk

Drop-in tool objects for the Vercel AI SDK. Works with streamText, generateText, and generateObject across any supported provider.

Install

npm install agent402-ai-sdk

Quick start

import { agent402Tools } from "agent402-ai-sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const { tools, execute } = await agent402Tools();

const { text, toolCalls } = await generateText({
  model: openai("gpt-4o"),
  prompt: "Hash 'hello world' with SHA-256",
  tools,
});

// Tool calls are executed automatically by the AI SDK,
// or handle them manually:
for (const call of toolCalls) {
  const result = await execute(call.toolName, call.args);
  console.log(result);
}

Configuration

OptionTypeDescription
categories string[] Filter tools by category.
slugs string[] Load only specific tools by slug.
baseUrl string Point to a self-hosted Agent402 instance.
agentKey string Private key for wallet-only (paid) tools.
// Filter tools by category.
agent402Tools({ categories: ["pdf"] })

// Load only specific tools by slug.
agent402Tools({ slugs: ["pdf-to-markdown", "extract"] })

// Point to a self-hosted Agent402 instance.
agent402Tools({ baseUrl: "https://my-agent402.example.com" })

// Private key for wallet-only (paid) tools.
agent402Tools({ agentKey: process.env.AGENT_KEY })

Works with

OpenAI (via @ai-sdk/openai) Anthropic (via @ai-sdk/anthropic) Google (via @ai-sdk/google) Mistral (via @ai-sdk/mistral) streamText generateText generateObject