Build document Q&A
Let users upload a PDF and search it — build document retrieval in minutes.
Build a "search your PDF" experience: users upload a document, wait for processing, then search and retrieve relevant passages from that document.
Prerequisites
- A MemoryKit API key (get one here)
- Node.js 18+ or Python 3.8+
Step 1: Upload and process
Upload the user's file and poll until processing completes.
For production, use webhooks instead of polling. Listen for memory.completed and memory.failed events.
Step 2: Search the document
Use tags and precision to scope retrieval to just this document's content.
Step 3: Multi-document sessions
Support multiple documents in one session. Upload several files and query across all of them.
Step 4: Clean up
Delete temporary documents when the session ends.
Summary
| What | How |
|---|---|
| Upload files | upload() with polling or webhooks |
| Scope to document | search() with tags scoped to the document |
| Search passages | search() with limit and precision |
| Multi-document | Tag all documents with a session tag, then search by tag |
| Clean up | delete() each memory when done |
Key features used: File upload, Search