{"id":148,"library":"marvin","title":"Marvin (PrefectHQ)","description":"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).","status":"active","version":"3.2.7","language":"python","source_language":"en","source_url":"https://github.com/PrefectHQ/marvin","tags":["marvin","prefect","llm","structured-output","agents","python","ai-functions"],"install":[{"cmd":"pip install marvin","lang":"bash","label":"Python"}],"dependencies":[{"reason":"LLM backend from v3. Replaces direct OpenAI dependency from v2.","package":"pydantic-ai","optional":false},{"reason":"Default model provider. Marvin uses OpenAI by default — set OPENAI_API_KEY.","package":"openai","optional":true}],"imports":[{"wrong":"from marvin import extract","symbol":"extract","correct":"from marvin import extract"},{"symbol":"fn","correct":"from marvin import fn"},{"symbol":"classify","correct":"from marvin import classify"}],"quickstart":{"code":"# pip install marvin\nimport marvin\nimport os\n\n# Set OPENAI_API_KEY env var — marvin uses OpenAI by default\n\n# Structured extraction\nnumbers = marvin.extract(\n    'I paid $45 for lunch and $12 for coffee',\n    int,\n    instructions='USD amounts only'\n)\nprint(numbers)  # [45, 12]\n\n# Classification\ncategory = marvin.classify(\n    'The new iPhone has great camera features',\n    labels=['tech', 'sports', 'politics']\n)\nprint(category)  # 'tech'\n\n# AI function\n@marvin.fn\ndef translate(text: str, language: str) -> str:\n    \"\"\"Translates text to the given language.\"\"\"\n\nprint(translate('Hello world', 'Spanish'))  # 'Hola mundo'","lang":"python","description":"Core marvin 3.x structured output functions."},"warnings":[{"fix":"Set OPENAI_API_KEY env var. Or configure other providers via pydantic-ai settings.","message":"marvin v2 was OpenAI-only. v3 uses Pydantic AI as backend supporting all providers. marvin.settings.openai.api_key configuration pattern from v2 is gone.","severity":"breaking","affected_versions":">= 3.0.0"},{"fix":"Replace @flow decorated functions with 'with marvin.Thread(): marvin.run(...)' pattern.","message":"ControlFlow's @flow decorator removed in v3. ControlFlow merged into marvin. Use marvin.Thread() context manager instead.","severity":"breaking","affected_versions":">= 3.0.0"},{"fix":"Reset SQLite data after version updates during development. Production: handle migrations manually.","message":"Thread/message history storage changed to SQLite in v3. No database migrations available — expect data loss when updating during development.","severity":"breaking","affected_versions":">= 3.0.0"},{"fix":"pip install marvin for AI functions. pip install sdss-marvin for astronomy. Never mix.","message":"Name collision: 'marvin' PyPI package is PrefectHQ's AI library. 'sdss-marvin' is the SDSS astronomy toolkit. LLMs may conflate them. They are completely unrelated.","severity":"gotcha","affected_versions":"all"},{"fix":"Set OPENAI_API_KEY or configure a different pydantic-ai provider explicitly.","message":"Marvin defaults to OpenAI gpt-4o. No model specified = OpenAI API call. Fails silently with AuthenticationError if OPENAI_API_KEY not set.","severity":"gotcha","affected_versions":"all"},{"fix":"Use @marvin.fn not @ai_fn.","message":"ai_fn decorator from very old v1 docs still appears in many tutorials. Renamed to marvin.fn in v2+.","severity":"gotcha","affected_versions":">= 2.0"},{"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.","message":"Installation 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.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"search_vec":"'2024':26 '2026':47 '3.2.7':45 'agent':6,74 'agent/task':22 'ai':3,15,39,55,77 'ai-funct':76 'astronomi':60 'backend':32 'base':14 'controlflow':29 'current':43 'decor':13 'decorator-bas':12 'function':4,16,78 'librari':8,56,62 'llm':31,70 'mar':46 'marvin':1,49,61,65,68 'marvin.cast':20 'marvin.classify':18 'marvin.extract':19 'marvin.fn':17 'merg':27 'multi':41 'multi-provid':40 'openai':35 'openai-on':34 'orchestr':23 'output':73 'prefect':69 'prefecthq':2,10,53 'provid':11,42 'pydant':38 'pypi':51,67 'python':75 'releas':25 'sdss':59,64 'sdss-marvin':63 'structur':72 'structured-output':71 'switch':30 'v3.0':24 'version':44 'warn':48 'workflow':7","created_at":"2026-03-24T04:14:18.470505+00:00","updated_at":"2026-04-16T16:27:24.460715+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpftouk9_z/venv/lib/python3.12/site-packages/marvin/__init__.py\", line 5, in <module>\n    from marvin.database import init_database_if_necessary\n  File \"/tmp/tmpftouk9_z/venv/lib/python3.12/site-packages/marvin/d"},"ecosystem":"pypi","meta_description":null,"install_score":38,"quickstart_score":33,"quickstart_tag":"draft","pypi_latest":"3.2.7","cli_name":"marvin","cli_version":"Usage: marvin [OPTIONS] COMMAND [ARGS]...","type":"library","homepage":"https://askmarvin.ai","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/marvin/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml","workflow"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-08-26","next_check":"2026-07-10","install_tag":"stale"}}