Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@expandai/ai

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expandai/ai

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

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
3
Created
Source

@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

Support

For issues and questions:

Keywords

vercel

FAQs

Package last updated on 21 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts