Appearance
Firecrawl + Vercel AI SDK
Updated Feb 2026Firecrawl provides a first-class firecrawl-aisdk package for the Vercel AI SDK. Scrape, search, browse, and extract web data in your AI applications with pre-built tools.
Source: docs.firecrawl.dev/developer-guides/llm-sdks-and-frameworks/vercel-ai-sdk
Installation
bash
npm install firecrawl-aisdk ai @ai-sdk/openaiSet environment variables:
env
FIRECRAWL_API_KEY=fc-your-key
OPENAI_API_KEY=sk-your-keyProvider Agnostic
These examples use OpenAI, but Firecrawl tools work with any Vercel AI SDK provider including Anthropic, Google, Mistral, and more. See the supported providers.
Quick Start
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { scrapeTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Scrape https://firecrawl.dev and summarize what it does',
tools: { scrape: scrapeTool },
});Available Tools
js
import {
scrapeTool, // Scrape single URL
searchTool, // Search the web
browserTool, // Interactive browser sessions
agentTool, // Autonomous web agent
mapTool, // Discover URLs on a site
crawlTool, // Crawl multiple pages
batchScrapeTool, // Scrape multiple URLs
extractTool, // Extract structured data
pollTool, // Poll async jobs
statusTool, // Check job status
cancelTool, // Cancel jobs
} from 'firecrawl-aisdk';Examples
Scrape
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { scrapeTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Scrape https://firecrawl.dev and summarize what it does',
tools: { scrape: scrapeTool },
});
console.log(text);Search
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { searchTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Search for Firecrawl and summarize what you find',
tools: { search: searchTool },
});
console.log(text);Map
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { mapTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Map https://docs.firecrawl.dev and list the main sections',
tools: { map: mapTool },
});
console.log(text);Crawl (Async)
Include pollTool to check job status for async operations.
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { crawlTool, pollTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Crawl https://docs.firecrawl.dev (limit 3 pages) and summarize',
tools: { crawl: crawlTool, poll: pollTool },
});
console.log(text);Batch Scrape (Async)
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { batchScrapeTool, pollTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Scrape https://firecrawl.dev and https://docs.firecrawl.dev, then compare',
tools: { batchScrape: batchScrapeTool, poll: pollTool },
});
console.log(text);Extract (Async)
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { extractTool, pollTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Extract the main features from https://firecrawl.dev',
tools: { extract: extractTool, poll: pollTool },
});
console.log(text);Search + Scrape
Combine tools for multi-step workflows.
js
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { searchTool, scrapeTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Search for Firecrawl, scrape the top result, and explain what it does',
tools: { search: searchTool, scrape: scrapeTool },
});
console.log(text);Stream
js
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { scrapeTool } from 'firecrawl-aisdk';
const result = streamText({
model: openai('gpt-4o'),
prompt: 'Scrape https://firecrawl.dev and explain what it does',
tools: { scrape: scrapeTool },
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}Browser
Use browserTool with ToolLoopAgent for interactive web browsing -- navigating pages, clicking elements, filling forms, and extracting data.
js
import { ToolLoopAgent, stepCountIs } from 'ai';
import { openai } from '@ai-sdk/openai';
import { browserTool } from 'firecrawl-aisdk';
const { text } = await new ToolLoopAgent({
model: openai('gpt-4o'),
tools: { browserTool },
stopWhen: stepCountIs(25),
}).generate({
prompt: 'Go to https://news.ycombinator.com, get the top 3 stories.',
});
console.log(text);Agent
Use agentTool for autonomous web data gathering.
js
import { generateText, stepCountIs } from 'ai';
import { openai } from '@ai-sdk/openai';
import { agentTool, pollTool } from 'firecrawl-aisdk';
const { text } = await generateText({
model: openai('gpt-4o'),
prompt: 'Find the founders of Firecrawl, their roles, and their backgrounds',
tools: { agent: agentTool, poll: pollTool },
stopWhen: stepCountIs(10),
});
console.log(text);