Skip to main content

Marvin

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.11 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

Apache 2.0.

Metadata

Release files for marvin 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marvin 3.3.0
File Size Uploaded Provenance Actions
marvin-3.3.0.tar.gz 2.0 MB Without provenance Details for marvin-3.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for marvin 3.3.0
File Interpreter ABI Platform Actions
marvin-3.3.0-py3-none-any.whl Python 3 none any Details for marvin-3.3.0-py3-none-any.whl

Total release size: 2.1 MB

Release files / marvin-3.3.0.tar.gz

Download URL marvin-3.3.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
f5e9b9a53227748a134d7097cf9bd633a7383585769357779c5a33c65a425333
BLAKE2b-256 checksum
How to use checksums
590be5d7d992b7648ff3d15dfc473e449896be60807894fc02db78398edbd2dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / marvin-3.3.0-py3-none-any.whl

Download URL marvin-3.3.0-py3-none-any.whl
Size 112.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74b4fb6545c75ccfec30189952d6208bc7dea2f70fba5f5387893031ac786254
BLAKE2b-256 checksum
How to use checksums
1bdc36960414c2e1918bb75b55859af56909a9e0210e414492dffe3e7c4dbbcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for marvin 3.3.0

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.

Release history Release notifications | RSS feed

This release

3.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page