DeepCitation Documentation
Verify AI citations against source documents. Visual proof for every claim.
DeepCitation is an API and React component library that verifies whether your AI’s citations actually appear in the source documents. Upload a PDF, let your LLM cite it, and get back visual proof screenshots showing exactly where each claim was found — or flagging it as hallucinated.
Quick Navigation
| Section | Description |
|---|---|
| Getting Started | Install, configure, and verify your first citation in 5 minutes |
| API Reference | REST endpoints, SDK methods, and TypeScript types |
| Components | React CitationComponent — 7 variants, CitationDrawer, SourcesList |
| Framework Guides | LangChain, Next.js, Vercel AI SDK, Express, Python |
| Styling | 50+ CSS tokens, dark mode, brand theming examples |
| Error Handling | Error classes, retry patterns, common mistakes |
| Common Mistakes | Unstyled citations, not_found results, API key exposure |
| Code Examples | 6 runnable example apps with live demos |
How DeepCitation Works
- Install & Setup — Install, import types, initialize client, prepare sources, configure proof images
- Server Side — Wrap prompts, call your LLM, verify citations, optionally persist results
- Display with CitationComponent — Parse numeric
[N]markers viaparseCitationResponse, map to citation keys, render inline with verification status
Example Projects
Complete, runnable examples are available on GitHub:
| Example | Description | Demo |
|---|---|---|
| basic-verification | Core 3-step workflow with OpenAI/Anthropic | – |
| langchain-rag-chat | Next.js + LangChain.js RAG app with verification | Live Demo |
| mastra-rag-chat | Next.js + Mastra RAG app with verification | Live Demo |
| nextjs-ai-sdk | Next.js chat app with Vercel AI SDK streaming | Live Demo |
| agui-chat | AG-UI protocol chat with SSE streaming | Live Demo |
| static-html | CDN popover in plain HTML, no build step | – |
Quick Install
npm install deepcitation
import { DeepCitation, wrapCitationPrompt, getAllCitationsFromLlmOutput } from "deepcitation";
const dc = new DeepCitation({ apiKey: process.env.DEEPCITATION_API_KEY });
// Prepare, wrap, verify in 3 steps
const { fileDataParts, deepTextPages } = await dc.prepareAttachments([{ file: pdfBuffer, filename: "report.pdf" }]);
const { enhancedSystemPrompt, enhancedUserPrompt } = wrapCitationPrompt({ systemPrompt, userPrompt, deepTextPages });
// ... call your LLM ...
const citations = getAllCitationsFromLlmOutput(response.content);
const { verifications } = await dc.verifyAttachment(fileDataParts[0].attachmentId, citations);