RadarTopicsBuildersWeeklyReads
Open Source Radar
jackmpcollins/

magentic

GitHubWebsite

Magentic provides decorators to create LLM-backed Python functions with structured outputs, streaming, and multi-backend configuration. It supports OpenAI, Anthropic, LiteLLM, and Mistral backends, with recent releases introducing streaming and OpenRouter support.

2.4kstars
127forks
49issues
MITlicense
2023since
Star historydaily snapshots by VibeCrowd

Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).

Alternatives & relatedmatched by topic overlap
Reviewgenerated from repository data · Aug 5, 2026

What it is

Magentic is a Python library to integrate Large Language Models into Python code. It uses the @prompt and @chatprompt decorators to return structured outputs using pydantic models or built-in types, enabling function calls, streaming, and agent-like behavior. It includes features for observability and retries, and supports multiple backends for LLM providers.

How it works

The library exposes decorators (@prompt, @chatprompt, @prompt_chain) to define LLM prompts and chat flows. It can perform function calling, streaming outputs, and iterative prompts. It supports Configured backends (OpenAI, Anthropic, LiteLLM, Mistral) with environment/config options to switch providers. Examples show creating prompts that map to pydantic models and streaming results via StreamedStr. The project mentions FunctionCall objects and the ability to pass resulting calls to other decorators.

Getting started

Install via:

pip install magentic

or using uv

uv add magentic

Configure the OpenAI API key via OPENAI_API_KEY. For other backends, see configuration docs.

Usage highlights include:

  • Using @prompt to define prompts that return typed outputs
  • Using @chatprompt to define chat-style prompts with system and user messages
  • Using @prompt_chain to resolve FunctionCall objects automatically

Recent releases

  • v0.41.1 (2026-03-11): Handle empty stream chunks & remove require_parameters in OpenRouterChatModel by @piiq in https://github.com/jackmpcollins/magentic/pull/464
  • v0.41.0 (2025-10-14): Add support for verbosity and max_completion_tokens request parameters to OpenAI chat model; Bump astral-sh/setu
  • v0.40.0 (2025-06-22): Bump astral-sh/setup-uv; Add OpenRouter chat model
  • v0.39.3 (2025-04-07): Fix: function call parsing positional args ignoring arg defaults
  • v0.39.2 (2025-03-02): Add tests for Gemini via openai package

Traction

Stars: 2415, Forks: 127, Open issues: 49

Behind the repo

Not included in the provided facts.

Caveats

License: MIT. Created: 2023-06-18. Last push: 2026-03-11. Language: Python.

SharePost on XLinkedIn
All trending reposRevenue-verified startups →