Marvin extracts typed data and runs tasks through language models on top of Pydantic AI. It exposes cast, extract, classify, and generate helpers plus Agent, Task, and Thread primitives.
Overview
Marvin is a Python library from Prefect for turning unstructured text into typed Python values and orchestrating model-backed work. It builds on Pydantic AI for provider access and validation while adding higher-level task APIs.
Functions such as cast, extract, classify, and generate cover single-value workflows, each with async variants. Task objects carry instructions, context, and tools for multi-step jobs, while Agent and Thread types reuse settings and persist conversation history in a database.
Install requires Python 3.11 or newer and credentials for your chosen model provider; OpenAI is the default configuration. Documentation and examples live on askmarvin.ai, and the project releases under Apache 2.0.
Tests that call live models need provider credentials and can isolate state with MARVIN_HOME_PATH.
Key features
- cast, extract, classify, and generate helpers
- Task API with tools and instructions
- Agent reuse of model settings and tools
- Thread-backed conversation history storage
- Built on Pydantic AI providers
- Async counterparts for core APIs
Use cases
- Parse free-form text into Python types
- Classify support tickets or survey responses
- Build reusable agents with shared tool sets