@exalabs/convex-exa

中文文档
0.1.1发布于 2026/08/04Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 4955

Convex component for web search and content extraction with Exa

原始使用文档
文档目录14 节
  1. Quick Start
  2. 1. Install the Component
  3. 2. Configure Convex
  4. 3. Set Up Environment Variables
  5. 4. Use the Component
  6. API Reference
  7. search(ctx, args)
  8. deepSearch(ctx, args)
  9. contents(ctx, args)
  10. Requirements
  11. How It Works
  12. Development
  13. Building the Component
  14. Example App

convex-exa

Web search and content extraction for Convex applications. Search the web, pull clean page content, and return structured answers.

Quick Start

1. Install the Component

npm install @exalabs/convex-exa zod

zod is required when you pass a Zod schema to deepSearch.

2. Configure Convex

Add the component to your convex/convex.config.ts:

import { defineApp } from "convex/server";
import { v } from "convex/values";
import exa from "@exalabs/convex-exa/convex.config";

const app = defineApp({
  env: {
    EXA_API_KEY: v.string(),
  },
});

app.use(exa, {
  name: "exa",
  env: {
    EXA_API_KEY: app.env.EXA_API_KEY,
  },
});

export default app;

3. Set Up Environment Variables

Add this to your Convex Dashboard → Settings → Environment Variables:

VariableDescription
EXA_API_KEYYour Exa API key

You can also set it from the CLI: npx convex env set EXA_API_KEY <your-key>.

4. Use the Component

import { action } from "./_generated/server";
import { ExaClient } from "@exalabs/convex-exa";
import { components } from "./_generated/api";
import { z } from "zod";

const exa = new ExaClient(components.exa);

export const searchNews = action({
  handler: async (ctx) => {
    return await exa.search(ctx, {
      query: "recent llm launches",
      contents: {
        highlights: true,
        maxAgeHours: 24,
      },
    });
  },
});

export const summarizeFunding = action({
  handler: async (ctx) => {
    return await exa.deepSearch(ctx, {
      query: "recent AI startup funding announcements",
      systemPrompt: "Prefer official sources and avoid duplicate reporting.",
      schema: z.object({
        summary: z.string(),
        companies: z.array(z.string()),
      }),
    });
  },
});

export const fetchKnownPage = action({
  handler: async (ctx) => {
    return await exa.contents(ctx, {
      urls: ["https://exa.ai/docs"],
      highlights: true,
      maxAgeHours: 12,
    });
  },
});

API Reference

search(ctx, args)

Run Exa /search with type: "auto" by default. Use for general retrieval; pass nested contents when you want highlights or text on result URLs.

await exa.search(ctx, {
  query: "battery recycling policy changes in the EU",
  contents: {
    highlights: true,
  },
});

Parameters:

  • query - Search query
  • contents - Optional nested options for text, highlights, summary, maxAgeHours, etc.
  • Other fields are forwarded to the Exa search API (filters, numResults, type, etc.)

deepSearch(ctx, args)

Run Exa /search with type: "deep" by default. Use when you want structured or synthesized output.

await exa.deepSearch(ctx, {
  query: "Compare recent frontier model launches",
  schema: z.object({
    summary: z.string(),
    models: z.array(z.string()),
  }),
});

Parameters:

  • query - Search query
  • schema - Zod schema for structured output (converted to JSON Schema for Exa)
  • outputSchema - Raw JSON Schema instead of Zod
  • systemPrompt - Optional guidance for the deep search model
  • type - One of deep-lite, deep, deep-reasoning

Returns: Exa search response; structured fields follow your schema when provided


contents(ctx, args)

Fetch content for URLs you already know via Exa /contents.

await exa.contents(ctx, {
  urls: ["https://exa.ai/docs"],
  highlights: true,
  maxAgeHours: 12,
});

Parameters:

  • urls - URLs to fetch
  • text, highlights, summary - Top-level content options (not nested under contents like on /search)

Requirements

  • Exa account and API key
  • Convex 1.39.1 or later
  • zod when using schemas with deepSearch

How It Works

This component wraps the Exa API inside a Convex component. Your actions call ExaClient, which runs component actions that:

  1. Read EXA_API_KEY from component environment configuration
  2. Call Exa /search or /contents with your arguments
  3. Return typed results to your Convex action

The API key stays in Convex env—not in client-visible code.

Development

Building the Component

To build the component locally:

# Install dependencies
npm install
cd example && npm install && cd ..

# Build with Convex codegen (generates component API)
npm run build:codegen

# Or just build TypeScript
npm run build:esm

# Run tests
npm test

The component requires a Convex deployment to generate proper component API types (_generated/component.ts).

Example App

Work against a live deployment with the example app:

npm run dev

This runs the example Convex backend and rebuilds the component when src/ changes.

See example/README.md for a walkthrough of the example app, which demonstrates:

  • searchNews: Retrieve general web results based on queries.
  • deepResearch: Perform structured and schema-driven deep search.
  • fetchKnownPage: Extract contents from a specific, known URL.

These example actions highlight key parameters you’ll likely want to adjust in your own application, such as:

  • Filtering by domain
  • Including or excluding text via text filters
  • Setting the number of results to return
  • Choosing a search mode
  • Selecting a content mode (highlights, text, or summary)
  • Limiting document recency with maxAgeHours

See the Exa API Docs for full reference on the available parameters and capabilities.

版本与发布记录

@exalabs/convex-exa 共发布 2 个版本,首次发布于 2026/06/03;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.1latest2026/08/043 个月前
0.1.02026/06/035 个月前

关于 @exalabs/convex-exa 的常见问题

@exalabs/convex-exa 是什么?

Convex component for web search and content extraction with Exa

如何安装 @exalabs/convex-exa?

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

@exalabs/convex-exa 支持 TypeScript 吗?

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

@exalabs/convex-exa 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exalabs/convex-exa 可以商用吗?

@exalabs/convex-exa 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@exalabs/convex-exa 的下载量有多少?

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

@exalabs/convex-exa 还在维护吗?

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