> ## Documentation Index
> Fetch the complete documentation index at: https://student-213fb9fc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

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

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

<div id="install">
  ## インストール
</div>

```bash theme={null}
npm install firecrawl-aisdk ai @ai-sdk/openai
```

環境変数の設定：

```bash theme={null}
FIRECRAWL_API_KEY=fc-your-key
OPENAI_API_KEY=sk-your-key
```

<Note>
  これらの例では OpenAI を使用していますが、Firecrawl のツールは Anthropic、Google、Mistral などを含む、すべての Vercel AI SDK プロバイダーで動作します。サポートされているプロバイダーの[完全な一覧](https://ai-sdk.dev/providers/ai-sdk-providers)を参照してください。
</Note>

<div id="quick-start">
  ## クイックスタート
</div>

```typescript theme={null}
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 },
});
```

<div id="available-tools">
  ## 利用可能なツール
</div>

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

<div id="examples">
  ## 使用例
</div>

<div id="scrape">
  ### スクレイピング
</div>

```typescript theme={null}
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);
```

<div id="search">
  ### 検索
</div>

```typescript theme={null}
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);
```

<div id="map">
  ### マップ
</div>

```typescript theme={null}
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);
```

<div id="crawl">
  ### Crawl
</div>

非同期処理です。ジョブのステータスを確認するには `pollTool` を含めてください。

```typescript theme={null}
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);
```

<div id="batch-scrape">
  ### バッチスクレイピング
</div>

非同期で実行されます。ジョブのステータスを確認するには `pollTool` を含めてください。

```typescript theme={null}
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);
```

<div id="extract">
  ### 抽出
</div>

これは非同期処理です。ジョブのステータスを確認するには `pollTool` を指定してください。

```typescript theme={null}
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);
```

<div id="search-scrape">
  ### 検索 + スクレイピング
</div>

```typescript theme={null}
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);
```

<div id="stream">
  ### ストリーミング
</div>

```typescript theme={null}
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);
}
```

<div id="browser">
  ### ブラウザ
</div>

インタラクティブな Web ブラウジングには、`browserTool` を `ToolLoopAgent` と組み合わせて使用します。エージェントはページ遷移、要素のクリック、フォームへの入力、データの抽出を行うことができます。

```typescript theme={null}
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);
```

<div id="browser-search">
  ### Browser + Search
</div>

検索を起点に、その後インタラクティブにブラウジングしていくワークフローには、`browserTool` と `searchTool` を組み合わせて使用します。

```typescript theme={null}
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);
```

<div id="agent">
  ### エージェント
</div>

自律的な Web データ収集には `agentTool` を使用します。エージェントが自動で検索・ページ遷移・データ抽出を行います。

```typescript theme={null}
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);
```
