メインコンテンツへスキップ
Vercel AI SDK 向け Firecrawl ツール。AI アプリケーション向けの Web スクレイピング、検索、ブラウジング、データ抽出。

インストール

npm install firecrawl-aisdk ai @ai-sdk/openai
環境変数の設定:
FIRECRAWL_API_KEY=fc-your-key
OPENAI_API_KEY=sk-your-key
これらの例では OpenAI を使用していますが、Firecrawl のツールは Anthropic、Google、Mistral などを含む、すべての Vercel AI SDK プロバイダーで動作します。サポートされているプロバイダーの完全な一覧を参照してください。

クイックスタート

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { scrapeTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'https://firecrawl.dev をスクレイピングして、その機能を要約してください',
  tools: { scrape: scrapeTool },
});

利用可能なツール

import {
  scrapeTool,         // 単一URLをスクレイピング
  searchTool,         // Web検索
  browserTool,        // インタラクティブなブラウザセッション
  agentTool,          // 自律型Webエージェント
  mapTool,            // サイト上のURLを検出
  crawlTool,          // 複数ページをクロール
  batchScrapeTool,    // 複数URLをスクレイピング
  extractTool,        // 構造化データを抽出
  pollTool,           // 非同期ジョブをポーリング
  statusTool,         // ジョブステータスを確認
  cancelTool,         // ジョブをキャンセル
} from 'firecrawl-aisdk';

使用例

スクレイピング

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { scrapeTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'https://firecrawl.dev をスクレイピングして、何をするものか要約してください',
  tools: { scrape: scrapeTool },
});

console.log(text);
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { searchTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'Search for Firecrawl and summarize what you find',
  tools: { search: searchTool },
});

console.log(text);

マップ

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { mapTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'https://docs.firecrawl.dev をマップして主要なセクションをリストアップしてください',
  tools: { map: mapTool },
});

console.log(text);

Crawl

非同期処理です。ジョブのステータスを確認するには pollTool を含めてください。
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { crawlTool, pollTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'https://docs.firecrawl.dev をクロール(3ページまで)して要約',
  tools: { crawl: crawlTool, poll: pollTool },
});

console.log(text);

バッチスクレイピング

非同期で実行されます。ジョブのステータスを確認するには pollTool を含めてください。
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { batchScrapeTool, pollTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'Scrape https://firecrawl.dev and https://docs.firecrawl.dev, then compare',
  tools: { batchScrape: batchScrapeTool, poll: pollTool },
});

console.log(text);

抽出

これは非同期処理です。ジョブのステータスを確認するには pollTool を指定してください。
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { extractTool, pollTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'https://firecrawl.dev から主な機能を抽出',
  tools: { extract: extractTool, poll: pollTool },
});

console.log(text);

検索 + スクレイピング

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { searchTool, scrapeTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'Search for Firecrawl, scrape the top result, and explain what it does',
  tools: { search: searchTool, scrape: scrapeTool },
});

console.log(text);

ストリーミング

import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { scrapeTool } from 'firecrawl-aisdk';

const result = streamText({
  model: openai('gpt-5-mini'),
  prompt: 'https://firecrawl.dev をスクレイピングして、それが何をするものか説明してください',
  tools: { scrape: scrapeTool },
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

ブラウザ

インタラクティブな Web ブラウジングには、browserToolToolLoopAgent と組み合わせて使用します。エージェントはページ遷移、要素のクリック、フォームへの入力、データの抽出を行うことができます。
import { ToolLoopAgent, stepCountIs } from 'ai';
import { openai } from '@ai-sdk/openai';
import { browserTool } from 'firecrawl-aisdk';

const { text } = await new ToolLoopAgent({
  model: openai('gpt-5-mini'),
  tools: { browserTool },
  stopWhen: stepCountIs(25),
}).generate({
  prompt: 'Go to https://news.ycombinator.com, get the top 3 stories with their titles, points, and links.',
});

console.log(text);
検索を起点に、その後インタラクティブにブラウジングしていくワークフローには、browserToolsearchTool を組み合わせて使用します。
import { ToolLoopAgent, stepCountIs } from 'ai';
import { openai } from '@ai-sdk/openai';
import { browserTool, searchTool } from 'firecrawl-aisdk';

const { text } = await new ToolLoopAgent({
  model: openai('gpt-5-mini'),
  tools: { browserTool, searchTool },
  stopWhen: stepCountIs(25),
}).generate({
  prompt: '今週のトップAI論文を検索し、閲覧して、主要な知見を要約する。',
});

console.log(text);

エージェント

自律的な Web データ収集には agentTool を使用します。エージェントが自動で検索・ページ遷移・データ抽出を行います。
import { generateText, stepCountIs } from 'ai';
import { openai } from '@ai-sdk/openai';
import { agentTool, pollTool } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: openai('gpt-5-mini'),
  prompt: 'Find the founders of Firecrawl, their roles, and their backgrounds',
  tools: { agent: agentTool, poll: pollTool },
  stopWhen: stepCountIs(10),
});

console.log(text);