Skip to main content

Introduction

@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. This package enables you 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

Installation

Quick Start

Using Tools with generateText

Using the Context7 Agent

Authentication

Set your Context7 API key via environment variable:
Alternatively, pass the API key directly to tools or agents:

Package Contents

The package provides:

Tools

  • resolveLibraryId - Searches Context7’s database to find the correct library ID
  • queryDocs - Fetches documentation for a specific library

Agents

  • Context7Agent - Pre-configured agent that handles multi-step documentation lookup

Prompts

  • SYSTEM_PROMPT - Basic documentation assistant prompt
  • AGENT_PROMPT - Detailed multi-step workflow prompt
  • RESOLVE_LIBRARY_ID_DESCRIPTION - Tool description for resolveLibraryId
  • QUERY_DOCS_DESCRIPTION - Tool description for queryDocs

Next Steps

Tools

Learn about resolveLibraryId and queryDocs tools

Agent

Use the pre-configured Context7Agent