Skip to content

DeepCitation/deepcitation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

309 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepCitation cover

DeepCitation
Build Trusted AI Products.
Show proof for every AI citation.

License: MIT Zero Dependencies < 25KB

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.

Install

With bun

bun add deepcitation

With npm

npm install deepcitation

With yarn

yarn add deepcitation

With pnpm

pnpm add deepcitation

Quick Start

import { 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: verifications is a Record<string, Verification> object, not an array. Use Object.keys(verifications).length to count results, not .length.

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:

# 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

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.