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, andnn.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
uv add "msgflux[openai]"
# or
pip install "msgflux[openai]"
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_message = "You are a helpful support agent."
instructions = "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_message = "You are a helpful support agent."
instructions = "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
- Documentation: https://msgflux.com/
- Agent quickstart: https://msgflux.com/learn/nn/agent/quickstart/
- Tutorials index: https://msgflux.com/tutorials/
- Dependency management: https://msgflux.com/dependency-management/
- Home page theory and architecture: https://msgflux.com/
Example Tutorials
- Support Ticket Router: https://msgflux.com/tutorials/support-ticket-router/
- Meeting Assistant: https://msgflux.com/tutorials/meeting-assistant/
- PIX Assistant: https://msgflux.com/tutorials/pix-assistant/
- Plan Tool with Root Context: https://msgflux.com/tutorials/plan-tool-with-root-context/
Release files for msgflux 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| msgflux-0.5.1.tar.gz | 2.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| msgflux-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.3 MB
Release files / msgflux-0.5.1.tar.gz
| Download URL | msgflux-0.5.1.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ec7b81180b79daf1a7eaa6a9e688469cf507d5e13b19c51fd4036bada5ee30f
|
|
BLAKE2b-256 checksum How to use checksums |
b01afa3e1601ee395fecdc33566b4ca5921c85855b27998a71ea7f0a72d5197f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 29, 2026.
Transparency logRelease files / msgflux-0.5.1-py3-none-any.whl
| Download URL | msgflux-0.5.1-py3-none-any.whl |
|---|---|
| Size | 314.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b411640178e15c96e7a51358b5304a8373925c63a3b189f10605cd0de7c773f
|
|
BLAKE2b-256 checksum How to use checksums |
cdfed5c6602bfe7041e222dd4eb8e1dfd88c8cbbe7349b10fbb0f4123a178748
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 29, 2026.
Transparency log