# Chat with PDF

Indexes a PDF into a vector store and answers questions over it with page-cited retrieval.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).



<DocsBaseSwitcher base="eve" agent="chat-with-pdf" />

<AgentPreview
  agent="chat-with-pdf"
  framework="eve"
  inputFields="[
  {
    name: &#x22;url&#x22;,
    label: &#x22;PDF URL&#x22;,
    placeholder: &#x22;https://example.com/whitepaper.pdf&#x22;,
    type: &#x22;text&#x22;,
  },
  {
    name: &#x22;question&#x22;,
    label: &#x22;Question&#x22;,
    placeholder: &#x22;What does the paper conclude about latency?&#x22;,
    type: &#x22;text&#x22;,
  },
]"
/>

## Summary [#summary]

The **Chat with PDF Agent** lets you ask questions about a PDF and get answers
grounded in the document, with a page citation for every claim. It indexes the
PDF into a vector store, retrieves only the relevant chunks per question, and can
also generate comprehension quizzes from real passages. Reach for it to turn
manuals, papers, and reports into something you can query.

## Install [#install]

```bash
npx shadcn@latest add https://agentcn.vercel.app/r/eve/chat-with-pdf.json
```

## Composition [#composition]

```text
agent/
├── agent.ts              # Agent definition (model + config)
├── instructions.md       # Retrieval-grounded answering instructions
├── lib/
│   └── vector-store.ts   # libSQL vector store + embeddings helpers
└── tools/
    ├── index_pdf.ts      # Chunk, embed, and store a PDF
    └── search_docs.ts    # Retrieve relevant chunks for a query
```

## Customization [#customization]

* **Swap the vector store.** `lib/vector-store.ts` wraps libSQL — replace it with
  Pinecone, Qdrant, Chroma, or pgvector behind the same `upsertChunks`/`search`
  functions.
* **Tune chunking.** Adjust `chunkText`'s size and overlap for your documents.
* **Swap the embedding model.** Change the model in `lib/vector-store.ts`.
* **Add quizzes.** The instructions already support quiz generation from
  retrieved passages — extend them with your preferred format.
