Home/Tools/@exalabs/ai-sdk

webSearch

@exalabs/ai-sdk

Search the web for code docs, current information, news, articles, and content. Use this when you need up-to-date information or facts from the internet. Performs real-time web searches and can scrape content from specific URLs.

by Exa

search
v1.0.5
MIT

Interactive Playground

Test @exalabs/ai-sdk (webSearch) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @exalabs/ai-sdk
pnpm add @exalabs/ai-sdk
yarn add @exalabs/ai-sdk
bun add @exalabs/ai-sdk
deno add npm:@exalabs/ai-sdk

2. Import the tool

import { webSearch } from '@exalabs/ai-sdk';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { webSearch } from '@exalabs/ai-sdk';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { webSearch },
  prompt: 'Your prompt here...',
});

console.log(result.text);

AI Agent Integration

How AI agents can use this tool

Use Case

Use when you need current information, news, research papers, or web content

Limitations

Requires API key. Rate limits apply based on plan.

Examples

  • Find latest AI developments
  • Search for technical documentation
  • Research current events

Signature

(query: string) => Promise<unknown>

Tags

ai
ai-sdk
articles
code
content
current
date
docs
exa
information
news
sdk
search
vercel
web
web-search

Parameters

Available configuration options

Auto-extracted
query
Required
Type: string

The web search query - be specific and clear about what you're looking for

Schema extracted: 3/1/2026, 1:19:28 AM

README

Exa AI SDK

Exa is a Websearch API. Add Exa websearch tool to your LLMs in just a few lines of code. Giving your AI apps websearch capabilites. Works with AI SDK by Vercel.

Table of Contents

Installation

npm install @exalabs/ai-sdk

Quick Start

import { generateText, stepCountIs } from "ai";
import { webSearch } from "@exalabs/ai-sdk";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai('gpt-5-nano'),
  prompt: 'Tell me the latest developments in AI',
  system: "Only use web search once per turn. Answer based on the information you have.",
  tools: {
    webSearch: webSearch(),
  },
  stopWhen: stepCountIs(3),
});

console.log(text);

Get your API key from the Exa Dashboard.

Defaults when you use webSearch():

  • Type: auto (best search)
  • Results: 10
  • Text: 3000 characters per result
  • Livecrawl: fallback (fresh content when needed)

Setup

  1. Get your API key from the Exa Dashboard
  2. Add it to your .env file:
EXA_API_KEY=your-api-key-here

That's it! The package reads it automatically.

Example

Here's a full-featured example combining the most useful search settings:

const { text } = await generateText({
  model: openai('gpt-5-nano'),
  prompt: 'Find the top AI companies in Europe founded after 2018',
  tools: {
    webSearch: webSearch({
      type: "auto",                           // intelligent hybrid search
      numResults: 6,                          // return up to 6 results
      category: "company",                    // focus on companies
      contents: {
        text: { maxCharacters: 1000 },        // get up to 1000 chars per result
        livecrawl: "preferred",               // always get fresh content if possible
        summary: true,                        // return an AI-generated summary for each result
      },
    }),
  },
  stopWhen: stepCountIs(5),
});

console.log(text);

All Options

webSearch({
  // Search settings
  type: "auto",           // "auto", "keyword", "neural", "fast", "deep"
  category: "news",       // "company", "research paper", "news", "pdf", 
                          // "github", "personal site", "linkedin profile", "financial report"
  numResults: 10,
  
  // Filter by domain
  includeDomains: ["linkedin.com", "github.com"],
  excludeDomains: ["wikipedia.com"],
  
  // Filter by date (ISO 8601)
  startPublishedDate: "2025-01-01T00:00:00.000Z",
  endPublishedDate: "2025-12-31T23:59:59.999Z",
  startCrawlDate: "2025-01-01T00:00:00.000Z",
  endCrawlDate: "2025-12-31T23:59:59.999Z",
  
  // Filter by text
  includeText: ["AI"],    // Must contain
  excludeText: ["spam"],  // Must not contain
  
  // Location
  userLocation: "US",     // Two-letter country code
  
  // Content options
  contents: {
    text: {
      maxCharacters: 1000,
      includeHtmlTags: false,
    },
    summary: {
      query: "Main points",
    },
    livecrawl: "fallback",     // "never", "fallback", "always", "preferred"
    livecrawlTimeout: 10000,
    subpages: 5,
    subpageTarget: "about",
    extras: {
      links: 5,
      imageLinks: 3,
    },
  },
})

TypeScript Support

Full TypeScript types included:

import { webSearch, ExaSearchConfig, ExaSearchResult } from "@exalabs/ai-sdk";

const config: ExaSearchConfig = {
  numResults: 10,
  type: "auto",
};

const search = webSearch(config);

Links

License

MIT

Statistics

Downloads/month

48,610

GitHub Stars

0

Quality Score

90%

Bundle Size

NPM Keywords

exa
search
ai-sdk
vercel
web-search
ai
tools

Maintainers

theishangoswami(ishan@exa.ai)

Frameworks

vercel-ai