Show proof for every AI citation.
We believe AI citations should follow show, don't tell; they should prove their citations so you don't have to blindly chase them down yourself. DeepCitation replaces 'trust me' citations with a deterministic verification layer.
DeepCitation turns model citations into deterministic, inspectable proof.
bun add deepcitationnpm install deepcitationyarn add deepcitationpnpm add deepcitationimport { DeepCitation, extractVisibleText, wrapCitationPrompt } from "deepcitation";
const deepCitation = new DeepCitation({
apiKey: process.env.DEEPCITATION_API_KEY,
});
// 1) Process documents
const { deepTextPromptPortion } = await deepCitation.prepareAttachments([
{ file: pdfBuffer, filename: "report.pdf" },
]);
// 2) Wrap prompts before calling your model
const { enhancedSystemPrompt, enhancedUserPrompt } = wrapCitationPrompt({
systemPrompt: "You are a helpful assistant...",
userPrompt: "Summarize the key findings",
deepTextPromptPortion,
});
const response = await yourLLM.chat({
system: enhancedSystemPrompt,
user: enhancedUserPrompt,
});
// 3) Verify citations
const { verifications } = await deepCitation.verify({ llmOutput: response.content });
// 4) Strip citation metadata before showing model text to users
const visibleText = extractVisibleText(response.content);Heads up:
verificationsis aRecord<string, Verification>object, not an array. UseObject.keys(verifications).lengthto count results, not.length.
A set of high-quality React components to help you build production-ready attribution systems. Skip the complexity of reading multiple file formats, rendering multiple formats, coordinate mapping, and visual proof generation.
Works with any LLM -- OpenAI, Anthropic, Google, AI SDK, local models, or any leading model.
| OpenAI ✔ | Anthropic ✔ | Gemini ✔ | AI SDK ✔ |
Clone a working example and have citations running in under 2 minutes:
# Next.js chat app with streaming citations
git clone https://github.com/DeepCitation/deepcitation.git
cd deepcitation/examples/nextjs-ai-sdk
cp .env.example .env.local # add your API keys
npm install && npm run dev# Run unit tests
npm test
# Run Playwright component tests
npm run test:ct
# Run visual snapshot tests
npm run test:ct -- --grep "visual snapshot"- Full Documentation
- Examples -- Basic verification, Next.js chat app, URL citations
- Integration Guide -- For AI coding assistants
- Error Handling Guide -- Production error patterns
- Styling Guide -- CSS custom properties and theming
See CONTRIBUTING.
Hosted API/service is subject to Terms and Privacy Policy. Patent pending. "DeepCitation" is a trademark.
