Skip to content

DeepCitation/deepcitation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

461 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepCitation cover

DeepCitation
Stop hallucinations
/verify citations

CI License: MIT Zero Dependencies ~9KB

DeepCitation demo

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.

Agent Skills

The fastest way to use DeepCitation is to install the /verify Agent Skill and ask Claude to verify your AI claims.

npx skills add DeepCitation/skills

Or

  1. Download verify.zip
  2. Go to claude.ai/customize/skills
  3. Upload verify.zip

Then ask Claude to /verify.

Building your own integration?

Install the package:

npm install deepcitation  # or bun add / yarn add / pnpm add

Quick Start

import { DeepCitation, extractVisibleText, wrapCitationPrompt } from "deepcitation";

const deepCitation = new DeepCitation({
  apiKey: process.env.DEEPCITATION_API_KEY,
});

// 1) Process documents 
const { deepTextPages } = 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",
  deepTextPages,
});

const response = await yourLLM.chat({
  system: enhancedSystemPrompt,
  user: enhancedUserPrompt,
});

// 3) Verify citations
const { verifications } = await deepCitation.verify({ llmOutput: response.content });
// IMPORTANT: 'verifications' is a Record<string, Verification> (object map, not an array).
// Use Object.keys(verifications).length to count results, not .length.

// 4) Strip citation metadata before showing model text to users
const visibleText = extractVisibleText(response.content);

Complete integration guide: See INTEGRATION.md for golden rules, 5 ready-to-use recipes, and common mistakes to avoid. Read Error Handling for production error patterns.

Components

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.

Support

Works with any LLM -- OpenAI, Anthropic, Google, AI SDK, local models, or any leading model.

OpenAI logo Anthropic logo Google Gemini logo Vercel AI SDK logo
OpenAI ✔ Anthropic ✔ Gemini ✔ AI SDK ✔

Try it now

Clone a working example and have citations running in under 2 minutes:

# Quickest start — Next.js chat with Vercel AI SDK
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

For RAG pipelines with LangChain.js and in-memory vector search:

cd deepcitation/examples/langchain-rag-chat
cp .env.example .env.local  # add DEEPCITATION_API_KEY + OPENAI_API_KEY
npm install && npm run dev

Examples

Development

Running Tests

# Run unit tests
npm test

# Run Playwright component tests
npm run test:ct

# Run visual snapshot tests
npm run test:ct -- --grep "visual snapshot"

Go deeper

Community

Contributing

See CONTRIBUTING.

License

MIT

Hosted API/service is subject to Terms and Privacy Policy. Patent pending. "DeepCitation" is a trademark.