npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

snaprender-ai-sdk

v0.2.0

Published

Vercel AI SDK tools for SnapRender: let your agent take website screenshots and read rendered pages as markdown

Readme

snaprender-ai-sdk

Vercel AI SDK tools for SnapRender. Your agent can take screenshots of web pages and read rendered pages as markdown. Pages load in a real Chrome browser with ads and cookie banners removed, and the screenshot goes back to the model as an image it can look at.

  • takeScreenshot: capture a URL or raw HTML (desktop, phone or tablet, viewport or full page) and send the image to the model.
  • extractContent: read a page after JavaScript runs, as markdown, main article text, plain text, links or metadata.

The free plan includes 200 captures a month. Get a key at app.snap-render.com/auth/signup, or start with no key at all (see below).

Install

npm install snaprender-ai-sdk ai zod

Requires AI SDK 7 (ai@^7) and Node.js 20.3 or newer. Set your key:

export SNAPRENDER_API_KEY=sk_live_...

Try it with no key

If no key is set, the tools start a free agent trial key on the first call: 100 captures over 7 days (up to 30 a day), with a small watermark and lower priority. The key is saved in ~/.snaprender/trial.json and shared with the other SnapRender tools on the machine (the MCP server and the LlamaIndex tools), so one trial covers all of them.

While the trial key is in use, each tool result ends with a short note for your human:

Trial key: 97 captures left. Ask your human to claim it at https://app.snap-render.com/dashboard/claim/... to remove the watermark and get 200 free captures a month.

Claiming takes a free account. The same key then keeps working with no watermark, so nothing in your code changes. Pass trial: false to turn this off and get a MISSING_API_KEY error instead. Details: snap-render.com/docs/agent-trial.

Quick start

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);

Pick single tools if you only need one:

import { takeScreenshot, extractContent } from 'snaprender-ai-sdk';

const tools = {
  takeScreenshot: takeScreenshot(),
  extractContent: extractContent({ timeoutMs: 30_000 }),
};

The tools work the same way with streamText, ToolLoopAgent and any provider that accepts images in tool results (Anthropic, OpenAI, Google and others).

What the model sees

takeScreenshot returns the image through the tool's toModelOutput, as a text summary plus an image file part:

{
  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>' } },
  ],
}

The tool's own result (what you get in steps[].toolResults and in UI messages) is a JSON object with source, mediaType, bytes, width, height, cache, remainingCredits and image (base64). On a trial key it also has trialNote, which is added to the text the model sees.

Captures render at 2x device scale, so a 1280 px wide viewport gives a 2560 px wide image. Very tall full-page captures can be larger than vision models accept. When an image is over maxImageBytes (default 5 MB) or maxImageDimension (default 8000 px), the tool leaves the image out and tells the model why, so it can try again with full_page: false or a smaller viewport.

extractContent returns the page content as text, followed by a short source line.

Tool inputs

takeScreenshot (pass url or html):

| Input | Type | Notes | |---|---|---| | url | string | Public http or https URL | | html | string | Raw HTML to render instead of a URL (max 2 MB) | | format | jpeg | png | webp | Default jpeg at quality 80 (smallest for the model) | | full_page | boolean | Whole scrollable page | | lazy_load | boolean | With full_page, scroll first so lazy images load | | device | iphone_14 | iphone_15_pro | pixel_7 | ipad_pro | macbook_pro | Omit for desktop | | width, height | number | Viewport in CSS px (320-3840, 200-10000). Default 1280x800 | | dark_mode | boolean | prefers-color-scheme: dark | | delay | number | Extra wait after load, ms (0-10000) | | quality | number | JPEG or WebP quality (1-100) | | hide_selectors | string | Comma-separated CSS selectors to hide | | click_selector | string | CSS selector to click before capture | | block_ads, block_cookie_banners | boolean | Both default true | | cache | boolean | Accept a copy from the last 24 hours (free). Default false |

extractContent:

| Input | Type | Notes | |---|---|---| | url | string | Public http or https URL | | type | markdown | article | text | html | links | metadata | Default markdown | | selector | string | Read only part of the page, e.g. main | | max_length | number | Max characters (default 100000) | | delay | number | Extra wait after load, ms | | block_ads, block_cookie_banners, cache | boolean | As above |

Options

Every factory (takeScreenshot, extractContent, snaprenderTools) takes the same options:

| Option | Default | Notes | |---|---|---| | apiKey | process.env.SNAPRENDER_API_KEY | Your SnapRender key | | getApiKey | none | Async function that returns a key at call time (secret stores) | | trial | true | With no key, use the shared agent trial key. false throws MISSING_API_KEY instead | | trialAgent | snaprender-ai-sdk | Name sent when starting a trial key, shown on the claim page | | baseUrl | https://app.snap-render.com | | | timeoutMs | 90000 | Per request | | maxRetries | 1 | Retries after a per-minute rate limit, waiting as long as Retry-After says (up to 60 s). Monthly quota errors are never retried | | maxImageBytes | 5000000 | takeScreenshot only | | maxImageDimension | 8000 | takeScreenshot only | | fetch | global fetch | Custom fetch (proxies, tests) |

Errors

Failed requests throw SnapRenderError with status, code and the API's message, for example SnapRender 422 TARGET_UNREACHABLE: The target website could not be reached.... The AI SDK passes the message to the model as a tool error, so the agent can explain or try another URL. Failed renders do not use a capture.

Trial keys have their own codes, and their messages already include the claim link: TRIAL_LIMIT_REACHED (429, the daily or total trial captures are used), TRIAL_EXPIRED (401, claim the key and it works again), TRIAL_BUSY (503, the trial lane is busy, try again in a minute) and, when a new trial key cannot be started, AGENT_TRIAL_LIMIT (429) or AGENT_TRIAL_UNAVAILABLE (503).

The tools cannot reach localhost, private networks or pages behind a login. If a capture of your own site shows a security check page, see snap-render.com/docs/allow-snaprender.

Example

git clone https://github.com/User0856/snaprender-integrations
cd snaprender-integrations/ai-sdk
npm install && npm run build
SNAPRENDER_API_KEY=sk_live_... ANTHROPIC_API_KEY=sk-ant-... npm run example -- https://example.com

examples/basic.ts uses Anthropic or OpenAI directly when their keys are set, and the AI Gateway otherwise.

Development

npm test                                   # unit tests, no network
SNAPRENDER_TEST_KEY=sk_live_... npm run test:live   # live API tests (about 14 captures)
npm run test:live:trial                    # starts ONE real trial key and makes one capture
npm run typecheck

Links

MIT License