@decodo/ai-sdk is the npm package that gives Vercel AI SDK models live web data. It adds tools that scrape a page as Markdown, search the web, map a site’s URLs, and crawl a site. All of them run on the Web Data API and work with any AI SDK model provider.
View the ai-sdk repository for the source code, examples, and latest releases.
Features
- Web scraping – fetch one page as Markdown, optionally rendering JavaScript first
- Search – search the web and get ranked results
- Site mapping – list a site’s URLs without fetching their content
- Crawling – start a crawl, poll its status, read the pages as Markdown, or cancel it
- AI SDK integration –
decodoTools()returns standard AI SDK tools you pass togenerateTextor pick one by one - Errors the model can act on – a failed call reaches the model as a tool error, and
generateTextkeeps running
Requirements
- Node.js 18 or newer
aiv6 or v7, which is a peer dependency- A Decodo Web Data API plan. Free trials are available on the dashboard.
Installation
@ai-sdk/anthropic and read ANTHROPIC_API_KEY. Any AI SDK model provider works.
Authentication
Copy your API key from your Web Data API subscription in the Web Data API playground and store it in theDECODO_API_KEY environment variable:
decodoTools() throws right away when the API key is missing, or when it contains a line break, space, or other character that can’t be sent in a header.
Usage
Pass all the tools togenerateText:
crawl_start, crawl_status, and crawl_results:
crawl_status by calling it again, and each call uses a step, so give crawling prompts a higher stepCountIs. While a crawl is pending, crawl_status waits 5 seconds before answering. This slows polling and keeps a long crawl from using up the steps.
Available tools
A crawled page too long for one call is split across calls, and each part carries
contentPart with its character range. Every page also comes back with its url, depth, status, and content_error, and the response carries total, so the model can tell how much is left to read.
Inputs
Inputs are strict: a field that isn’t listed is refused rather than ignored.limit, max_depth, select_paths, and exclude_paths keep a crawl off the parts of a site you don’t need, so they’re worth setting in the prompt.
Errors
A failed call reaches the model as a tool error it can read and act on, andgenerateText keeps running:
- A rejected API key names
DECODO_API_KEY. - Rate limits and
5xxresponses tell the model to retry later. - A timeout tells the model to retry later, except on
scrapeandcrawl_start. Those requests may still have run, so the model is told not to send them again unless asked. - Validation errors tell the model to change the input.
- A page that couldn’t be scraped is an error, even when the API answered
200.
Related
- TypeScript SDK – The SDK these tools are built on.
- LangChain (TypeScript) – Decodo tools for LangChain agents in Node.js.
- MCP Server – Connect AI agents and MCP-compatible tools to Decodo.
- GitHub repository – View the source code, examples, and latest releases.
Support
Need help or just want to say hello? Our support is available 24/7.
You can also reach us anytime via email at support@decodo.com.
You can also reach us anytime via email at support@decodo.com.
Feedback
Can’t find what you’re looking for? Request an article!
Have feedback? Share your thoughts on how we can improve.
Have feedback? Share your thoughts on how we can improve.