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

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.1
File Size Uploaded Provenance Actions
marvin-3.3.1.tar.gz 2.0 MB Without provenance Details for marvin-3.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 2.2 MB

Release files / marvin-3.3.1.tar.gz

Download URL marvin-3.3.1.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
bfacd4917526445a43b0ae018171f23a6e35ef1cc551a34caa771ab5b13a1dcc
BLAKE2b-256 checksum
How to use checksums
037a6be7284e028797d2cfb87199fec672b302ecab04c377b53c2a73b5ce3ff2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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.1-py3-none-any.whl

Download URL marvin-3.3.1-py3-none-any.whl
Size 112.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ae2d639ff99240f03576b8b942168a6545a6174085ac0fcff80d55b6b0af2ae
BLAKE2b-256 checksum
How to use checksums
d58d92ee8455801a3215672f53b8bd702e2ff91871c0e42aa8e09d2432156a18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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.1

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