Skip to main content

Official Python client SDK for Marona-compatible AI runtimes and Hub integrations.

Project description

marona

Official Python client for Marona-compatible AI runtimes and Hub integrations.

Use marona to build web apps, mobile backends, WhatsApp bots, desktop apps, devices, smart glasses, and agents that need one API for online, offline, and hybrid AI execution.

Install

pip install marona

Complete Example

This example shows the normal flow for a developer application:

  1. Create a Marona client.
  2. Sync Hub metadata into the local cache.
  3. Connect approved Hub apps by app ID.
  4. Send a user message through the runtime.
  5. Print the final assistant response.
import asyncio
import os

from marona import Marona


async def main() -> None:
    api_key = os.environ["MARONA_API_KEY"]
    identity_token = os.getenv("MARONA_IDENTITY_TOKEN")

    async with Marona(api_key=api_key, mode="online") as marona:
        await marona.sync(
            interface="api",
            identity_token=identity_token,
            conversation_id="quickstart",
        )

        tools = await marona.hub.connect(
            ["sda-books", "zimsec"],
            adapter="tools",
        )

        response = await marona.message(
            "Find chapter 1 of Steps to Christ and explain the main point.",
            interface="api",
            identity_token=identity_token,
            conversation_id="quickstart",
            tools=tools,
        )

        print(response.text)


asyncio.run(main())

Run it:

export MARONA_API_KEY="mrn_live_..."
python app.py

If the user has paired an interface or connected private apps, pass their identity token as MARONA_IDENTITY_TOKEN. Public apps can still work without a user identity when they do not require personal authorization.

Pair A User

Use pairing when an interface needs to become the same user across web, mobile, WhatsApp, wearables, or another client surface.

async with Marona(api_key=os.environ["MARONA_API_KEY"]) as marona:
    pairing = await marona.start_pairing(
        interface="web",
        device_name="Customer web chat",
    )

    print(pairing.display_code)
    print(pairing.whatsapp_url)

    status = await marona.pairing_status(pairing.pairing_id)
    print(status.status)

After the user confirms the pairing, store the returned identity token in your application and pass it to marona.message(...).

Online, Offline, And Hybrid Modes

Choose one runtime mode for the client:

  • online: use online runtime and online app routes.
  • offline: use only local cache, local/private models, and installed offline-capable app targets.
  • hybrid: try local/private execution first, then use online runtime when allowed.

Apps also declare one availability mode:

  • online: online only.
  • offline: offline only.
  • hybrid: online and offline capable.

Hybrid is a single mode. Do not declare online + offline + hybrid; declare hybrid.

Hybrid Or Offline With A Local/Private Model

Register a local or private model endpoint once, then use it as the default for hybrid or offline execution.

async with Marona(api_key=os.environ["MARONA_API_KEY"], mode="hybrid") as marona:
    await marona.sync(interface="api")

    marona.models.register(
        name="office-model",
        endpoint="http://localhost:9379",
    )
    marona.models.use("office-model")

    tools = await marona.hub.connect(["sda-books", "zimsec"], adapter="tools")

    response = await marona.message(
        "Summarize the chapter about faith.",
        interface="desktop",
        conversation_id="local-demo",
        tools=tools,
    )

    print(response.text)

In offline mode, Marona never calls public cloud runtime. If a model or an offline-capable app target is missing, the client returns a clear offline error.

Attach Files

from pathlib import Path

from marona import RuntimeAttachment


attachment = RuntimeAttachment.from_bytes(
    Path("proposal.pdf").read_bytes(),
    filename="proposal.pdf",
    mime_type="application/pdf",
    kind="document",
)

response = await marona.message(
    "Summarize this proposal.",
    attachments=[attachment],
)

Interface Names

interface identifies the client surface making the request. Standard values:

  • api
  • web
  • mobile_app
  • desktop
  • whatsapp

Future devices can use custom lowercase slugs such as smart_glasses, vehicle_console, or kiosk.

Related Packages

  • Python client: marona, import marona
  • Dart client: marona, import package:marona/marona.dart
  • TypeScript client: marona, import Marona from "marona"
  • Developer SDK for building apps: marona-sdk, import marona_sdk

Project details


Release history Release notifications | RSS feed

This version

0.2.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marona-0.2.8.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marona-0.2.8-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file marona-0.2.8.tar.gz.

File metadata

  • Download URL: marona-0.2.8.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for marona-0.2.8.tar.gz
Algorithm Hash digest
SHA256 03b6f1b519cdf80286afdb18e2966f87596e37a95649ffbd90d5d21c9e5e3a81
MD5 38d7dbb4c70d9f7ed74c72a81cedf98f
BLAKE2b-256 21481e2c6f260e0c6e47de3f84c1fb5fde4bbfe6a512c9d14862ff619eb48b67

See more details on using hashes here.

File details

Details for the file marona-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: marona-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for marona-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ea3485981a67420a25cad92328b35c5ae66fd4fcd7f24f0dd16b158e25594ce1
MD5 1f575fbd6d1f3b094f9900de45c09626
BLAKE2b-256 4a0baab8e56acdc0569cbebbee92e4c153820fa908b83d571f9981e436d705f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page