Development · Tip

Minimal Web-Connected AI Agent in TypeScript

TypeScript snippet to build a web-searching agent using Vercel AI SDK and Exa

A concise code recipe demonstrating how to wire an LLM to live web search using Vercel AI SDK and the Agentic Exa integration. It serves as a minimal boilerplate for building tool-calling agents in TypeScript with minimal configuration.

How it works

Full code shown in the screenshot:

import "dotenv/config";

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

import { ExaClient } from "@agentic/exa";

import { generateText } from "ai";

import { createAISDKTools } from "@agentic/ai-sdk";

async function main() {

const exa = new ExaClient();

const result = await generateText({

model: openai("gpt-4o-2024-05-13"),

tools: createAISDKTools(exa),

prompt: "What is founder mode and why is everyone talking about it?",

maxToolRoundtrips: 2,

});

console.log(result.text);

}

main().catch(console.error);

Stack: Vercel AI SDK (@ai-sdk/openai, ai), Exa (@agentic/exa), agentic (@agentic/ai-sdk by @transitive_bs).

What it's for

  • Bootstrap a web-browsing AI agent in TypeScript
  • Integrate Exa search tools into the Vercel AI SDK
  • Reference minimal tool-calling setup with generateText

Key points

  • Uses Vercel AI SDK generateText with maxToolRoundtrips
  • Integrates ExaClient via @agentic/exa for real-time web querying
  • Uses createAISDKTools from @agentic/ai-sdk to automatically adapt client methods into model tools
  • Configured for OpenAI GPT-4o with minimal boilerplate

Pricing

Free

Details

Type
Tip
Category
Development
Topic
AI Agents
Open source
Yes
Platforms
Code library
For
TypeScript and Node.js developers building AI agents
Alternative to
LangChain, LlamaIndex
Tags
typescript, ai agents, vercel ai sdk, exa, openai, code snippet

Why it was saved

  • @nicoalbanese10, 2 September 2024: A copy-paste starting point for tool-calling agents with web search.

Compare

Related

  • Skills.sh

    Open directory and CLI for discovering and installing AI agent skills

  • Odin AI

    Enterprise platform to build autonomous AI agents and automated business workflows.

  • ai-agent-cognitivedriftt

    Starter repository for building an autonomous social AI agent with Eliza

  • Botpress

    AI agent and chatbot platform for automated customer support and workflows.

  • Browser Use Box

    Always-on cloud agent box with preinstalled browser and Telegram interface

  • Browser Use WebUI

    Open-source graphical interface for running autonomous AI browser agents locally.

All 21 in AI Agents →

Updated