Chat with PDFs
Documents File Upload Vision
Upload PDF documents and have a conversation about their content. The AI reads the document and answers questions based on what it finds.
Demo
Upload a PDF and ask questions about it!
Convert Files to Data URLs
The FileReader API converts uploaded files into base64
data URLs that can be sent to the AI model.
utils.ts
Copy
Client Component
Send both text and file parts in a single message. The parts array can contain multiple content types.
+page.svelte
Copy
Server Endpoint
Uses a model that supports document understanding. The convertToModelMessages handles the multi-part format.
+server.ts
Copy