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.0rc4

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.0rc4
File Size Uploaded Provenance Actions
msgflux-1.0.0rc4.tar.gz 3.6 MB With provenance Details for msgflux-1.0.0rc4.tar.gz

Built distribution (wheel)

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

Total release size: 4.6 MB

Release files / msgflux-1.0.0rc4.tar.gz

Download URL msgflux-1.0.0rc4.tar.gz
Size 3.6 MB
Tags Source
SHA-256 checksum
How to use checksums
7ac9448517a36bf667a532b86cbff6190cfbe4796d07bbdcbefc61bc2277310d
BLAKE2b-256 checksum
How to use checksums
795dc4103c1af9449c89a1381bcd02151aa7bb190591aa0e1171b9d96cb7d084
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

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

Download URL msgflux-1.0.0rc4-py3-none-any.whl
Size 954.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd681637413ca2beb6f05e0e9f8f5cf3b41895d3ff6ac6db056675f77dbc85af
BLAKE2b-256 checksum
How to use checksums
26e7701dc04dfb324b776e132ac4312bf41cef54d61daaf8b67be75a141d861c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Security for msgflux 1.0.0rc4

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.0rc4.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 Nov 3, 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