Vercel AI SDK Screenshot: Adding Screenshot Capabilities to AI Workflows

Website screenshots give AI applications visual information about a webpage's layout, design, and content.

Aakash
Updated November 25, 2026
Share

Website screenshots give AI applications visual information about a webpage’s layout, design, and content. Let’s connect the screenshot tool to the Vercel AI SDK so an AI model can capture webpage screenshots based on user prompts and use the resulting images in its responses.

How Vercel AI SDK Works with Screenshots

The Vercel AI SDK lets developers connect external tools to AI models through tool calling. Geekflare’s @geekflare/ai-sdk package adds screenshot capabilities through the geekflareScreenshot() tool.

The tool captures webpage screenshots and returns a hosted image URL that the AI model can use. It accepts two inputs: url to specify the webpage and fullPage to capture the entire page or just the visible area.

The integration supports AI SDK versions 5, 6, and 7, requires Node.js 18+ and Zod 3.25+ or 4, and supports both ECMAScript Modules (ESM) and CommonJS (CJS).

How to Integrate Screenshots with Vercel AI SDK

We’ll build a small Node.js application that connects the screenshot tool to an AI model.

Prerequisites

  • Node.js 18 or later
  • A Geekflare API key
  • An API key from your preferred LLM provider

Step 1: Install the Required Packages

Create a new project folder, open it in your preferred code editor, and initialize a Node.js project:

npm init -y

Install the Vercel AI SDK, Geekflare integration, and Zod using your preferred package manager.

Choose any one option. The integration requires ai and zod as peer dependencies.

Step 2: Configure Your API Keys

The integration needs a Geekflare API key to access its screenshot service. You’ll also need an API key from your preferred LLM provider to connect an AI model.

There are two ways to configure your Geekflare API key.

Method 1: Use an Environment Variable

Get your API key from the Geekflare Dashboard and set it as an environment variable named GEEKFLARE_API_KEY.

Replace YOUR_API_KEY with your actual key. The integration reads this environment variable automatically. You can also pass the key directly through the tool’s apiKey option.

Method 2: Manage the Key with Vercel Connect

If you’re deploying your application on Vercel, you can store the Geekflare API key in Vercel Connect and retrieve it at runtime.

From your project folder, link the project and create a Geekflare connector:

vercel link
vercel connect create geekflare --name my-geekflare
vercel env pull

The CLI prompts you to enter your Geekflare API key. The vercel env pull command adds a VERCEL_OIDC_TOKEN to your .env.local file for local development.

Install the Vercel Connect SDK:

npm install @vercel/connect

Use getToken() to retrieve your API key and pass it to geekflareScreenshot():

import { getToken } from "@vercel/connect";
import { geekflareScreenshot } from "@geekflare/ai-sdk";

const apiKey = await getToken("geekflare/my-geekflare", {
  subject: { type: "app" },
});

const screenshotTool = geekflareScreenshot({ apiKey });

Replace my-geekflare with your connector name if you choose a different one. To use the connector in another project, run vercel connect attach from that project. Geekflare

Finally, add your preferred LLM provider’s API key to the environment variables. I’ll use Claude for this example.

Step 3: Connect the Screenshot Tool to Vercel AI SDK

Import generateText from the Vercel AI SDK and geekflareScreenshot from the Geekflare integration. Register the screenshot tool inside generateText() so the AI model can capture and analyze webpages.

import { generateText, stepCountIs } from "ai";
import { geekflareScreenshot } from "@geekflare/ai-sdk";
import { geekflareScreenshot } from "@geekflare/ai-sdk";

import { anthropic } from "@ai-sdk/anthropic";  // Required because I'm using Claude. The provider package and model configuration may differ depending on your choice of LLM.

const { text, steps } = await generateText({
  model: anthropic("claude-sonnet-4-5"), // Reads ANTHROPIC_API_KEY
  prompt: "Use the screenshot tool to capture https://in.nothing.tech/collections/phones. Study the screenshot and analyze the webpage's design choices, layout, visual elements, and overall presentation.",
  tools: {
    geekflareScreenshot: geekflareScreenshot({
      device: "desktop",
      type: "png",
    }),
  },
  stopWhen: stepCountIs(5), // Let the model answer after the tool call
});

console.error("TOOL RESULTS:", JSON.stringify(steps.flatMap(s => s.toolResults.map(r => r.output)), null, 2));
console.log(text);

Here, geekflareScreenshot() captures the webpage using the configured mobile device and PNG format. The model then uses the returned screenshot to analyze the page’s design and layout.

You can configure the following options:

ParameterDescription
urlWebpage URL to capture.
fullPageSet to true to capture the entire page.
deviceSet to "mobile" or "desktop" to emulate a device.
typeChoose an image format: "png", "jpeg", or "webp".

The url and fullPage values are model inputs. The device and type options set defaults for the screenshot tool.

Here is the screenshot:

Vercel AI SDK Screenshot

Here is the analysis using the LLM:

Vercel AI SDK Screenshot Response

Frequently Asked Questions

Which Vercel AI SDK versions are compatible with the Geekflare integration?

The @geekflare/ai-sdk package supports Vercel AI SDK versions 5, 6, and 7.

Can I capture full-page screenshots?

Yes. Set the fullPage option to true to capture the entire webpage or false to capture only the visible area.

Which image formats does the screenshot tool support?

You can choose PNG, JPEG, or WebP using the type option.

Conclusion

The Vercel AI SDK lets developers connect screenshot tools to AI models through tool calling. Geekflare’s geekflareScreenshot() tool adds webpage capture capabilities, allowing models to access screenshots and analyze website layouts, design choices, and visual elements.

You can use this integration to build AI applications that inspect webpage designs and work with visual website content.

Aakash
Aakash R
Developer Advocate

Aakash R is a Developer Advocate with expertise in Artificial Intelligence, Machine Learning, and Computer Vision. Alongside his work in developer advocacy, he actively contributes technical articles and research-driven content on Generative AI, AI agents, developer tools, and cloud platforms. He enjoys translating advanced AI concepts into practical resources that developers can apply in real projects.

Thanks to Our Partners

More from Geekflare

Build a Web Scraping Agent with LlamaIndex
Dev Hub
Build a Web Scraping Agent with LlamaIndex

Build a web scraping agent with LlamaIndex and Geekflare to extract webpage content and process website…

Dev Hub
10 Best Android Emulators for PC and Mac

An Android emulator runs the Android operating system inside a window on your Windows PC or…

How to Give a LangChain Agent Screenshot Capabilities
Dev Hub
How to Give a LangChain Agent Screenshot Capabilities

Give a LangChain agent screenshot capabilities to capture webpages and retrieve visual content.