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

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

Built distribution (wheel)

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

Total release size: 3.9 MB

Release files / msgflux-1.0.0rc2.tar.gz

Download URL msgflux-1.0.0rc2.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7245fe2483734cefd976fa483967afbce219a485920bb3357ddaf9ec50a0f0e6
BLAKE2b-256 checksum
How to use checksums
511f6e081fc2c498463f96f205cbcdf7df79c708ce18707ea853d171af99b2d2
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 15, 2026.

Transparency log

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

Download URL msgflux-1.0.0rc2-py3-none-any.whl
Size 800.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9993f6a07d5a0b1d5167c98f592f0e9826a3b08ed522a32485648416fb9aa7b
BLAKE2b-256 checksum
How to use checksums
3f5d83c7b091cdee4bc194e7fb9a509a455a852bc67fb02a1348313c1fb2a4dd
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 15, 2026.

Transparency log

Security for msgflux 1.0.0rc2

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.0rc2.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 15, 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