npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@radiustechsystems/ai-agent-adapter-vercel-ai

v1.0.4

Published

Vercel AI SDK adapter for the Radius AI Agent Toolkit

Readme

Radius AI Agent Toolkit - Vercel AI Adapter

This adapter provides integration between the Radius AI Agent Toolkit and the Vercel AI SDK, allowing you to easily add Radius capabilities to AI agents built with the Vercel AI SDK.

This package is part of the Radius AI Agent Toolkit, which provides tools for integrating AI agents with the Radius platform.

Installation

# Install this specific package
npm install @radiustechsystems/ai-agent-adapter-vercel-ai

# Required peer dependencies
npm install @radiustechsystems/ai-agent-core
npm install ai

Prerequisites

  • Node.js >=20.12.2 <23
  • Vercel AI SDK installed in your project:
    • npm install ai @ai-sdk/openai
  • OpenAI API key (or other model provider supported by Vercel AI SDK)
  • Radius wallet setup with a funded account

Usage

import { getOnChainTools } from "@radiustechsystems/ai-agent-adapter-vercel-ai";
import { createRadiusWallet, sendETH } from "@radiustechsystems/ai-agent-wallet";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import * as dotenv from "dotenv";

// Load environment variables
dotenv.config();

// 1. Create a Radius wallet (always validate your environment variables)
const rpcUrl = process.env.RPC_PROVIDER_URL;
const privateKey = process.env.WALLET_PRIVATE_KEY;
const openaiApiKey = process.env.OPENAI_API_KEY;

if (!rpcUrl || !privateKey) {
  console.warn("WARNING: Missing required wallet environment variables");
  console.warn("RPC_PROVIDER_URL and WALLET_PRIVATE_KEY must be set");
  throw new Error("Missing wallet configuration");
}

if (!openaiApiKey) {
  console.warn("WARNING: Missing OPENAI_API_KEY environment variable");
  throw new Error("Missing OpenAI API key");
}

// Create the wallet
const wallet = await createRadiusWallet({
  rpcUrl,
  privateKey
});

// Get wallet address
const address = await wallet.getAddress();
console.log(`Wallet address: ${address}`);

// 2. Configure the tools for Vercel AI SDK
const tools = await getOnChainTools({
  wallet,
  plugins: [
    sendETH(), // Enable ETH transfers
  ]
});

// Log available tools
console.log(`Configured tools for Vercel AI SDK:`);
Object.entries(tools).forEach(([name, tool]) => {
  console.log(` - ${name}: ${tool.description}`);
});

// 3. Use the tools with Vercel AI SDK
const result = await generateText({
  model: openai("gpt-4o"),
  tools,
  maxSteps: 5, // Maximum number of tool invocations per request
  prompt: "What is my wallet address? Get the current balance of my wallet.",
  onStepFinish: (event) => {
    console.log("Step completed:", JSON.stringify(event));
  },
});

console.log("AI Response:", result.text);

If you want to include ERC20 token support, you would add:

import { erc20, USDC } from "@radiustechsystems/ai-agent-plugin-erc20";

// Then in the plugins array:
const tools = await getOnChainTools({
  wallet,
  plugins: [
    sendETH(), 
    erc20({ tokens: [USDC] }) // Add ERC20 token support
  ]
});

API Reference

getOnChainTools(options)

Creates a tool collection compatible with Vercel AI SDK that provides access to configured Radius features.

Parameters:

  • options.wallet (WalletClientBase): A Radius wallet instance
  • options.plugins (Array): Array of plugin instances to enable

Returns:

  • (Object): An object of Vercel AI SDK compatible tools that can be passed directly to the Vercel AI SDK's generateText function

Default Tools:

The getOnChainTools function automatically provides the following wallet-related tools:

  • get_address: Get the address of the wallet
  • get_chain: Get the chain of the wallet
  • get_balance: Get the balance of an address
  • sign_message: Sign a message with the wallet
  • simulate_transaction: Simulate a transaction to check if it would succeed
  • resolve_address: Resolve an ENS name to an address
  • get_transaction_status: Check the status of a transaction

Tool Structure:

Each tool follows the Vercel AI SDK tool structure:

{
  description: string;
  parameters: {
    type: "object";
    properties: Record<string, { type: string; description: string; ... }>;
    required: string[];
  };
  execute: (params: any) => Promise<any>;
}

Example:

const tools = await getOnChainTools({
  wallet,
  plugins: [
    sendETH(),
    erc20({ tokens: [USDC] })
  ]
});

Integration Examples

For examples of how to integrate this adapter with the Vercel AI SDK, see:

Troubleshooting

Error: Missing OpenAI API Key

If you encounter an error about a missing API key:

  1. Ensure you've set the OPENAI_API_KEY environment variable (or the appropriate key for your model provider)
  2. For local development, create a .env file with your API key
  3. For deployment, configure the environment variable in your hosting platform

Error: Invalid Schema for Function

If you encounter schema validation errors with complex tools:

  1. Start with simple tools like get_address and get_balance which have straightforward schemas
  2. Some complex tool schemas (especially those with array parameters) may need additional validation
  3. For complex parameters, consider creating a simplified version of the tool for use with the Vercel AI SDK
  4. Update to the latest version of the adapter, as schema compatibility issues may be fixed

Error: Tool Execution Failed

If a tool execution fails:

  1. Check that the wallet has sufficient funds for the operation
  2. Verify that the parameters match the expected format for the tool
  3. Check your network connectivity to the RPC provider
  4. Ensure your wallet private key has access to perform the requested operation

Error: Invalid Vercel AI SDK Version

The Vercel AI SDK is actively developed and its API may change:

  1. Check the version compatibility between the Vercel AI SDK and this adapter
  2. Update to the latest version of both packages
  3. Check the Vercel AI SDK documentation for any breaking changes

Related Packages

Resources

Contributing

Please see the Contributing Guide for detailed information about contributing to this toolkit.

License

This project is licensed under the MIT License.