SnapRender
  1. Home
  2. Integrations
  3. Vercel AI SDK

npm package for AI SDK 7

SnapRender tools for the Vercel AI SDK

snaprender-ai-sdk adds SnapRender, the screenshot API for AI agents, to the Vercel AI SDK. takeScreenshot lets the model see a web page on desktop, a phone or a tablet, and extractContent lets it read a web page as markdown. Pass snaprenderTools() to generateText, streamText or an agent, and the screenshot reaches the model as an image it can look at.

200 free captures a monthNo cardVersion 0.2.0, MIT

import { generateText, isStepCount } from 'ai';
import { snaprenderTools } from 'snaprender-ai-sdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-5.5',
  prompt: 'Take a screenshot of https://vercel.com on an iPhone and tell me what the hero section says.',
  tools: snaprenderTools(),
  stopWhen: isStepCount(4),
});

console.log(text);

Install and add your key

You need a SnapRender API key (free), Node.js 20.3 or newer and AI SDK 7. No key yet? Leave it unset: the first call starts a free trial key (100 watermarked captures) and each result includes a link to claim it. See agent trial keys.

  1. Get your API key

    Sign up with Google, GitHub or email. The key is on your dashboard right away and starts with sk_live_. The free plan has 200 captures a month (25 until you verify your email; Google and GitHub sign-ins start at 200), no card.

  2. Install the package

    npm install snaprender-ai-sdk ai zod. ai and zod are peer dependencies: AI SDK 7 (ai@^7) and zod 3.25.76+ or 4.1.8+.

  3. Set the key

    export SNAPRENDER_API_KEY=sk_live_.... The tools read SNAPRENDER_API_KEY, or pass { apiKey } or { getApiKey } to any factory.

  4. Give the tools to the model

    tools: snaprenderTools() in generateText, streamText or a ToolLoopAgent, with a stopWhen that leaves room for the tool steps.

The two tools

snaprenderTools() returns both. Import takeScreenshot or extractContent on its own when you need only one; each factory takes the same options.

See a web page

takeScreenshot

Captures a public URL or raw HTML and sends the image to the model. Desktop by default, or a phone, tablet or laptop with device; one screen, or the whole page with full_page.

  • Defaults: JPEG at quality 80, a 1280 x 800 viewport, ads and cookie banners hidden.
  • Devices: iphone_14, iphone_15_pro, pixel_7, ipad_pro, macbook_pro.
  • Uses: 1 capture, none for a cached copy.

Read a web page as markdown

extractContent

Reads a page after its scripts run and returns the content as text: the full page as markdown, the main article, plain text, HTML, the links or the metadata.

  • Defaults: markdown, up to 100,000 characters.
  • Focus: selector reads one part, such as main.
  • Uses: 1 capture, none for a cached copy.

takeScreenshot inputs

The model fills these in. Pass url or html.

InputTypeNotes
urlTypestringPublic http or https URL. Pass url or html, not both.
htmlTypestringRaw HTML to render instead of a URL, up to 2 MB.
formatTypejpeg | png | webpDefault jpeg at quality 80, the smallest file for the model.
full_pageTypebooleanThe whole scrollable page instead of the first screen.
lazy_loadTypebooleanWith full_page, scroll first so lazy images further down load.
deviceTypeiphone_14 | iphone_15_pro | pixel_7 | ipad_pro | macbook_proA phone, tablet or laptop view. Omit for desktop.
width, heightTypenumberViewport in CSS px: width 320 to 3,840, height 200 to 10,000. Default 1280 x 800.
dark_modeTypebooleanAsks the page for its dark theme (prefers-color-scheme: dark).
delayTypenumberExtra wait after load, 0 to 10,000 ms.
qualityTypenumberJPEG or WebP quality, 1 to 100.
hide_selectorsTypestringComma-separated CSS selectors to hide, such as a chat widget.
click_selectorTypestringA CSS selector to click before the capture, such as a tab.
block_ads, block_cookie_bannersTypebooleanBoth on by default.
cacheTypebooleanAccept a copy from the last 24 hours, which uses no capture. Default false: render now.

extractContent inputs

InputTypeNotes
urlTypestringPublic http or https URL.
typeTypemarkdown | article | text | html | links | metadataDefault markdown. article keeps the main text only; links lists the links; metadata returns the title, description and Open Graph tags.
selectorTypestringRead only part of the page, such as main or #pricing.
max_lengthTypenumberMost characters returned, default 100,000.
delayTypenumberExtra wait after load, 0 to 10,000 ms.
block_ads, block_cookie_banners, cacheTypebooleanAs for takeScreenshot.

What the model receives

The screenshot goes back as an image the model can look at, next to a one-line summary. Pages come back as text.

takeScreenshot returns the image through the tool's toModelOutput: a text summary plus an image file part. The tool's own result, in steps[].toolResults and in UI messages, is a JSON object with source, mediaType, bytes, width, height, cache, remainingCredits and image (base64).

Image size. Captures render at 2x device scale, so a 1280 px wide viewport gives a 2560 px wide image. When an image is over maxImageBytes (5 MB) or maxImageDimension (8,000 px), the tool leaves it out and tells the model why, so it can retry with full_page: false or a smaller viewport.

extractContent returns the page content as text, followed by a short source line with the type and the word count.

Errors. A failed request throws SnapRenderError with status, code and the API's message, such as SnapRender 422 TARGET_UNREACHABLE. The AI SDK passes it to the model as a tool error, so the agent can explain or try another URL. Failed renders do not use a capture.

takeScreenshot: what the model gets
{
  type: 'content',
  value: [
    { type: 'text', text: 'Screenshot of https://example.com (2560x1600 px, 161337 bytes, cache MISS, 172 captures left this period).' },
    { type: 'file', mediaType: 'image/jpeg', data: { type: 'data', data: '<base64>' } },
  ],
}

Works with generateText, streamText, ToolLoopAgent and any provider that accepts images in tool results.

Options

takeScreenshot(), extractContent() and snaprenderTools() take the same options object. You set these in code; the model never sees them.

OptionDefaultNotes
apiKeyDefaultprocess.env.SNAPRENDER_API_KEYYour SnapRender API key.
trialDefaulttrueWith no key, use a free agent trial key (100 watermarked captures over 7 days) and add a claim link to results. false throws MISSING_API_KEY instead.
trialAgentDefault'snaprender-ai-sdk'Name shown on the claim page.
getApiKeyDefaultnoneAn async function that returns a key at call time, for secret stores.
baseUrlDefaulthttps://app.snap-render.comThe API address.
timeoutMsDefault90000Per request. Full-page captures of long pages can take a while.
maxRetriesDefault1Retries after a per-minute rate limit, waiting as long as Retry-After says, up to 60 s. Monthly quota errors are never retried.
maxImageBytesDefault5000000takeScreenshot only. Larger images are left out and the model is told why.
maxImageDimensionDefault8000takeScreenshot only. Largest width or height in px sent to the model.
fetchDefaultglobal fetchA custom fetch, for proxies and tests.

Rate limits: a per-minute limit (HTTP 429) is retried maxRetries times after the Retry-After wait. A used-up month comes back to the model as a plain-words tool error and is never retried. The tools cannot reach localhost, private networks or pages behind a login; for your own site behind a firewall, see allow SnapRender.

One environment variable to set

Sign up free, copy the key from your dashboard into SNAPRENDER_API_KEY and pass snaprenderTools() to your model.

200 captures a month free, no card. Every plan works with the package.

Get a free API key

Python agents: LlamaIndex, LangChain and CrewAI

The same two tools for LlamaIndex, and ready-made packages for LangChain and CrewAI. Each one uses your SnapRender API key; the LlamaIndex tools also start a free trial key when none is set.

LlamaIndex: llama-index-tools-snaprender. SnapRenderToolSpec gives an agent take_screenshot, which returns a text summary plus an ImageBlock the model can look at, and extract_content, which returns the page as markdown, article text, plain text, links or metadata. Both have async versions that async agents use on their own.

The inputs match the AI SDK tools (device, full_page, lazy_load, selector, max_length and the rest). The constructor takes api_key (default SNAPRENDER_API_KEY), timeout in seconds, max_retries, max_image_bytes, max_image_dimension and get_api_key.

Use any LlamaIndex LLM integration that accepts images in tool results. Call the tools directly too:

Direct calls
spec = SnapRenderToolSpec()
blocks = spec.take_screenshot(url="https://example.com", full_page=True)  # [TextBlock, ImageBlock]
markdown = spec.extract_content(url="https://example.com", type="article")
Install
pip install llama-index-tools-snaprender
export SNAPRENDER_API_KEY=sk_live_...
FunctionAgent with SnapRender
import asyncio

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.anthropic import Anthropic
from llama_index.tools.snaprender import SnapRenderToolSpec

agent = FunctionAgent(
    tools=SnapRenderToolSpec().to_tool_list(),
    llm=Anthropic(model="claude-sonnet-5-5"),
    system_prompt="You can look at web pages with take_screenshot and read them with extract_content.",
)


async def main() -> None:
    response = await agent.run(
        "Take a screenshot of https://www.llamaindex.ai on an iPhone (device iphone_14) "
        "and tell me what the first screen shows."
    )
    print(response)


asyncio.run(main())
  • LangChain

    Screenshot, cache check and usage tools for Python and JavaScript agents, LangGraph included. pip install langchain-snaprender or npm install langchain-snaprender.

  • CrewAI

    A tool package that lets a crew capture pages and check usage. pip install crewai-snaprender.

  • All 11 tools over MCP

    Batches, signed links, webhooks and usage too. The AI SDK, the OpenAI Agents SDK and Mastra connect to the hosted MCP server with your key as a Bearer token.

Limits and plans

The packages are free. Each screenshot or extraction uses one capture from your SnapRender plan; failed renders and cached copies use none. Every screenshot summary tells the model how many captures are left, and when the month runs out the tool error says so in plain words.

PlanPrice a monthCaptures a month
Free$0200
Starter$92,000
Growth$2910,000
Business$7950,000
Scale$199200,000

The free plan has 200 captures a month (25 until you verify your email; Google and GitHub sign-ins start at 200). Every plan also includes scheduled screenshots and change monitoring. Yearly billing costs ten months of the monthly price. All plans.

Questions

What is snaprender-ai-sdk?

An npm package that adds SnapRender, the screenshot API for AI agents, to the Vercel AI SDK. It has two tools: takeScreenshot lets the model see a web page as an image, on desktop, a phone or a tablet, and extractContent lets it read a web page as markdown, article text, links or metadata. snaprenderTools() returns both, ready for generateText, streamText or an agent.

Which AI SDK and Node.js versions does it need?

AI SDK 7 (ai@^7), with zod 3.25.76 or later, or 4.1.8 or later, and Node.js 20.3 or newer. Install all three with npm install snaprender-ai-sdk ai zod.

Which models can look at the screenshots?

Any provider that accepts images in tool results, such as Anthropic, OpenAI and Google models. The screenshot reaches the model as an image file part next to a short text summary. extractContent returns plain text, so it works with any model that can call tools.

What does it cost?

The package is free and MIT licensed. Captures come from your SnapRender plan: Free $0 for 200, Starter $9 for 2,000, Growth $29 for 10,000, Business $79 for 50,000, Scale $199 for 200,000 captures a month. The free plan has 200 captures a month (25 until you verify your email; Google and GitHub sign-ins start at 200). Each screenshot or extraction uses one capture; failed renders and cached copies (cache: true) use none.

Why did the model get a note instead of the image?

The capture was over maxImageBytes (5 MB by default) or maxImageDimension (8,000 px). Captures render at 2x device scale, so a tall full-page capture can pass the limit that vision models accept. The tool leaves the image out and tells the model why, so it can try again with full_page: false or a smaller viewport. Raise the limits if your model accepts larger images.

What happens on a rate limit or when the month runs out?

A per-minute rate limit is retried once by default (maxRetries), after waiting as long as the Retry-After header says, up to 60 seconds. Monthly quota errors are never retried. Failed requests throw SnapRenderError with the status, code and the API's message, which the AI SDK passes to the model as a tool error, so the agent can tell you.

Should I use this package or the SnapRender MCP server?

The package gives you two typed tools and sends screenshots to the model as images, with no MCP client to run. The hosted MCP server gives all 11 SnapRender tools, including batches, signed links, webhooks and usage, through @ai-sdk/mcp: see the MCP setup for the AI SDK.

Can it capture localhost or pages behind a login?

No. The tools reach public pages only, not localhost, private networks or signed-in sessions. If a capture of your own site shows a security check, one firewall rule lets SnapRender through: see allow SnapRender on your site.

Let your AI SDK agent see the web

npm install snaprender-ai-sdk, set a free API key and pass snaprenderTools(). 200 captures a month, no card.