Skip to content

Documentation navigation

Upgrading to the mAIvn SDK 2.0

Update from SDK 0.x: what moved, what was removed, and what to check before you deploy.

#Upgrading to the mAIvn SDK 2.0

SDK 2.0 is the SDK for mAIvn Platform v2. SDK 0.x targeted the previous platform, which is retired, so 2.0 is a new major version and not an in-place upgrade. The package name is still maivn. The client, configuration and command-line tool changed with the platform. This page covers what moved, what was removed and what to check before you deploy. The SDK repository's MIGRATION.md records the packaging facts.

#Who needs to do anything

Everyone who moves from 0.x. Upgrade the package, then work through Configuration changes and Import changes and re-run your tests. If your code imports event helpers, or calls compose_artifact_policy, get_interrupt_service or set_interrupt_service, the later sections apply to you as well.

#1. Upgrade

Shell
python -m pip install -U maivn

In a uv project:

Shell
uv add maivn -U

SDK 2.x requires Python 3.10 or newer. Optional extras:

Shell
python -m pip install "maivn[fastapi,otel,rich]"

maivn-tools, the optional connectors package, needs Python 3.12 or newer.

Packaging changed as well:

0.4.32.0.0
Contractsmaivn-sharedmaivn-contracts (new package)
Private data storagenot includedprivate-data-vault (new package)
Terminal outputrich requiredrich optional, through maivn[rich]
Removed dependenciesdocstring-parser, prompt-toolkit, python-dotenv, tzlocal
Console scriptmaivnmaivn (unchanged name)

The CLI in 2.x has the commands serve, dev-tunnel, watch-files, connections, studio and version. Run maivn --help to list them.

#2. Your API keys keep working

Project API keys issued for SDK 0.x still authenticate after you upgrade, so there is nothing to rotate. Keep the same MAIVN_API_KEY value, or pass the same key to Client(api_key=...) or Agent(api_key=...).

SDK 2.x reads the key from api_key= or from MAIVN_API_KEY, and it can also read a single-line key file or a dotenv file that you select. See Authentication. A key that was revoked is rejected with a 401; create a new one for the project in the Developer Portal. See API Keys and Webhooks.

#3. Configuration changes

SDK 2.0 reads one renamed environment variable for the service address:

SDK 0.xSDK 2.0
MAIVN_SERVER_BASE_URLMAIVN_BASE_URL

There is exactly one address to set: mAIvn has a single public API entry point, and every SDK request goes there. If you never set MAIVN_SERVER_BASE_URL, there is nothing to change: the SDK 2.0 default address is https://api.maivn.io.

MAIVN_API_KEY is unchanged.

#4. Import changes

The event and streaming helpers live in maivn.events, not in the top-level maivn module. Update any import of them that still points at maivn.

Before (SDK 0.x):

Python
from maivn import (
    AppEvent,
    EventBridge,
    RawSSEEvent,
    build_final_payload,
    normalize_stream,
)

After (SDK 2.0):

Python
from maivn.events import (
    AppEvent,
    EventBridge,
    RawSSEEvent,
    build_final_payload,
    normalize_stream,
)

This covers AppEvent, UIEvent, RawSSEEvent, EventBridge, EventBridgeSecurityPolicy, BridgeAudience, BridgeRegistry, NormalizedStreamState, NormalizedEventForwardingState, APP_EVENT_CONTRACT_VERSION, every build_*_payload helper, forward_normalized_event, forward_normalized_stream, normalize_stream and normalize_stream_event. If an import fails after the upgrade and names one of these, move it to maivn.events.

These still import from maivn: Agent, Swarm, Client, ModelConfig, the tool_output, toolify and toolset decorators, the depends_on_* decorators, the memory and resource configuration models, and the schedule types (CronSchedule, IntervalSchedule and AtSchedule).

#5. Removed APIs and what to use instead

Three names are not in SDK 2.x. Each has a replacement.

compose_artifact_policy: SDK 2.x exports compose_argument_policy for the same job. It controls whether the compose_argument system tool may write one argument of a tool. mode is 'allow', 'require' or 'forbid'. approval='explicit' refuses composition unless the "tool.argument" target appears in the allow-list on your Agent or Swarm:

Python
from maivn import Agent, SystemToolsConfig, compose_argument_policy

@compose_argument_policy('summary', mode='allow', approval='explicit')
def report_tool(summary: str) -> dict:
    return {'summary': summary}

agent = Agent(
    name='assistant',
    api_key='your-api-key',
    tools=[report_tool],
    system_tools_config=SystemToolsConfig(
        approved_compose_argument_targets=['report_tool.summary'],
    ),
)

See Decorators for every parameter. If you used compose_artifact_policy as a compliance control, re-test that control after the move.

get_interrupt_service / set_interrupt_service: these managed a process-global interrupt service. SDK 2.x has no global registry. Pass your input handler directly where you declare the dependency instead:

Python
from maivn import depends_on_interrupt

@depends_on_interrupt('approval', input_handler=my_input_handler, prompt='Approve this action?')
def send_email(approval, **kwargs):
    ...

If you previously swapped the global service in tests, construct and pass a handler per test instead of installing one globally.

#6. Other changes to check

MIGRATION.md states that the client, the configuration and the CLI changed with the platform. Review each of these against your 0.x code:

  • Client and configuration. Client takes api_key, env_file, api_key_file, base_url, timeout_seconds (alias timeout), thread_id and the other options in the Client reference. Connection settings come from the variables in Authentication.
  • CLI. Use the commands listed in step 1.
  • Results. InvokeResponse has .response, .result, .tool_names, .artifacts and .assistant_id. See Shared Data Models.

Run your test suite against SDK 2.x before you deploy, and read the changelog for anything added since 2.0.

#7. Calling the HTTP API directly

If your application talks to the HTTP API directly instead of through the maivn package, the REST API changed along with everything above. Do not guess at the new request or response shapes from this guide. Work from the API Reference instead.

#Next steps