For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Fork this repoGet a demo
  • Docs
    • Welcome
    • Quickstart
    • Concepts
    • Search
    • MCP Server
    • CLI
    • Agent Skills
    • Connect
    • Add New Connector
    • Rate Limits
      • LlamaIndex
      • Vercel AI SDK
      • Google Antigravity
      • Pipedream
      • Sim
  • API Reference
LogoLogo
Fork this repoGet a demo
On this page
  • Prerequisites
  • Installation
  • Quick Start
  • Configuration
  • Configuration Options
  • Environment Variables
  • TypeScript Support
  • Result Types
  • Learn More
DocsFramework Integrations

Vercel AI SDK

Add Airweave search to your Vercel AI SDK agents with a single function call.
Was this page helpful?
Edit this page
Previous

Google Antigravity

Airweave is available natively in the Antigravity MCP Store, giving your coding agents the ability to search and retrieve context across all your apps and databases.
Next
Built with

The @airweave/vercel-ai-sdk package currently uses the legacy search API. It will be updated to support the new three-tier search API (instant, classic, agentic) in a future release.

The @airweave/vercel-ai-sdk package provides an airweaveSearch tool that integrates seamlessly with the Vercel AI SDK.

Prerequisites

Before you start you’ll need:

  • A collection with data: at least one source connection must have completed its initial sync. See the Quickstart if you need to set this up.
  • An API key: Create one in the Airweave dashboard under API Keys.

Installation

$npm install ai @ai-sdk/openai @airweave/vercel-ai-sdk

Quick Start

1import { generateText } from 'ai';
2import { openai } from '@ai-sdk/openai';
3import { airweaveSearch } from '@airweave/vercel-ai-sdk';
4
5const { text } = await generateText({
6 model: openai('gpt-4o'),
7 prompt: 'What were the key decisions from last week?',
8 tools: {
9 search: airweaveSearch({
10 defaultCollection: 'my-knowledge-base',
11 }),
12 },
13 maxSteps: 3,
14});
15
16console.log(text);

Configuration

1airweaveSearch({
2 // API key (defaults to AIRWEAVE_API_KEY env var)
3 apiKey: 'your-api-key',
4
5 // Default collection to search
6 defaultCollection: 'my-collection',
7
8 // Max results per search (default: 10)
9 defaultLimit: 20,
10
11 // Generate AI answer from results (default: false)
12 generateAnswer: true,
13
14 // Query expansion for better recall (default: true)
15 expandQuery: true,
16
17 // Rerank for relevance (default: true)
18 rerank: true,
19
20 // Base URL for self-hosted instances
21 baseUrl: 'https://your-instance.airweave.ai',
22});

Configuration Options

OptionTypeDefaultDescription
apiKeystringAIRWEAVE_API_KEY envYour Airweave API key
baseUrlstring-Base URL for self-hosted instances
defaultCollectionstring-Default collection readable ID to search
defaultLimitnumber10Default maximum number of results
generateAnswerbooleanfalseGenerate an AI-powered answer from results
expandQuerybooleantrueExpand query with variations for better recall
rerankbooleantrueRerank results for improved relevance

Environment Variables

Set your API key as an environment variable. You can copy your API key from the Airweave dashboard.

$AIRWEAVE_API_KEY=your-api-key

TypeScript Support

Full TypeScript types are included:

1import {
2 airweaveSearch,
3 AirweaveSearchOptions,
4 AirweaveSearchResult,
5 AirweaveSearchResultItem
6} from '@airweave/vercel-ai-sdk';
7
8const config: AirweaveSearchOptions = {
9 defaultCollection: 'my-collection',
10 defaultLimit: 10,
11};
12
13const search = airweaveSearch(config);

Result Types

Each search result includes:

1interface AirweaveSearchResultItem {
2 id: string; // Entity ID
3 score: number; // Relevance score
4 payload: {
5 entity_id?: string;
6 name?: string;
7 created_at?: string;
8 textual_representation?: string;
9 breadcrumbs?: AirweaveBreadcrumb[];
10 airweave_system_metadata?: {
11 source_name?: string; // e.g., "notion", "slack"
12 entity_type?: string; // e.g., "NotionPageEntity"
13 sync_id?: string;
14 chunk_index?: number;
15 };
16 // Plus source-specific fields
17 };
18}

Learn More

  • Vercel AI SDK Documentation
  • Airweave on Vercel Tool Registry
  • Airweave GitHub