Skip to content

Documentation navigation

API Overview

Top-level SDK API map and import surface.

#SDK Reference

The supported public SDK surface, grouped by import path and linked to the detailed reference pages.

This page is the hub. If you are building your first agent, start with the Getting Started guide and the Agent reference. Come back here when you need to find an exact name or see how the pieces fit together. This page documents the behavioral surface (how to build, invoke, and stream). For the shapes that behavior produces and consumes (InvokeResponse, its token_usage dictionary, and privacy and billing models), see Shared Data Models.

#What this is

maivn is a Python SDK for building agentic systems. You describe what your agent can do (its tools, its dependencies, its configuration) as plain Python objects, and the SDK runs each request through an orchestrator that decides what to call and when. Everything you need lives behind a single import:

Python
from maivn import Agent
from maivn.messages import HumanMessage

agent = Agent(name='assistant', api_key='your-api-key')
response = agent.invoke([HumanMessage(content='Hello!')])
print(response.response)

The whole programming surface is the SDK. You construct Agent and Swarm objects, register tools with decorators, tune behavior with typed config models, and read results off a InvokeResponse. Tool code runs locally in your environment. The SDK sends only tool schemas (names, descriptions, parameters) for planning.

Note invoke() returns a InvokeResponse. Use response.response for the final assistant text and response.result for structured or final-tool output.

#The public import surface

The core classes, decorators, configuration, scheduling, and interrupt helpers below are exported from maivn. Event normalization and frontend-bridge APIs live in maivn.events; message types live in maivn.messages.

Python
from maivn import (
    # Version
    __version__,

    # Core Classes
    Agent,
    Swarm,
    Client,
    ClientBuilder,
    BaseScope,
    ToolOverride,
    MCPServer,
    MCPAutoSetup,
    MCPSoftErrorHandling,

    # Decorators
    tool_output,
    toolify,
    toolset,
    depends_on_tool,
    depends_on_agent,
    depends_on_private_data,
    depends_on_interrupt,
    depends_on_await_for,
    depends_on_reevaluate,

    # Configuration
    ConfigurationBuilder,
    MaivnConfiguration,
    get_configuration,
    MemoryAssetsConfig,
    MemoryConfig,
    MemoryInsightExtractionConfig,
    MemoryLevel,
    MemoryPersistenceMode,
    MemoryResourceConfig,
    MemoryRetrievalConfig,
    MemorySharingScope,
    MemorySkillConfig,
    MemorySkillExtractionConfig,
    SessionExecutionConfig,
    FinalOutputMode,
    OrchestrationMode,
    SessionOrchestrationConfig,
    StopStrategy,
    StructuredOutputConfig,
    SwarmAgentConfig,
    SwarmConfig,
    SystemToolsConfig,

    # Memory Resources
    MemoryInsight,
    MemoryInsightOrigin,
    MemoryInsightType,
    MemoryPersistenceCeiling,
    MemoryResource,
    MemoryResourceBindingType,
    MemoryResourceDetail,
    MemoryResourceStatus,
    MemorySkill,
    MemorySkillOrigin,
    MemorySkillStatus,
    MemoryUnboundResourceCandidate,
    OrganizationMemoryPolicy,
    OrganizationMemoryPurgeResult,
    ProjectMemoryResources,

    # PII / Privacy
    HIPAA_SAFE_HARBOR_CATEGORIES,
    PIIWhitelist,
    PIIWhitelistEntry,
    PrivateData,
    RedactedMessage,
    RedactionPreviewRequest,
    RedactionPreviewResponse,

    # Billing / Usage
    BillingUsage,
    BillingPlan,
    BillingCurrentUsage,
    BillingUsageBreakdown,
    BillingUsageProject,
    BillingUsageApiKey,
    BillingUsageTotals,

    # Permissions
    PERMISSION_FLAG_NAMES,
    PermissionFlag,
    PermissionSet,
    require_permissions,

    # Provider Metadata
    AuthMode,
    ProviderCapability,
    ProviderMetadata,

    # Logging
    configure_logging,
    get_logger,

    # Scheduling
    AtSchedule,
    CronInvocationBuilder,
    CronSchedule,
    IntervalSchedule,
    JitterDistribution,
    JitterSpec,
    MisfirePolicy,
    OverlapPolicy,
    Retry,
    RetryBackoff,
    RunRecord,
    RunStatus,
    Schedule,
    ScheduledJob,
    list_jobs,
    stop_all_jobs,

    # Terminal reporting and bridge policy
    BackpressurePolicy,

    # Interrupts
    AgentGenerated,
    FollowupOption,
    FollowupQuestion,
    FollowupQuestionsConfig,
    default_terminal_followup,
    default_terminal_interrupt,
)

Event and message APIs live in dedicated public submodules:

Python
from maivn.events import AppEvent, EventBridge, RawSSEEvent, normalize_stream
Python
from maivn.messages import HumanMessage, AIMessage, SystemMessage, RedactedMessage

Metadata-only run telemetry lives in its own versioned submodule:

Python
from maivn.telemetry import RunTelemetryEvent, register_listener
from maivn.telemetry.opentelemetry import OpenTelemetryAdapter
Tip You rarely import all of this at once. Most applications need only Agent (or Swarm), one or two decorators, and the message types. Everything else is opt-in.

#Core classes

The objects you instantiate and call. Agent and Swarm are the two entry points. Both inherit a large shared surface from BaseScope (tool registration, events, batching, scheduling, and MCP). The .structured_output(Model) builder is Agent-only; Swarms use final tools for typed output.

ClassDescriptionReference
AgentPrimary entry point. Holds tools, config, and credentials, and routes invocations through the orchestrator. Resolves credentials from arguments, selected files, or the process environment. Exposes invoke / stream / ainvoke / astream.Core
SwarmMulti-agent orchestration container. Members carry their own tools; parent tools can be explicit dependencies. Member list order does not select an entry agent. Adds add_agent / list_agents and the .member dependency-aware registration builder.Core
BaseScopeAbstract base shared by Agent and Swarm. Owns tool registration (toolify / add_tool / add_toolset), events(), batch / abatch, scheduling (cron / interval / at), and MCP registration. Rarely instantiated directly.Core
ClientConnection manager that carries credentials and connects an Agent or Swarm to the mAIvn service. Usually created for you from an api_key.Core
ClientBuilderFactory for constructing Client instances with explicit settings.Core
EventsPublic event models, payload builders, and stream-normalization helpers for surfacing execution state to your backend and frontend.Core
Run TelemetryStable metadata-only run hooks and the optional OpenTelemetry adapter.Observability
ToolOverrideRetained compatibility model; current local and MCP compilation paths do not apply these overrides.Core
MCPServerConfiguration for connecting an external MCP server (stdio or HTTP transport) as a tool provider. MCP tools run locally in your environment.MCP
MCPAutoSetupAuto-setup helper for uvx-based MCP servers.MCP
MCPSoftErrorHandlingRetained model; current MCP execution does not apply this policy.MCP

#How an agent runs

When you call invoke() or stream(), the SDK compiles your tools, dependencies, and config into a request and hands it to the orchestrator. The orchestrator plans which tools to call (planning sees only the tool schemas, never your code), executes them locally in your process, and synthesizes a response. You read the result from InvokeResponse, or consume incremental StreamEvent values.

The async methods (ainvoke / astream) mirror the synchronous ones for native asyncio code, and batch / abatch run independent requests concurrently while preserving input order.

#Decorators

Decorators define tools and declare how a tool relates to other tools, agents, secret data, and the user. @toolify turns a function or Pydantic model into a tool; @toolset marks a class whose methods become tools. Dependency decorators are applied beneath @agent.toolify(...) (or beneath @swarm.member), or chained off the builder returned by toolify(...). See the Dependencies guide for the full data-flow model.

DecoratorDescriptionReference
@toolifyRegister a function or Pydantic model as a tool.Decorators
@toolsetMark a class whose @toolify-marked methods register as a group of tools.Decorators
@depends_on_toolInject another tool's output as an argument.Decorators
@depends_on_agentInject another agent's output as an argument (swarm workflows).Decorators
@depends_on_private_dataInject a declared private value at execution time; the model plans against the schema and never sees the raw value.Decorators
@depends_on_interruptPause to collect user input mid-execution.Decorators
@depends_on_await_forGate a tool behind another tool's run without consuming its output.Decorators
@depends_on_reevaluateTrigger orchestrator reevaluation after the tool runs, so the plan can adapt.Decorators
@requires_producer_referenceDeclare that a tool argument requires a reference produced by a named upstream tool.Decorators

Artifact production uses generator toolsets from maivn-tools. These tools run in the user's tool environment and return GeneratedFile values through the normal artifact intake. Stored DOCX, XLSX, and PPTX files are downloadable but do not have an inline preview; PDF, PNG, and JPEG do.

Python
from maivn import depends_on_tool

@agent.toolify(description='Fetch raw sensor data')
def fetch_sensor_data(sensor_id: str) -> dict:
    return {'sensor_id': sensor_id, 'readings': [72, 73, 71]}

@agent.toolify(description='Analyze sensor readings')
@depends_on_tool(fetch_sensor_data, arg_name='sensor_data')
def analyze_readings(sensor_data: dict) -> dict:
    readings = sensor_data['readings']
    return {'average': sum(readings) / len(readings)}

#Configuration

Two kinds of configuration exist. SDK configuration describes the environment (credentials, timeouts, defaults) and is usually built once from the environment. Session config models are typed objects that carry per-scope or per-call runtime controls; pass them to Agent(...) / Swarm(...) as defaults, or to invoke() / stream() as overrides.

#SDK configuration

ItemDescriptionReference
MaivnConfigurationTop-level SDK environment/configuration model.Configuration
ConfigurationBuilderBuild SDK configuration from environment variables.Configuration
get_configuration()Return the current SDK configuration.Configuration

#Session config models

ItemDescriptionReference
MemoryConfigMemory retrieval, summarization, and persistence controls.Session Config
SystemToolsConfigAllowlists and approvals for built-in system tools (web_search, repl, think).Session Config
SessionOrchestrationConfigRetained compatibility schema; current invocations do not send it to the runtime.Session Config
MemoryAssetsConfigCompatibility schema for skill/resource metadata.Session Config
SwarmConfigCompatibility schema for swarm metadata.Session Config
StructuredOutputConfigCompatibility schema for structured-output metadata.Session Config
SessionExecutionConfigCompatibility schema; not sent during current invocations.Session Config
FinalOutputMode, OrchestrationMode, StopStrategyLiteral aliases used by SessionOrchestrationConfig.Session Config

Memory has a dedicated family of resource and policy models (MemoryInsight, MemoryResource, MemorySkill, OrganizationMemoryPolicy, and related enums). See the Memory and Recall guide for how they fit together.

#Privacy and private data

These models declare and govern sensitive values so the SDK can keep them out of model-visible context. The model plans against a schema of key names and types; real values are injected at tool-execution time, and tool results are scanned and redacted before returning to the model. See the Private Data guide.

These are technical controls, not certifications or guarantees. mAIvn holds no SOC 2, HIPAA, ISO 27001, or FedRAMP certification, cannot provide a BAA, and does not make a deployment compliant. Evaluate the controls at your own risk under the mAIvn Platform Disclaimer.

ItemDescriptionReference
PrivateDataDeclares a known private value with a custom key name, label, type, and format hint.Private Data guide
RedactedMessageA user message whose sensitive spans are detected and substituted with placeholders.Private Data guide
PIIWhitelist, PIIWhitelistEntryMark specific values, patterns, or entity types as safe to pass through, with required justification. phi_mode refuses entity-type entries for HIPAA Safe Harbor categories.Private Data guide
HIPAA_SAFE_HARBOR_CATEGORIESExported constant: the HIPAA Safe Harbor identifier categories.Private Data guide
RedactionPreviewRequest, RedactionPreviewResponsePreview payload models; the current public SDK has no preview transport method.Private Data guide

#Messages

Import message types from maivn.messages. These are the inputs you pass to invoke() / stream() and the assistant turns the SDK returns.

ClassDescriptionReference
HumanMessageUser input message.Messages
AIMessageAssistant response message.Messages
SystemMessageSystem prompt message.Messages
RedactedMessageRequests runtime redaction before model processing.Messages

#Logging

FunctionDescriptionReference
configure_logging()Initialize SDK logging (optionally to a file).Logging
get_logger()Return the SDK logger instance.Logging

#Events

The events surface lets you stream execution state (tool calls, phase indicators, the final response) into your own backend and frontend. The canonical normalize_stream() helper converts a raw stream into a stable, versioned AppEvent contract, payload builders construct individual event payloads, and EventBridge mounts an SSE endpoint. See the Events reference and the Frontend Events guide for the browser client example.

ItemDescriptionReference
AppEvent, UIEvent, RawSSEEventPublic event models for normalized, UI, and raw stream events.Events
APP_EVENT_CONTRACT_VERSIONVersion constant for the AppEvent contract.Events
normalize_stream, normalize_stream_eventConvert raw stream events into the canonical AppEvent shape.Events
build_*_payloadBuilders for individual event payloads (enrichment, final, tool, status message, interrupt, session start, and more).Events
EventBridge, BridgeRegistry, BridgeAudienceMount and manage an SSE bridge with an audience scope.Events
EventBridgeSecurityPolicy, BackpressurePolicyTrust-boundary and backpressure controls for the bridge.Events
forward_normalized_event, forward_normalized_streamForward normalized events/streams to a downstream consumer.Events
NormalizedStreamState, NormalizedEventForwardingStateState objects for normalization and forwarding.Events
Note Enrichment events are fixed-label phase indicators (for example, "Evaluating request", "Planning actions", "Synthesizing response") streamed between tool calls so consumers can show what the system is doing. Status messages are a separate event family that may appear on the same stream.

#Decisions

The prepared maivn.decisions feature set provides categorical requests, locally authorized platform calls, fallback diagnostics, native batching, before/after invocation plans, typed arguments, function/local-tool dependencies and optional matching. Use the ordinary mAIvn key and platform address; no provider credential or model selector is exposed. See the Decisions API, guide and examples.

#Run telemetry

maivn.telemetry publishes the customer-visible run lifecycle as a closed, versioned metadata schema. The optional maivn[otel] adapter maps runs to traces and tool calls to spans without exporting messages, prompts, arguments, results, or resolved private values. See Run Telemetry.

#Scheduling

Any Agent or Swarm can run on a schedule. cron(...), interval(...), and at(...) return a chainable builder. A remote terminal call returns a durable Trigger. An explicit mode="local" call returns a process-owned ScheduledJob. See the Scheduling reference and the Scheduled Invocation guide.

ItemDescriptionReference
scope.cron(...) / interval(...) / at(...)Build a durable remote trigger or explicitly local scheduled invocation.Scheduling
CronInvocationBuilderChainable builder over invoke / stream / batch and async variants.Scheduling
ScheduledJobLifecycle handle returned by terminal builder calls (on_fire, on_error, stop).Scheduling
JitterSpec, JitterDistributionBounded randomness around fire times.Scheduling
Retry, RetryBackoffRetry policy with constant / linear / exponential backoff.Scheduling
Schedule, CronSchedule, IntervalSchedule, AtScheduleSchedule descriptor models.Scheduling
MisfirePolicy, OverlapPolicyPolicies for missed and overlapping fires.Scheduling
RunRecord, RunStatusOutcome of a single fire.Scheduling
list_jobs() / stop_all_jobs()Process-wide registry helpers.Scheduling

#Token usage and billing

Responses expose runtime-reported token usage as an extensible dictionary. The public billing models validate aggregated plan and quota payloads, but the current public Client does not fetch those payloads. See the Billing reference and the Billing and Usage guide.

#Quick navigation by goal

#Next steps

#Version

Python
from maivn import __version__
print(__version__)