Documentation Index
Fetch the complete documentation index at: https://student-213fb9fc.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
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);
非同期処理です。ジョブのステータスを確認するには 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 ブラウジングには、browserTool を ToolLoopAgent と組み合わせて使用します。エージェントはページ遷移、要素のクリック、フォームへの入力、データの抽出を行うことができます。
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);
検索を起点に、その後インタラクティブにブラウジングしていくワークフローには、browserTool と searchTool を組み合わせて使用します。
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);