Skip to content

Documentation navigation

Overview

Choose a starting point and understand what runs locally and what the service handles.

#mAIvn SDK Overview

mAIvn lets you build AI agents that reliably use your own code as tools, coordinate as teams, and keep secrets out of the model.

This overview explains what mAIvn is, how the SDK works, how to install it, and where to go next.

#What mAIvn Is

mAIvn is a Python SDK for building agents: programs that can reason about a request and then take action by calling tools.

Three ideas carry the whole SDK:

  • Agents. An Agent is the thing you talk to. You give it a name, a system prompt, and a set of tools, and it decides which tools to call to fulfill a request.
  • Tools are your own functions. A tool is just a Python function (or a Pydantic model) that you mark with @agent.toolify(). The agent can call it, but the code is yours: your business logic, your API calls, your database access.
  • Teams of agents. When one agent isn't enough, a Swarm coordinates several specialized agents so they can hand work back and forth.

If you can write a Python function, you can give an agent a new capability.

#Why It Matters

The defining property of mAIvn is where your code runs.

When you register a tool, the agent does not receive your code. Your tool's code never leaves your environment: the platform receives each tool's name, its description and the types of its parameters, and the function body stays on your machine and runs there.

The data a run needs does go to the platform, and on to the model provider that serves the run: your messages and files, and the arguments and results of tool calls. Values you mark as private are replaced with placeholders before a model sees them. See the Private Data Guide.

Note: Your tool code executes locally in your environment. It is never transferred to or executed on mAIvn servers. The platform receives each tool's name, description and parameter types for orchestration, and the run's data as described above.

That one design choice gives you:

  • Private business logic. Your implementation never leaves your environment.
  • Local data access. Tools can read your database, hit internal services, or touch the filesystem. You decide what each tool returns, and only what it returns goes back to the run.
  • Secrets out of the model. Sensitive values such as API keys, passwords and PII can be declared as private data and injected into your tools only at execution time. The model plans against the names of those values, never the values themselves, and known private values in tool results are redacted before they return to the model. See the Private Data Guide.

You get the planning ability of a hosted orchestrator without surrendering your code or your secrets to it.

#How It Works at a Glance

The flow: you describe tools and rules; the hosted orchestrator plans; your code runs locally; a typed response comes back.

Concretely, every invocation flows through four conceptual stages:

  1. You author scopes. A scope is an Agent or a Swarm. You declare its tools, the rules between them (dependencies, private data, structured output), and any configuration.
  2. The hosted orchestrator plans. When you call invoke(), the SDK sends your message and the schemas of your tools to the orchestrator, which decides what to do and in what order.
  3. Your tools execute locally. When the plan calls a tool, the SDK runs your function in your own process and sends only the result back. Private values are injected at this moment and redacted from results.
  4. A typed response comes back. You receive an InvokeResponse. Read response.response for the final assistant text, or response.result for structured output.

You stay in control of the code and the data, and the orchestrator handles the reasoning about which tool to call and when.

#Install

Shell
pip install maivn

Or with uv:

Shell
uv add maivn

mAIvn requires Python 3.10 or newer. It depends on the public maivn-contracts package and installs it automatically. Check the installed release with maivn version.

Optional extras add features you may not need:

ExtraAdds
maivn[rich]Rich terminal output for verbose=True runs. Plain text works without it.
maivn[fastapi]maivn.events.fastapi, which serves an event stream from your FastAPI app.
maivn[otel]The OpenTelemetry API for run telemetry. You choose and configure the SDK and exporter.

The SDK also installs private-data-vault. On a supported desktop with an available OS credential store, it opens encrypted local storage when caller private values are first used. Installation itself does not create a vault. Servers need a durable directory and a secret-manager key. See Values that outlive one call for setup and recovery, and for how local deletion works.

#Your First Agent

A short script defines an agent, gives it a tool, and runs it:

Python
import os

from maivn import Agent
from maivn.messages import HumanMessage

agent = Agent(name='assistant', api_key=os.environ['MAIVN_API_KEY'])

@agent.toolify(description='Get current weather for a city')
def get_weather(city: str) -> dict:
    return {'city': city, 'temp': 72, 'condition': 'sunny'}

response = agent.invoke([HumanMessage(content='What is the weather in Austin?')])
print(response.response)

Agent accepts an explicit api_key, a preconfigured Client, or credentials from the process environment or an explicitly selected credential file. This example reads the environment itself. See Authentication.

For a guided, step-by-step build of this same agent (including structured output and live event streaming), start with the Getting Started guide.

#Where to Go Next

Pick the path that matches what you're trying to do.

Start here

  • Getting Started: build your first agent step by step, return a typed answer, and watch execution events.
  • Core Concepts: scopes, tools, swarms, dependencies, sessions and structured output on one page.
  • Best Practices: patterns for tools, prompts, privacy, errors and swarms before you go to production.
  • Glossary: short definitions for the terms that are easy to confuse.
  • Troubleshooting: error messages, their causes and fixes.
  • Versioning, Upgrading to SDK 2.0 and Upgrading to SDK 3.0: version numbers, the stable import surface, what changed from 0.x, and what 3.0 removed.

Build agents

Start agents from events

Account, Portal and Studio

Reference and examples