Python SDK for the Mainwave AI observability platform
Project description
mainwave
Python SDK for the Mainwave AI observability platform.
Install
pip install "mainwave[openai]" # one platform
pip install "mainwave[langchain]" # LangChain + a callback handler
pip install "mainwave[all]" # everything (kick-the-tires only)
Per-platform pinning is recommended in production.
Quickstart
import mainwave
mainwave.init(
api_key="...", # or MAINWAVE_API_KEY
use_case_id="00000000-0000-0000-0000-000000000001", # or MAINWAVE_USE_CASE_ID
collector_url="https://collect.mainwave.ai", # default
)
with mainwave.run("INV-12345", metadata={"customer": "acme"}):
# ... do work; auto-instrumented LLM calls land under this run
...
mainwave.flush() # before exit
init() auto-wires every supported instrumentor that's already importable, so
the snippet above needs no instrument() call. Reach for instrument() only
to wire a framework imported after init() ran (lazy import, CLI subcommand,
FastAPI lifespan) — see Public API.
mainwave.run(...) is optional — without it, every OTel trace becomes its
own logical run. Wrap explicitly when one logical operation spans multiple
traces (loops, fan-out, multiple LLM invocations per request); the integration
guide wraps every agent execution for exactly this reason.
Not seeing data?
The SDK never raises into your app, so a misconfigured endpoint or key fails quietly. Turn on its logger to see what's happening:
import logging
logging.getLogger("mainwave").setLevel(logging.INFO) # add a handler if you have none
At INFO it logs the first successful export, which instrumentors wired, and a
WARNING for any framework that didn't. mainwave.flush() returns False on a
failed drain — check it before a hard exit. Confirm collector_url and the API
key, and that the framework's extra is installed (pip install "mainwave[openai]").
Public API
mainwave.init(...)— set up the SDK once, at process start.mainwave.instrument(name=None)— re-wire instrumentors after late imports.mainwave.run(...)/mainwave.arun(...)/mainwave.start_run(...)— open a logical run (sync CM, async CM, imperative).mainwave.span(name, attrs=...)— escape hatch for manual spans.mainwave.flush(timeout=30.0)/mainwave.aflush(timeout=30.0)— drain buffers.mainwave.langchain.CallbackHandler— optional explicit LangChain handler.mainwave.testing—reset()+install_in_memory_provider()for tests.
LangChain users
Use the native CallbackHandler (captures model reasoning + step trajectory) OR
auto-instrumentation (instrument(name="langchain")) — not both, or every call
is double-counted. You don't have to police it: attaching the handler disables
the OpenInference LangChain instrumentor automatically, and
init(skip_instrumentors=["langchain"]) skips wiring it up front.
See also
Spec: docs/agent_sdk/ in the platform monorepo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mainwave-0.1.0rc1.tar.gz.
File metadata
- Download URL: mainwave-0.1.0rc1.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2af9343cb7252100312d12898186e877a4d5116ff84b863b5155099dfd432cfe
|
|
| MD5 |
52c10adea9da449c633ecb740eb0831c
|
|
| BLAKE2b-256 |
0f4cfc9cb17bb65e6d48ea366285b3791630a473ab804b7527ca387898be548c
|
Provenance
The following attestation bundles were made for mainwave-0.1.0rc1.tar.gz:
Publisher:
sdk-publish.yml on mainwaveai/mainwave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mainwave-0.1.0rc1.tar.gz -
Subject digest:
2af9343cb7252100312d12898186e877a4d5116ff84b863b5155099dfd432cfe - Sigstore transparency entry: 1956490853
- Sigstore integration time:
-
Permalink:
mainwaveai/mainwave@3ef28d276e0561557272117bf30cad99ddbc3257 -
Branch / Tag:
refs/tags/sdk-v0.1.0rc1 - Owner: https://github.com/mainwaveai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish.yml@3ef28d276e0561557272117bf30cad99ddbc3257 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mainwave-0.1.0rc1-py3-none-any.whl.
File metadata
- Download URL: mainwave-0.1.0rc1-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8d433b241aa020d33cebf9bbd142e1cfb254e7d5c921a469bce2a41cc4ad9dd
|
|
| MD5 |
af6aadea47f3fe07d950a09c4baec6f0
|
|
| BLAKE2b-256 |
c51914b0be92992d09eaa38e9842378ed0c5d158c67992cc982a0da75f280804
|
Provenance
The following attestation bundles were made for mainwave-0.1.0rc1-py3-none-any.whl:
Publisher:
sdk-publish.yml on mainwaveai/mainwave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mainwave-0.1.0rc1-py3-none-any.whl -
Subject digest:
e8d433b241aa020d33cebf9bbd142e1cfb254e7d5c921a469bce2a41cc4ad9dd - Sigstore transparency entry: 1956491050
- Sigstore integration time:
-
Permalink:
mainwaveai/mainwave@3ef28d276e0561557272117bf30cad99ddbc3257 -
Branch / Tag:
refs/tags/sdk-v0.1.0rc1 - Owner: https://github.com/mainwaveai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish.yml@3ef28d276e0561557272117bf30cad99ddbc3257 -
Trigger Event:
push
-
Statement type: