@exalabs/ai-sdk

中文文档
2.1.0发布于 2026/06/06MITTypeScriptESM + CJS构建来源已验证近 30 天下载 17.5万

Exa web search tool for Vercel AI SDK

原始使用文档
文档目录9 节
  1. Table of Contents
  2. Installation
  3. Quick Start
  4. Setup
  5. Example
  6. All Options
  7. TypeScript Support
  8. Links
  9. License

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);

License

MIT

版本与发布记录

@exalabs/ai-sdk 共发布 6 个版本,首次发布于 2025/11/11;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.0latest2026/06/065 个月前
2.0.12026/03/237 个月前
2.0.02026/03/177 个月前
1.0.52025/12/0211 个月前
1.0.42025/11/121 年前
1.0.22025/11/111 年前

关于 @exalabs/ai-sdk 的常见问题

@exalabs/ai-sdk 是什么?

Exa web search tool for Vercel AI SDK

如何安装 @exalabs/ai-sdk?

在项目目录运行 npm install @exalabs/ai-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ai(^6.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@exalabs/ai-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@exalabs/ai-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@exalabs/ai-sdk 可以商用吗?

@exalabs/ai-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exalabs/ai-sdk 的下载量有多少?

根据 npm 官方下载统计,@exalabs/ai-sdk 在 2026/10/14 – 2026/11/12 这 30 天内被下载 174,734 次,日均约 5,824 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exalabs/ai-sdk 还在维护吗?

最新版本 2.1.0 发布于 2026/06/06(5 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 4 个;首次发布于 2025/11/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。