Flash Cards from PDF
A template that generates educational flash cards from PDF documents. Attach a PDF in Mastra Studio, and the agent creates flash cards with optional AI-generated images. Built with Mastra.
Why we built this
This template shows how you can generate images with an agent, and how to build a tool that parses PDFs.
Demo
This demo runs in Mastra Studio, but you can connect this workflow to your React, Next.js, or Vue app using the Mastra Client SDK or agentic UI libraries like AI SDK UI, CopilotKit, or Assistant UI.
Prerequisites
- OpenAI API key — used by default, but you can swap in any model
Quickstart 🚀
- Clone the template
- Run
npx create-mastra@latest --template flash-cards-from-pdfto scaffold the project locally.
- Run
- Add your API keys
- Copy
.env.exampleto.envand fill in your keys.
- Copy
- Start the dev server
- Run
npm run devand open localhost:4111 to try it out.
- Run
Making it yours
Select the Flash Card Agent and attach a PDF file using the attachment button in the chat. You can use the assets/example.pdf file included in the repo for testing. Ask the agent: "Create flash cards from this PDF". Optionally, afterwards ask for images: "Generate flash cards with images for the key concepts".
Swap in a different image generation provider, add your instructions, or wire the agent into your app using the Mastra Client SDK. The agent is in src/mastra/agents — edit it directly to fit your use case.
About Mastra templates
Mastra templates are ready-to-use projects that show off what you can build — clone one, poke around, and make it yours. They live in the Mastra monorepo and are automatically synced to standalone repositories for easier cloning.
Want to contribute? See CONTRIBUTING.md.
