Documentation Index Fetch the complete documentation index at: https://docs.scrapegraphai.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Vercel AI SDK is a popular JavaScript/TypeScript framework to interact with various LLM providers. This page shows how to integrate it with ScrapeGraph.
Official Vercel AI documentation View the Vercel AI SDK documentation
Installation
Follow our JavaScript SDK installation steps using your favourite package manager:
# Using npm
npm i scrapegraph-js
# Using pnpm
pnpm i scrapegraph-js
# Using yarn
yarn add scrapegraph-js
# Using bun
bun add scrapegraph-js
Then, install Vercel AI with their OpenAI provider :
# Using npm
npm i ai @ai-sdk/openai
# Using pnpm
pnpm i ai @ai-sdk/openai
# Using yarn
yarn add ai @ai-sdk/openai
# Using bun
bun add ai @ai-sdk/openai
Usage
The ScrapeGraph SDK can be used like any other tool. See Vercel AI tool calling docs .
import { z } from "zod" ;
import { generateText , tool } from "ai" ;
import { openai } from "@ai-sdk/openai" ;
import { extract } from "scrapegraph-js" ;
const result = await generateText ({
model: openai ( "gpt-4.1-mini" ),
tools: {
scrape: tool ({
description: "Extract articles information from a given URL." ,
parameters: z . object ({
url: z . string (). describe ( "The exact URL." ),
}),
execute : async ({ url }) => {
const response = await extract ( process . env . SGAI_API_KEY ! , {
url ,
prompt: "Extract the article information" ,
schema: {
type: "object" ,
properties: {
articles: {
type: "array" ,
items: {
type: "object" ,
properties: {
title: { type: "string" },
author: { type: "string" },
publishDate: { type: "string" },
content: { type: "string" },
category: { type: "string" },
},
},
},
},
},
});
return response . data ?. json ;
},
}),
},
prompt: "Can you find me the articles on https://scrapegraphai.com/blog?" ,
});
console . log ( result );
Support
Need help with the integration?
GitHub Issues Report bugs and request features
Discord Community Get help from our community