> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Citations

> Track sources in agent responses

Agents can cite their sources - show where information comes from.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Citation Flow"
        A[📚 Sources] --> B[🤖 Agent]
        B --> C[💬 Answer]
        C --> D[📖 Citations]
    end
    
    classDef source fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef tool fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff
    
    class A source
    class B agent
    class C,D output
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

```

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'Answer using the provided documents',
  knowledge: './docs/',
  citations: true
});

const result = await agent.chat('What is the return policy?');
console.log(result.content);
// "You can return items within 30 days [1]"
console.log(result.citations);
// [{ id: 1, source: 'returns.md', text: '...' }]
```

**2. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agent = new Agent({
  citations: {
    format: 'inline',  // or 'footnote', 'endnotes'
    includePageNumbers: true
  }
});
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Knowledge
    
    User->>Agent: "What's the return policy?"
    Agent->>Knowledge: Search documents
    Knowledge-->>Agent: Relevant passages
    Agent->>Agent: Generate answer
    Agent-->>User: Answer + citations
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Level 1: Bool - Enable citations
const agent = new Agent({
  citations: true
});

// Level 2: String - Citation style
const agent = new Agent({
  citations: 'inline'  // 'inline', 'footnote', 'endnotes'
});

// Level 3: Dict - Full options
const agent = new Agent({
  citations: {
    format: 'footnote',
    includePageNumbers: true,
    maxCitations: 5,
    minRelevanceScore: 0.7
  }
});
```

***

## Citation Formats

| Format | Example |
| - | - |
| `inline` | "Returns within 30 days \[1]" |
| `footnote` | "Returns within 30 days¹" |
| `endnotes` | Citations listed at end |

***

## API Reference

> [card] [Knowledge Module](https://praison.ai/docs/sdk/reference/typescript/modules/knowledge.md)
>
> Knowledge and citation support

***

## Best Practices

> [accordion] Use with knowledge base
>
> Citations work best when agent has documents to reference.

> [accordion] Set relevance threshold
>
> Use `minRelevanceScore` to ensure quality citations.

> [accordion] Limit citation count
>
> Too many citations can clutter responses.

***

## Related

> [card] [Knowledge](https://praison.ai/docs/js/knowledge-base.md)
>
> Knowledge base

> [card] [RAG](https://praison.ai/docs/js/rag-agent.md)
>
> Retrieval augmented generation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.