Maev AI Agent Observability SDK — one-liner instrumentation for AI agents
Project description
Maev Python SDK
One line. Full control over your agent in production.
Installation
pip install maev-sdk
Quickstart
import maev
result = maev.run(my_agent, gateway=True)
maev.run() wraps your agent with full observability, self-healing circuit breakers, and self-improving prompt optimization — in one call. The gateway=True flag transparently routes your LLM traffic through Maev's cloud edge for backend learning.
What activates automatically
| Feature | What it does |
|---|---|
| Observability | Every LLM call, token count, cost, and latency captured |
| Auto-retry | Failed or empty responses retried up to 3× with exponential backoff |
| Cost circuit breaker | Run stops if cost exceeds your cost_budget |
| Call count limit | Run stops if max_calls is exceeded |
| Duration limit | Run stops if max_duration_s is exceeded |
| Loop detection | Breaks infinite prompt loops before they drain the budget |
| Fallback models | Switches to backup models if the primary fails repeatedly |
| Backend optimization | After 20+ runs, generates and tests shadow prompt candidates automatically |
Parameters
maev.run(
agent, # required: callable or agent object
gateway=True, # enable Gateway for self-reflection and optimization
api_key="vl_xxx", # or set MAEV_API_KEY env var
agent_name="My Agent", # or set MAEV_AGENT_NAME env var
cost_budget=1.0, # max $ per run (default $1.00)
max_calls=50, # max LLM calls per run (default 50)
max_duration_s=300.0, # max seconds per run (default 300)
fallback_models=["gpt-4o-mini"],# fallback model list
)
Supported frameworks
Maev actively intercepts LLM calls for:
- OpenAI — including
AzureOpenAI,AsyncOpenAI,AsyncAzureOpenAI - Anthropic — including
AsyncAnthropic - LangChain — all
BaseChatModelsubclasses - CrewAI — detected via
.kickoff() - LiteLLM — via callback hooks; redirected to gateway when
gateway=True
Telemetry is also captured for Gemini, Cohere, AWS Bedrock, Mistral, Groq, LlamaIndex, and more.
Works with any framework
Because gateway=True makes Maev an OpenAI-compatible proxy, any library that accepts a custom base_url works automatically:
# LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://gateway.maev.dev/v1",
default_headers={"x-api-key": "vl_xxx", "x-agent-name": "My Agent"},
)
# Direct OpenAI client
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.maev.dev/v1",
default_headers={"x-api-key": "vl_xxx", "x-agent-name": "My Agent"},
)
Serverless environments
In serverless environments (AWS Lambda, Cloud Functions, Vercel), call maev.flush() before the handler returns:
import maev
def handler(event, context):
result = maev.run(my_agent, event, gateway=True)
maev.flush()
return result
Or use the one-liner form — Maev handles flushing automatically:
def handler(event, context):
return maev.run(my_agent, event, gateway=True)
Error handling
try:
maev.run(agent, gateway=True, cost_budget=0.10)
except maev.CircuitBrokenError as e:
print(e)
# Run stopped: cost limit exceeded ($0.10)
Requirements
- Python >= 3.9
- Works in scripts, servers, notebooks, containers, and serverless
API Key
Get your key at home.maev.dev/dashboard/settings.
Keys start with vl_. Set as environment variable:
export MAEV_API_KEY="vl_your_key_here"
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 maev_sdk-0.5.1.tar.gz.
File metadata
- Download URL: maev_sdk-0.5.1.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9f8187c963cde5b9597c8700ebb690aa454a8672cbcc22a530899bc6a539f3
|
|
| MD5 |
b18c3d2b4f991f456d8b2680d2cff9cc
|
|
| BLAKE2b-256 |
dc27c8c86228438c2816505143e9805d6e98c35e935e90f95d009d3fb82ef930
|
File details
Details for the file maev_sdk-0.5.1-py3-none-any.whl.
File metadata
- Download URL: maev_sdk-0.5.1-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
063eb12be6849dd3ce2a755fc0db0865fba93413fe45e249c5f50fe9a30805e8
|
|
| MD5 |
2645f09bf59ca41183a548f51be4a59b
|
|
| BLAKE2b-256 |
8bdca0b30056b9c4f8def88f78a9d34edda2257282c3ddccda703d664411b5c1
|