Skip to main content

Overview

@scrapegraph-ai/ai-sdk exposes ScrapeGraphAI endpoints as Vercel AI SDK tools. Add the tools to generateText or streamText, set stopWhen, and the model can scrape, extract, search, crawl, and monitor web data during the run.

Vercel AI SDK docs

Official Vercel AI SDK documentation

Tool calling

How AI SDK Core tools are executed

Installation

Install the ScrapeGraphAI tool package, the AI SDK, and the model provider you use:
Set your keys:
The tools read SGAI_API_KEY from the environment by default. You can also pass { apiKey: process.env.SGAI_API_KEY } to any tool factory.

Quickstart

Give the model a scrape tool and allow multiple steps so it can call the tool, receive the result, then write the final answer.

Available tools

Use a narrow tool set when the task is specific. Use all tools when the agent needs to decide the workflow:

Scrape example

This is the smallest useful agent: one scrape tool, a concrete target, and enough steps for the model to call the tool before answering.
Pass an API key explicitly when your runtime does not expose environment variables:

Crawl example

crawlTools() gives the model the full async crawl loop: start the job, poll status with getCrawl, then retrieve paginated pages with getCrawlPages.
For longer crawls, keep the same tools but add your app’s own timeout, cancellation, and persistence around the AI SDK call.

Tool reference

Scrape

Extract

Crawl

crawlTools() registers startCrawl, getCrawl, getCrawlPages, stopCrawl, resumeCrawl, and deleteCrawl.

Monitor

monitorTools() registers createMonitor, listMonitors, getMonitor, updateMonitor, deleteMonitor, pauseMonitor, resumeMonitor, and getMonitorActivity.

Support

GitHub Issues

Report bugs and request features

Discord Community

Get help from our community