How to Integrate Wigolo with Vercel AI SDK for Edge-Friendly Tool Usage

Wigolo provides LLM-agnostic tools that integrate with the Vercel AI SDK through a thin client wrapper, enabling search, fetch, and extract operations to run efficiently on Vercel's edge network without Node-specific dependencies.

Wigolo is an open-source toolkit providing LLM-agnostic utilities for data acquisition and transformation. When you integrate wigolo with Vercel AI SDK for edge-friendly tool usage, you unlock low-latency AI tool execution on Vercel's Edge Network without the overhead of traditional server processes. The integration leverages pure async functions that bypass Node.js-specific APIs, making it ideal for lightweight edge deployments according to the KnockOutEZ/wigolo source code.

Understanding the Integration Architecture

The integration between Wigolo and the Vercel AI SDK follows a three-layer architecture that separates tool logic from platform-specific adapters.

Core Tool Implementations

The foundation resides in src/tools.ts, which houses the pure async functions powering Wigolo's capabilities. These functions handle search, fetch, and extract operations using only web-standard APIs. Because they contain no Node-specific dependencies, they execute safely within Vercel's lightweight JavaScript edge runtime.

The Client Wrapper

src/client.ts imports the individual tool implementations and re-exports them under a unified wigolo object. This file creates the createVercelTool schema mapper, which transforms Wigolo's typed request/response shapes into the format expected by Vercel's AI SDK. The client serves as a façade that maintains type safety while adapting to platform conventions.

Vercel SDK Glue Layer

The entry point at src/index.ts exposes createClient and run utilities. The createClient function builds a Vercel-compatible ToolDefinition map from the Wigolo client, while the run helper executes selected tools and formats results for the edge runtime. This layer handles serialization and response streaming automatically.

Step-by-Step Implementation Guide

Follow these steps to deploy Wigolo tools on Vercel's edge network.

Install the Package

Add the Wigolo Vercel AI SDK package to your project:

npm i @wigolo/vercel-ai-sdk

Create the Edge Function

Create a new route file at app/api/wigolo/route.ts (or your framework's equivalent). Import createClient and run from the package, then initialize the client with your preferred model configuration:

import { createClient, run } from '@wigolo/vercel-ai-sdk';

const wigolo = createClient({ model: 'gpt-4o-mini' });

export const GET = async (req: Request) => {
  const url = new URL(req.url);
  const query = url.searchParams.get('q') ?? '';

  const result = await run(wigolo, 'search', { query });
  return new Response(JSON.stringify(result), { status: 200 });
};

Execute Tools on the Edge

Invoke specific tools using the run helper with typed parameters:

  • Search: run(wigolo, 'search', { query }) returns ranked URLs
  • Fetch: run(wigolo, 'fetch', { url }) streams content with politeness checks
  • Extract: run(wigolo, 'extract', { url, selector }) returns DOM snippets

All calls return standardized response shapes defined in src/types.ts, ensuring consistency across different tool types.

Practical Edge Function Examples

The repository includes working examples in examples/vercel-ai-sdk-tools/tools.ts that demonstrate real-world usage patterns:

import { createClient, run } from '@wigolo/vercel-ai-sdk';

const wigolo = createClient({ model: 'claude-3.5-sonnet' });

export async function edgeSearch(query: string) {
  return await run(wigolo, 'search', { query });
}

export async function edgeFetch(url: string) {
  return await run(wigolo, 'fetch', { url });
}

export async function edgeExtract(url: string, selector: string) {
  return await run(wigolo, 'extract', { url, selector });
}

These functions run directly on Vercel's edge nodes, minimizing latency by processing requests geographically close to users.

Summary

  • Wigolo tools in src/tools.ts provide pure async implementations of search, fetch, and extract operations without Node.js dependencies
  • The client wrapper in src/client.ts adapts these tools to Vercel AI SDK conventions through the createVercelTool schema
  • Entry point utilities in src/index.ts expose createClient and run for seamless edge deployment
  • All tool executions occur on Vercel's edge network, eliminating cold starts and reducing latency compared to traditional serverless functions
  • The integration maintains type safety through shared definitions in src/types.ts while supporting multiple LLM providers

Frequently Asked Questions

What makes Wigolo compatible with Vercel's edge runtime?

Wigolo's tool implementations use only web-standard APIs and pure async functions without Node.js-specific modules like fs or http. This allows the code to execute on Vercel's lightweight JavaScript engine running on the Edge Network.

How do I add custom tools to the Wigolo Vercel integration?

Add new tool implementations to src/tools.ts following the existing async function pattern, then register them in src/client.ts. The createClient function in src/index.ts will automatically include them in the exported tool map without requiring changes to the edge function code.

Can I use Wigolo with different LLM providers on Vercel?

Yes. The createClient function accepts a model parameter (e.g., gpt-4o-mini or claude-3.5-sonnet) that configures the client for your preferred provider. The tool implementations remain LLM-agnostic, while the Vercel AI SDK handles provider-specific formatting.

Where can I find working examples of this integration?

Reference the examples/vercel-ai-sdk-tools/tools.ts file in the KnockOutEZ/wigolo repository for complete, copy-ready implementations of edge functions using search, fetch, and extract tools.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →