Skip to main content

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 BaseChatModel subclasses
  • 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"

Metadata

Release files for maev-sdk 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maev-sdk 0.5.1
File Size Uploaded
maev_sdk-0.5.1.tar.gz 24.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maev-sdk 0.5.1
File Interpreter ABI Platform
maev_sdk-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / maev_sdk-0.5.1.tar.gz

Download URL maev_sdk-0.5.1.tar.gz
Size 24.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ec9f8187c963cde5b9597c8700ebb690aa454a8672cbcc22a530899bc6a539f3
BLAKE2b-256 checksum
How to use checksums
dc27c8c86228438c2816505143e9805d6e98c35e935e90f95d009d3fb82ef930
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / maev_sdk-0.5.1-py3-none-any.whl

Download URL maev_sdk-0.5.1-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
063eb12be6849dd3ce2a755fc0db0865fba93413fe45e249c5f50fe9a30805e8
BLAKE2b-256 checksum
How to use checksums
8bdca0b30056b9c4f8def88f78a9d34edda2257282c3ddccda703d664411b5c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

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