mirror of
https://github.com/upstash/context7.git
synced 2026-09-14 19:09:34 +08:00
8ba484cdc8
* generate skills * feat: add generate questions methods * feat(cli): improve skill generation UX with streaming feedback - Add real-time query results display during generation - Collapse answered questions to show summary - Separate query phase spinner from generation spinner - Add skill preview with expand option - Remove legacy generateSkill function - Clean up redundant comments * feat(cli): improve skill generation UX with streaming feedback - Add real-time query results display during generation - Collapse answered questions to show summary - Separate query phase spinner from generation spinner - Add skill preview with expand option - Remove legacy generateSkill function - Clean up redundant comments * feat(cli): optimize feedback regeneration and clean up UI - Add previousContent to StructuredGenerateInput for efficient feedback - Remove redundant "Selected X libraries" log message - Consolidate menu options (remove "Regenerate completely") - Update feedback prompt with skip hint * feat(cli): add skill generation with quota and improved display - Add skill quota checking before generation - Fix tool result display timing issue - Show library project IDs in selection to avoid confusion - Improve generation spinner with query log display * docs(cli): add 0.2.0 changelog entry * fix(cli): switch userinfo endpoint from dev to production * docs(cli): add skill generation and auth sections to README * fix(sdk): increase timeout for sequential search test * chore(cli): replace manual changelog with changeset for skill generation
Upstash Context7 SDK
⚠️ Work in Progress: This SDK is currently under active development. The API is subject to change and may introduce breaking changes in future releases.
@upstash/context7-sdk is an HTTP/REST based client for TypeScript, built on top of the Context7 API.
Why Context7?
LLMs rely on outdated or generic training data about the libraries you use. This leads to:
- Code examples based on year-old training data
- Hallucinated APIs that don't exist
- Generic answers for old package versions
Context7 solves this by providing up-to-date, version-specific documentation and code examples directly from the source. Use this SDK to:
- Build AI agents with accurate, current documentation context
- Create RAG pipelines with reliable library documentation
- Power code generation tools with real API references
Quick Start
Install
npm install @upstash/context7-sdk
Get API Key
Get your API key from Context7
Basic Usage
import { Context7 } from "@upstash/context7-sdk";
const client = new Context7({
apiKey: "<CONTEXT7_API_KEY>",
});
// Search for libraries
const libraries = await client.searchLibrary(
"I need to build a UI with components",
"react"
);
console.log(libraries[0].id); // "/facebook/react"
// Get documentation as JSON array (default)
const docs = await client.getContext("How do I use hooks?", "/facebook/react");
console.log(docs[0].title, docs[0].content);
// Get documentation context as plain text
const context = await client.getContext(
"How do I use hooks?",
"/facebook/react",
{ type: "txt" }
);
console.log(context);
Configuration
Environment Variables
You can set your API key via environment variable:
CONTEXT7_API_KEY=ctx7sk-...
Then initialize without options:
const client = new Context7();
Docs
See the documentation for details.
Contributing
Running tests
pnpm test
Building
pnpm build