> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl-claude-eager-dijkstra-ul56gh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Outils Firecrawl pour Vercel AI SDK. Web scraping, recherche, Interact et crawl pour les applications d'IA.

Outils Firecrawl pour Vercel AI SDK. Effectuez des recherches, faites du scraping, Interact avec des pages et effectuez un crawl du web dans vos applications d'IA."

<h2 id="install">
  Installation
</h2>

```bash theme={null}
npm install firecrawl-aisdk ai
```

Configurez les variables d'environnement :

```bash theme={null}
FIRECRAWL_API_KEY=fc-your-key       # https://firecrawl.dev
AI_GATEWAY_API_KEY=your-key         # https://vercel.com/ai-gateway
```

<Note>
  Ces exemples utilisent le format de modèle en chaîne de caractères du [Vercel AI Gateway](https://vercel.com/ai-gateway), mais les outils Firecrawl fonctionnent avec n'importe quel fournisseur de SDK d'IA. Vous pouvez également utiliser des imports de fournisseur comme `anthropic('claude-sonnet-4-5-20250514')` depuis `@ai-sdk/anthropic`.
</Note>

<h2 id="quick-start">
  Démarrage rapide
</h2>

`FirecrawlTools()` inclut `search`, `scrape` et `interact` par défaut.

```typescript theme={null}
import { generateText, stepCountIs } from 'ai';
import { FirecrawlTools } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  tools: FirecrawlTools(),
  stopWhen: stepCountIs(30),
  prompt: `
    1. Use interact on Hacker News to identify the top story
    2. Search for other perspectives on the same topic
    3. Scrape the most relevant pages you found
    4. Summarize everything you found
  `,
});
```

<h2 id="firecrawltools">
  FirecrawlTools
</h2>

`FirecrawlTools()` vous fournit les outils par défaut ainsi qu’un `systemPrompt` généré automatiquement, que vous pouvez transmettre à `generateText`.

```typescript theme={null}
import { generateText, stepCountIs } from 'ai';
import { FirecrawlTools } from 'firecrawl-aisdk';

const tools = FirecrawlTools();

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  system: `${tools.systemPrompt}\n\nAnswer with citations when possible.`,
  tools,
  stopWhen: stepCountIs(20),
  prompt: 'Find the current Firecrawl pricing page and explain the available plans.',
});
```

Vous pouvez personnaliser les paramètres par défaut, activer les outils asynchrones ou désactiver certains outils :

```typescript theme={null}
const tools = FirecrawlTools({
  search: { limit: 5 },
  scrape: { formats: ['markdown'], onlyMainContent: true },
  interact: { profile: { name: 'my-session', saveChanges: true } },
  crawl: true,
  agent: true,
});
```

```typescript theme={null}
// Désactiver interact, conserver search + scrape
FirecrawlTools({ interact: false });

// Activer la compatibilité Browser dépréciée
FirecrawlTools({ browser: {} });

// Inclure tous les outils disponibles
FirecrawlTools({ all: true });
```

Pour faire du scraping afin de répondre à une question sur une page, utilisez le format `question` :

```typescript theme={null}
formats: [{ type: 'question', question: 'What does this page say about pricing and rate limits?' }]
```

Utilisez `formats: ['markdown']` uniquement si vous avez besoin de tout le contenu de la page.

<h2 id="individual-tools">
  Outils individuels
</h2>

Chaque outil peut être utilisé directement ou appelé en lui passant des options :

```typescript theme={null}
import { generateText } from 'ai';
import { scrape, search } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Search for Firecrawl, then scrape the most relevant result.',
  tools: { search, scrape },
});

const customScrape = scrape({ apiKey: 'fc-custom-key', apiUrl: 'https://api.firecrawl.dev' });
```

<h3 id="search-scrape">
  Recherche + Scraping
</h3>

```typescript theme={null}
import { generateText } from 'ai';
import { search, scrape } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Recherche Firecrawl, scrape le premier résultat officiel et explique ce que ça fait.',
  tools: { search, scrape },
});
```

<h3 id="map">
  Cartographie
</h3>

```typescript theme={null}
import { generateText } from 'ai';
import { map } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Map https://docs.firecrawl.dev and list the main sections.',
  tools: { map },
});
```

<h3 id="stream">
  Streaming
</h3>

```typescript theme={null}
import { streamText, stepCountIs } from 'ai';
import { scrape } from 'firecrawl-aisdk';

const result = streamText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'What is the first 100 words of firecrawl.dev?',
  tools: { scrape },
  stopWhen: stepCountIs(3),
});

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

await result.fullStream;
```

<h2 id="interact">
  Interact
</h2>

`interact()` crée une session interactive basée sur le scraping. Appelez `start(url)` pour initialiser une session et obtenir une URL de vue en direct, puis laissez le modèle réutiliser cette session via l’outil `interact`.

```typescript theme={null}
import { generateText, stepCountIs } from 'ai';
import { interact, search } from 'firecrawl-aisdk';

const interactTool = interact();
console.log('Live view:', await interactTool.start('https://news.ycombinator.com'));

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  tools: { interact: interactTool, search },
  stopWhen: stepCountIs(25),
  prompt: 'Use interact on the current Hacker News session, find the top story, then search for more context.',
});

await interactTool.close();
```

Si vous avez besoin de l’URL de la vue en direct après le démarrage, utilisez `interactTool.interactiveLiveViewUrl`.

Réutilisez l’état du navigateur d’une session à l’autre avec des profils :

```typescript theme={null}
const interactTool = interact({
  profile: { name: 'my-session', saveChanges: true },
});
```

`browser()` est déprécié. Préférez `interact()`.

<h2 id="async-tools">
  Outils asynchrones
</h2>

Crawl, extraction par lot et agent renvoient un ID de tâche. Associez-les à `poll`.

<h3 id="crawl">
  Crawl
</h3>

```typescript theme={null}
import { generateText } from 'ai';
import { crawl, poll } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Crawl https://docs.firecrawl.dev (limit 3 pages) and summarize.',
  tools: { crawl, poll },
});
```

<h3 id="batch-scrape">
  Extraction par lot
</h3>

```typescript theme={null}
import { generateText } from 'ai';
import { batchScrape, poll } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Scrape https://firecrawl.dev and https://docs.firecrawl.dev, then compare them.',
  tools: { batchScrape, poll },
});
```

<h3 id="agent">
  Agent
</h3>

Collecte autonome de données sur le web qui recherche, navigue et extrait des données en toute autonomie.

```typescript theme={null}
import { generateText, stepCountIs } from 'ai';
import { agent, poll } from 'firecrawl-aisdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Trouve les fondateurs de Firecrawl, leurs rôles et leurs parcours.',
  tools: { agent, poll },
  stopWhen: stepCountIs(10),
});
```

<h2 id="logging">
  Journalisation
</h2>

```typescript theme={null}
import { generateText } from 'ai';
import { logStep, scrape, stepLogger } from 'firecrawl-aisdk';

const logger = stepLogger();

const { text, usage } = await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Scrape https://firecrawl.dev and summarize it.',
  tools: { scrape },
  onStepFinish: logger.onStep,
  experimental_onToolCallFinish: logger.onToolCallFinish,
});

logger.close();
logger.summary(usage);

await generateText({
  model: 'anthropic/claude-sonnet-4-5',
  prompt: 'Scrape https://firecrawl.dev and summarize it again.',
  tools: { scrape },
  onStepFinish: logStep,
});
```

<h2 id="all-exports">
  Tous les exports
</h2>

```typescript theme={null}
import {
  // Outils principaux
  search,             // Rechercher sur le web
  scrape,             // Faire du scraping sur une seule URL
  map,                // Découvrir les URLs d'un site
  crawl,              // Crawler plusieurs pages (async, utiliser poll)
  batchScrape,        // Faire du scraping sur plusieurs URLs (async, utiliser poll)
  agent,              // Recherche web autonome (async, utiliser poll)

  // Gestion des tâches
  poll,               // Interroger les tâches async pour récupérer les résultats
  status,             // Vérifier l'état d'une tâche
  cancel,             // Annuler les tâches en cours

  // Outils Browser/session
  interact,           // interact({ profile: { name: '...' } })
  browser,            // export de compatibilité déprécié

  // Bundle tout-en-un
  FirecrawlTools,     // FirecrawlTools({ search, scrape, interact, crawl, agent })

  // Utilitaires
  stepLogger,         // Statistiques de tokens par appel d'outil
  logStep,            // Journalisation simple en une ligne
} from 'firecrawl-aisdk';
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.