Registry / llm-agents / marvin

marvin

JSON →
library3.2.7pypypi✓ verified 30d ago

AI functions and agentic workflow library by PrefectHQ. Provides decorator-based AI functions (marvin.fn, marvin.classify, marvin.extract, marvin.cast) and agent/task orchestration. v3.0 released 2024 — merged with ControlFlow, switched LLM backend from OpenAI-only to Pydantic AI (multi-provider). Current version: 3.2.7 (Mar 2026). WARNING: 'marvin' on PyPI is PrefectHQ's AI library — not the SDSS astronomy Marvin library (sdss-marvin on PyPI).

pip install marvin
INSTALL
IMPORT
SIG · MARVIN
M
marvin
llm-agentspythonv3.2.7
Install
24.1s avg
Import
7415ms
Disk
214MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.2.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.656s · 235MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 24.1s · import 1.310s · 233MB
214MB installed
● package 214MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

extract
✓ from marvin import extract
✗ from marvin import extract
fn
✓ from marvin import fn
classify
✓ from marvin import classify

Core marvin 3.x structured output functions.

# pip install marvin import marvin import os # Set OPENAI_API_KEY env var — marvin uses OpenAI by default # Structured extraction numbers = marvin.extract( 'I paid $45 for lunch and $12 for coffee', int, instructions='USD amounts only' ) print(numbers) # [45, 12] # Classification category = marvin.classify( 'The new iPhone has great camera features', labels=['tech', 'sports', 'politics'] ) print(category) # 'tech' # AI function @marvin.fn def translate(text: str, language: str) -> str: """Translates text to the given language.""" print(translate('Hello world', 'Spanish')) # 'Hola mundo'
marvin --version
Debug
Known issues
breakingmarvin v2 was OpenAI-only. v3 uses Pydantic AI as backend supporting all providers. marvin.settings.openai.api_key configuration pattern from v2 is gone.
fix
Set OPENAI_API_KEY env var. Or configure other providers via pydantic-ai settings.
affects: >= 3.0.0
breakingControlFlow's @flow decorator removed in v3. ControlFlow merged into marvin. Use marvin.Thread() context manager instead.
fix
Replace @flow decorated functions with 'with marvin.Thread(): marvin.run(...)' pattern.
affects: >= 3.0.0
breakingThread/message history storage changed to SQLite in v3. No database migrations available — expect data loss when updating during development.
fix
Reset SQLite data after version updates during development. Production: handle migrations manually.
affects: >= 3.0.0
gotchaName collision: 'marvin' PyPI package is PrefectHQ's AI library. 'sdss-marvin' is the SDSS astronomy toolkit. LLMs may conflate them. They are completely unrelated.
fix
pip install marvin for AI functions. pip install sdss-marvin for astronomy. Never mix.
affects: all
gotchaMarvin defaults to OpenAI gpt-4o. No model specified = OpenAI API call. Fails silently with AuthenticationError if OPENAI_API_KEY not set.
fix
Set OPENAI_API_KEY or configure a different pydantic-ai provider explicitly.
affects: all
gotchaai_fn decorator from very old v1 docs still appears in many tutorials. Renamed to marvin.fn in v2+.
fix
Use @marvin.fn not @ai_fn.
affects: >= 2.0
breakingInstallation of Python packages with Rust extensions (e.g., 'temporalio') often fails on Alpine Linux (musl) due to dynamic linking requirements of the Rust toolchain or its dependencies (e.g., missing 'libgcc_s.so.1' and '_Unwind' symbols). This occurs because the Rust components might be compiled for glibc, which is incompatible with musl environments.
fix
Install build essentials and C/C++ libraries in your Alpine environment (e.g., 'apk add build-base libstdc++'). Alternatively, use a glibc-based Python image or ensure you're using a Rust toolchain specifically compiled for musl targets.
affects: all
Upgrade
Version history
3.2.7latest on PyPI · released Mar 4, 2026
Audit
Dependencies
pydantic-airequiredLLM backend from v3. Replaces direct OpenAI dependency from v2.
openaioptionalDefault model provider. Marvin uses OpenAI by default — set OPENAI_API_KEY.
Agent activity
28 hits · last 30 days
node
24
Anthropic
1
OpenAI (training)
1
Resources
marvin — pip install marvin · libregistry