Marvin
Marvin is a Python library for extracting structured data and running tasks with language models. It builds on Pydantic AI for model access and adds typed tasks, tools, and conversation history. Made by Prefect.
Install
Requires Python 3.10 or later and credentials for your model provider.
uv add marvin
export OPENAI_API_KEY="your-api-key"
Marvin uses OpenAI by default. See model configuration for other providers.
Use
import marvin
from pydantic import BaseModel
class Contact(BaseModel):
name: str
email: str
contacts = marvin.extract("Email Ada at ada@example.com", Contact)
print(contacts)
Use cast to produce one value, extract to find a list of values, classify to choose labels, and generate to create examples. Each has an async counterpart.
For work that needs instructions, context, or tools, use a task:
import marvin
def stock_level(product: str) -> int:
"""Return the number of units in stock."""
return {"notebook": 12, "pen": 30}[product]
count = marvin.run(
"Check how many notebooks are in stock",
result_type=int,
tools=[stock_level],
)
An Agent holds model settings, instructions, and tools you want to reuse. A Thread shares conversation history across calls and stores it in a database. See the quickstart and examples for both.
Develop
uv sync
uv run pytest tests/basic
uv run pre-commit run --all-files
Tests under tests/ai make model requests and require provider credentials. Keep test data separate from your local history by setting MARVIN_HOME_PATH to a temporary directory.
Docs
The documentation lives in docs/ and is published at askmarvin.ai. See releases for changes between versions.
License
Metadata
Release files for marvin 3.2.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| marvin-3.2.10.tar.gz | 2.0 MB | Without provenance | Details for marvin-3.2.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| marvin-3.2.10-py3-none-any.whl | Python 3 | none | any | Details for marvin-3.2.10-py3-none-any.whl |
Total release size: 2.1 MB
Release files / marvin-3.2.10.tar.gz
| Download URL | marvin-3.2.10.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
230d7b44450a87b2f303fd18720a07168dd865c7262e2e6eb22bb7b131d2697a
|
|
BLAKE2b-256 checksum How to use checksums |
d4d3fe3379235c21e3d0e5231bce4f096a30c3a764cf14be84cce485985ed099
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / marvin-3.2.10-py3-none-any.whl
| Download URL | marvin-3.2.10-py3-none-any.whl |
|---|---|
| Size | 114.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6677bbf2cd448d6c26c98dcb362cc044a24f4faf56be2a2d6fa720af18854495
|
|
BLAKE2b-256 checksum How to use checksums |
7b4ec30c6833beb58508bdc4e8b84c28b85c6f09926bd417de13d458cffeda0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for marvin 3.2.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.