Learn how to install and integrate DeepCitation into your application.
DeepCitation works in 4 simple steps: prepare files, wrap prompts, verify citations, and display results.
Upload source documents to extract text with line IDs for your LLM prompt.
Add citation instructions to your prompts and call any LLM provider (OpenAI, Anthropic, Google, etc.).
Verify citations with deterministic matching and get visual proof images.
Parse citations from markdown output and render with React components or your own UI.
Install the SDK using your preferred package manager:
# npm
npm install @deepcitation/deepcitation-js
# yarn
yarn add @deepcitation/deepcitation-js
# pnpm
pnpm add @deepcitation/deepcitation-js
# bun
bun add @deepcitation/deepcitation-js
import { DeepCitation, wrapCitationPrompt, getAllCitationsFromLlmOutput } from "@deepcitation/deepcitation-js";
const dc = new DeepCitation({ apiKey: process.env.DEEPCITATION_API_KEY });
// 1. Upload your source document
const { attachmentId, deepTextPromptPortion } = await dc.uploadFile(pdfBuffer, {
filename: "report.pdf"
});
// 2. Wrap your prompts with citation instructions
const systemPrompt = "You are a helpful assistant that cites sources.";
const { enhancedSystemPrompt, enhancedUserPrompt } = wrapCitationPrompt({
systemPrompt,
userPrompt,
deepTextPromptPortion // Pass file content directly
});
// 3. Call your LLM
const response = await yourLLM.chat({
messages: [
{ role: "system", content: enhancedSystemPrompt },
{ role: "user", content: enhancedUserPrompt },
]
});
// 4. Extract and verify citations
const citations = getAllCitationsFromLlmOutput(response.content);
const verified = await dc.verify(attachmentId, citations);
// 5. Use verification results
for (const [key, result] of Object.entries(verified.verifications)) {
console.log(`Citation ${key}: ${result.searchState?.status}`);
if (result.verificationImageBase64) {
// Display visual proof to users
}
}
Include your API key in the Authorization header:
Authorization: Bearer dc_live_your_api_key
Get your API key from the dashboard.
All API endpoints are available at:
https://api.deepcitation.com
The SDK handles API routing automatically. You only need to configure your API key.
| Type | Formats |
|---|---|
| PDFs | .pdf |
| Images | .jpg, .jpeg, .png, .gif, .webp (auto-OCR) |
| Office Docs | Word, Excel, Google Docs |
| URLs | Web pages via prepareUrl endpoint |