Moduna Python SDK
Moduna is a small Python SDK that brands and simplifies Traceloop setup for AI agent frameworks. It gives
applications a stable moduna import path, framework-aware instrumentation, and Moduna API-key resolution from
configuration, exported environment variables, or .env.
Installation
Install the SDK with all supported framework integrations:
uv add moduna
pip install moduna
The framework extras are also available for teams that prefer explicit dependency declarations:
uv add "moduna[langchain]"
pip install "moduna[langchain]"
uv add "moduna[crewai]"
pip install "moduna[crewai]"
Quick Start
from moduna import Instruments, Moduna
moduna = Moduna()
moduna.init(
{
"app_name": "customer support",
"framework": Instruments.LANGCHAIN,
"api_key": "mod_...",
}
)
Set a conversation ID using the Moduna-branded tracing namespace:
from moduna.sdk.tracing import set_conversation_id
set_conversation_id("customer-123")
Configuration
Moduna resolves the API key in this order:
api_keypassed toModuna().init(...)- exported
MODUNA_API_KEY MODUNA_API_KEY=...in a local.envfile
The production Moduna endpoint is used by default. For local development, create
an ignored config.toml in the project root to switch to a local collector:
[sdk]
base_url = "http://localhost:4318"
You can also override the endpoint per application:
from moduna import Instruments, Moduna
Moduna().init(
{
"app_name": "support-agent",
"framework": Instruments.LANGCHAIN,
"base_url": "http://localhost:4318",
}
)
Frameworks
LangChain
from langchain_core.prompts import ChatPromptTemplate
from moduna import Instruments, Moduna
from moduna.sdk.tracing import set_conversation_id
Moduna().init({"app_name": "langchain-app", "framework": Instruments.LANGCHAIN})
set_conversation_id("conversation-1")
prompt = ChatPromptTemplate.from_messages([("human", "{question}")])
CrewAI
from moduna import Instruments, Moduna
from moduna.sdk.tracing import set_conversation_id
Moduna().init({"app_name": "crewai-app", "framework": Instruments.CREWAI})
set_conversation_id("crew-run-1")
Moduna installs the Traceloop/OpenTelemetry CrewAI instrumentation. Install the CrewAI runtime separately in your application when you build CrewAI agents.
Development
Activate the local virtual environment before running checks:
source .venv/bin/activate
uv sync
uv run ruff format .
uv run ruff check .
uv run pytest
uv build
Use uv run ruff format --check . in CI when you want formatting verification without rewriting files.
Publishing
GitHub Actions validates pull requests and every push to main. A successful
main build publishes only when the version in pyproject.toml does not
already exist on PyPI.
Configure the PyPI token once:
- Open the GitHub repository.
- Go to Settings → Secrets and variables → Actions.
- Add a repository secret named
PYPI_TOKEN. - Paste the PyPI token value from your local
.env.
Never commit .env or the token.
Prepare a release with uv:
source .venv/bin/activate
uv version --bump patch
git add pyproject.toml uv.lock
git commit -m "Release Moduna $(uv version --short)"
git push origin main
Changes that do not bump the version still run the full CI pipeline and skip the PyPI upload successfully.
Metadata
Release files for moduna 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| moduna-0.1.9.tar.gz | 90.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| moduna-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 110.1 kB
Release files / moduna-0.1.9.tar.gz
| Download URL | moduna-0.1.9.tar.gz |
|---|---|
| Size | 90.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0bf826d2181362f965f00d0e9b14090ea2d70cedae99781678ccae96bebf41a
|
|
BLAKE2b-256 checksum How to use checksums |
f415df4b7ea26677ee042173f897c95c396d91758fd5565bd8ba6971843b18b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / moduna-0.1.9-py3-none-any.whl
| Download URL | moduna-0.1.9-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
075d0233ea9758b06742349797db0ac98a19f4b31985a69d9104f5fe86ca7466
|
|
BLAKE2b-256 checksum How to use checksums |
0255eb6593ac7ba2ccb90006851994ec0265e8c50a093bfe4c4612abe1f9ea15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.20 {"installer":{"name":"uv","version":"0.11.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|