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

@expandai/ai

v0.1.1

Published

Vercel AI SDK integration for expand.ai - fetch and extract content from any URL

Readme

@expandai/ai

Vercel AI SDK integration for Expand - fetch and extract content from any URL with AI.

Installation

npm install @expandai/ai ai zod
# or
pnpm add @expandai/ai ai zod
# or
yarn add @expandai/ai ai zod

Prerequisites

You need an Expand API key. Get one at expand.ai.

Set your API key as an environment variable:

export EXPAND_API_KEY=your_api_key_here

Usage

Basic Example

import { expandFetchTool } from '@expandai/ai'
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'

const result = await generateText({
  model: openai('gpt-4'),
  tools: {
    expandFetch: expandFetchTool,
  },
  prompt: 'What is on the Expand homepage at https://expand.ai?',
})

console.log(result.text)

Custom Configuration

import { createExpandFetchTool } from '@expandai/ai'

const customTool = createExpandFetchTool({
  apiKey: 'your_custom_api_key',
  description: 'Custom tool description for your specific use case',
})

const result = await generateText({
  model: openai('gpt-4'),
  tools: {
    fetch: customTool,
  },
  prompt: 'Summarize the content at https://example.com',
})

With Multiple Tools

import { expandFetchTool } from '@expandai/ai'
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'
import { weatherTool } from './other-tools'

const result = await generateText({
  model: openai('gpt-4'),
  tools: {
    expandFetch: expandFetchTool,
    weather: weatherTool,
  },
  prompt: 'Check the weather forecast on https://weather.com and plan my weekend',
})

API

expandFetchTool

The default tool instance that uses the EXPAND_API_KEY environment variable.

import { expandFetchTool } from '@expandai/ai'

createExpandFetchTool(options?)

Create a custom Expand fetch tool with specific configuration.

Parameters:

  • options.apiKey (optional): Expand API key. Defaults to process.env.EXPAND_API_KEY
  • options.description (optional): Custom tool description for the AI model

Returns: A Vercel AI SDK tool

import { createExpandFetchTool } from '@expandai/ai'

const tool = createExpandFetchTool({
  apiKey: 'your_api_key',
  description: 'Fetch web content for analysis',
})

Tool Output

The tool returns an object with:

  • url: The fetched URL
  • markdown: The extracted content in Markdown format
  • meta: Metadata object containing:
    • title: Page title
    • description: Page description
    • And other metadata fields

Examples

Research Assistant

import { expandFetchTool } from '@expandai/ai'
import { generateText } from 'ai'
import { anthropic } from '@ai-sdk/anthropic'

const result = await generateText({
  model: anthropic('claude-3-5-sonnet-20241022'),
  tools: {
    expandFetch: expandFetchTool,
  },
  prompt: `
    Research the latest developments in AI from these sources:
    - https://openai.com/blog
    - https://www.anthropic.com/news
    Provide a summary of the most important updates.
  `,
})

Content Comparison

import { expandFetchTool } from '@expandai/ai'
import { streamText } from 'ai'
import { openai } from '@ai-sdk/openai'

const result = await streamText({
  model: openai('gpt-4-turbo'),
  tools: {
    expandFetch: expandFetchTool,
  },
  prompt: `
    Compare the pricing pages of:
    - https://vercel.com/pricing
    - https://netlify.com/pricing
    Which one offers better value for small teams?
  `,
})

for await (const chunk of result.textStream) {
  process.stdout.write(chunk)
}

Error Handling

import { createExpandFetchTool } from '@expandai/ai'
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'

try {
  const tool = createExpandFetchTool({ apiKey: process.env.EXPAND_API_KEY })

  const result = await generateText({
    model: openai('gpt-4'),
    tools: { expandFetch: tool },
    prompt: 'Fetch https://example.com',
  })
} catch (error) {
  console.error('Failed to fetch content:', error)
}

Requirements

  • Node.js 18 or higher
  • ai >= 3.0.0
  • zod >= 3.0.0

License

Apache-2.0

Links

Support

For issues and questions: