🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@upstash/context7-tools-ai-sdk

Package Overview
Dependencies
Maintainers
8
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@upstash/context7-tools-ai-sdk

Context7 tools for Vercel AI SDK

canary
latest
Source
npmnpm
Version
0.2.0-canary-20251209084107
Version published
Maintainers
8
Created
Source

Upstash Context7 AI SDK

@upstash/context7-tools-ai-sdk provides Vercel AI SDK compatible tools and agents that give your AI applications access to up to date library documentation through Context7.

Use this package to:

  • Add documentation lookup tools to your AI SDK workflows with generateText or streamText
  • Create documentation aware agents using the pre-configured Context7Agent
  • Build RAG pipelines that retrieve accurate, version specific code examples

The package provides two main tools:

  • resolveLibrary - Searches Context7's database to find the correct library ID
  • getLibraryDocs - Fetches documentation for a specific library with optional topic filtering

Quick Start

Install

npm install @upstash/context7-tools-ai-sdk @upstash/context7-sdk ai zod

Get API Key

Get your API key from Context7

Usage

Using Tools with generateText

import { resolveLibrary, getLibraryDocs } from "@upstash/context7-tools-ai-sdk";
import { generateText, stepCountIs } from "ai";
import { openai } from "@ai-sdk/openai";

const { text } = await generateText({
  model: openai("gpt-4o"),
  prompt: "How do I use React Server Components?",
  tools: {
    resolveLibrary: resolveLibrary(),
    getLibraryDocs: getLibraryDocs(),
  },
  stopWhen: stepCountIs(5),
});

console.log(text);

Using the Context7 Agent

The package provides a pre-configured agent that handles the multi-step workflow automatically:

import { Context7Agent } from "@upstash/context7-tools-ai-sdk";
import { anthropic } from "@ai-sdk/anthropic";

const agent = new Context7Agent({
  model: anthropic("claude-sonnet-4-20250514"),
});

const { text } = await agent.generate({
  prompt: "How do I set up routing in Next.js?",
});

console.log(text);

Configuration

Environment Variables

Set your API key via environment variable:

CONTEXT7_API_KEY=ctx7sk-...

Then use tools and agents without explicit configuration:

const tool = resolveLibrary(); // Uses CONTEXT7_API_KEY automatically

Docs

See the documentation for details.

Contributing

Running tests

pnpm test

Building

pnpm build

Keywords

context7

FAQs

Package last updated on 09 Dec 2025

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