Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

msgFlux

Dynamic AI systems in Python.

Documentation | Tutorials | Quickstart

msgFlux is an open-source Python framework for building AI systems with pretrained models as composable software components. It is built for applications where the model is one part of a larger program: agents, tools, signatures, multimodal modules, shared messages, and explicit orchestration.

Its core mental model comes from PyTorch: modules compose into programs, execution is explicit, and system behavior lives in code structure. msgFlux also adopts typed signatures as a useful abstraction for LM workflows, while keeping prompting, tools, and data flow grounded in a broader module-oriented architecture.

Why msgFlux

  • Build AI systems, not isolated prompts.
  • Treat signatures, prompts, tools, and message flow as first-class program structure.
  • Compose nn.Agent, nn.Module, nn.Transcriber, nn.Speaker, nn.Embedder, and nn.MediaMaker.
  • Choose imperative calls or declarative message binding per module.
  • Run against OpenAI-compatible providers, hosted APIs, or self-hosted endpoints.

Install

Core

uv add msgflux
# or
pip install msgflux

OpenAI and OpenAI-compatible providers

They use the core installation above. Set the provider's API key before making a request; no provider SDK is required.

More setup details: https://msgflux.com/dependency-management/

Minimal Examples

Imperative

import msgflux as mf
import msgflux.nn as nn

mf.set_envs(OPENAI_API_KEY="...")


class SupportAgent(nn.Agent):
    model = mf.Model.chat_completion("openai/gpt-4.1-mini")
    system_prompt = (
        "You are a helpful support agent.\n\n"
        "You are assisting {{ user_name }}."
    )


agent = SupportAgent()
result = agent(
    "My dashboard is not loading after the last update.",
    vars={"user_name": "Alice"},
)

print(result)

Declarative

import msgflux as mf
import msgflux.nn as nn

mf.set_envs(OPENAI_API_KEY="...")


class SupportAgent(nn.Agent):
    model = mf.Model.chat_completion("openai/gpt-4.1-mini")
    system_prompt = (
        "You are a helpful support agent.\n\n"
        "You are assisting {{ user_name }}."
    )
    message_fields = {"task": "issue", "vars": "variables"}
    response_mode = "solution"


agent = SupportAgent()

msg = mf.Message()
msg.issue = "My dashboard is not loading after the last update."
msg.variables = {"user_name": "Alice"}

agent(msg)
print(msg.solution)

Core Ideas

AI systems, not ML systems

msgFlux targets software built with pretrained models as components inside larger applications. The focus is not training the model; it is designing the system around it.

Declarative and imperative

A module can behave like a regular Python callable or bind itself to a shared message object. That choice lives at the module level, which makes it easier to mix direct control flow with pipeline-style orchestration.

Programming and prompting

Prompting and programming are related, but not the same thing. msgFlux lets you write prompts directly when needed, while still treating signatures, schemas, and routing as explicit code-level structure.

Modules compose into programs

Agents, transcribers, speakers, embedders, retrievers, and custom modules can be combined into larger pipelines, routers, and multimodal workflows.

Learn More

Example Tutorials

Metadata

Release files for msgflux 1.0.0rc1

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

Source distribution (sdist)

Source distribution for msgflux 1.0.0rc1
File Size Uploaded Provenance Actions
msgflux-1.0.0rc1.tar.gz 3.0 MB With provenance Details for msgflux-1.0.0rc1.tar.gz

Built distribution (wheel)

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

Total release size: 3.8 MB

Release files / msgflux-1.0.0rc1.tar.gz

Download URL msgflux-1.0.0rc1.tar.gz
Size 3.0 MB
Tags Source
SHA-256 checksum
How to use checksums
5e4a5df2d1de4c8fa12d336fcc050cf9dced2deee6c6d04bbb0e06cb352ed366
BLAKE2b-256 checksum
How to use checksums
76e678eb72af4f2f7a627d7b0b25f3b57ba260ace6e9a2c1145d59c5e4f113b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / msgflux-1.0.0rc1-py3-none-any.whl

Download URL msgflux-1.0.0rc1-py3-none-any.whl
Size 792.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6b8b5d4bccc34ba47ea4212420b2a2875c12f556844513fb6cbecb8fdb78b72
BLAKE2b-256 checksum
How to use checksums
2e445e60d47e6a76bbe3fb1dff763a5532e6436986cac4dca6bbc16a1a8a3d4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Security for msgflux 1.0.0rc1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for msgflux-1.0.0rc1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

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