Skip to main content

nirium

Official Python SDK for the Nirium Protocol — autonomous AI treasury infrastructure on Stellar/Soroban.

Nirium agents rebalance USDC ↔ CETES (tokenized Mexican T-bills via Etherfuse) 24/7 without human intervention. Built for developers who want to integrate autonomous treasury management, agentic payments (x402 + MPP), and real-time market signals into their applications.

Install

pip install nirium

Quick Start

import asyncio
from nirium import Agent

agent = Agent(
    api_url="https://nirium-agent.fly.dev",
    api_key="sk_inst_your_key_here",
)

async def main():
    # Health check
    alive = await agent.ping()
    print(f"Agent alive: {alive}")

    # Real market data from Stellar Horizon
    market = await agent.get_market()
    print(f"XLM Price: ${market['xlmPrice']:.4f}")

    # Execute a treasury rebalance strategy
    result = await agent.execute("blend-yield", "USDC", {"amount": 5000})
    print(f"Success: {result['success']} | TX: {result.get('txHash')}")

asyncio.run(main())

Real-Time Signals (WebSocket)

agent = Agent(api_url="https://nirium-agent.fly.dev", api_key="sk_inst_...", token="eyJhbG...")

@agent.on("signal")
async def on_signal(data):
    print(f"Signal: {data['signal_type']}{data['data']['details']}")

asyncio.run(agent.subscribe())

Authentication

# API Key for REST endpoints
agent = Agent(api_url="https://nirium-agent.fly.dev", api_key="sk_inst_...")

# With JWT token for WebSocket
agent = Agent(api_url="https://nirium-agent.fly.dev", api_key="sk_inst_...", token="eyJhbG...")

Payment Protocols

x402 — Pay-Per-Request

agent.init_x402(
    secret_key="S...",          # Stellar secret key
    network="stellar:testnet"
)

response = await agent.x402_fetch("https://nirium-agent.fly.dev/api/v1/premium/signals")

MPP — Session-Based Budget Delegation

agent.init_mpp(
    secret_key="S...",
    network="stellar:testnet",
)

response = await agent.mpp_fetch("https://nirium-agent.fly.dev/api/v1/mpp/signals")

Endpoint Access Model

Access Endpoints
Public (no key) health, loop/status, execute-demo, signals/recent, skills list
Protected (API key) execute, market, loop/start|stop|scan, subscriptions, skills/install, webhooks
WebSocket (JWT) /ws/signals — real-time signal stream
x402 Premium /api/v1/premium/signals ($0.02 USDC), /api/v1/premium/market ($0.05 USDC)
MPP /api/v1/mpp/signals, /api/v1/mpp/market

Payouts

Batch disbursement, non-custodial: the node builds an unsigned transaction, you sign it with your own wallet and broadcast it. Nirium never holds funds and never sees your keys.

run = await agent.create_payout_run(
    recipients=[{"wallet": "GABC...", "amount": "250.00"}],
    acknowledge_terms=True,   # required on every network — 403 without it
)

signed_xdr = sign_with_your_wallet(run["xdr"])
settled = await agent.submit_payout(run["runId"], signed_xdr)
print(settled["txHash"], settled["cid"])   # on-chain hash + IPFS receipt

Licensed for independent service payments only — contractors, freelancers, B2B. Not for subordinate-employee salary. Read get_payout_terms() before integrating; classifying recipients and meeting tax and labor obligations is the client's responsibility.

Mainnet is invite-only during early access and additionally requires client_info.

Audit Trail

Anchor evidence to IPFS and get back a CID — an integrity seal, not notarization.

anchor = await agent.anchor_audit_record(
    hash="sha-256:9f86d081...",   # hash of your own file or event
    tag="invoice-batch-jul",
)
print(anchor["cid"])

Anchor a hash rather than the data itself: IPFS content cannot be deleted, so raw personal data would outlive any erasure request.

API Coverage

Category Methods
Health ping(), health(), system_health()
Execution execute(), execute_demo()
Market get_tickers(), get_market(), get_stats(), get_loop_status(), start_loop(), stop_loop(), trigger_scan()
Signals create_subscription(), get_subscriptions(), delete_subscription(), get_subscription_stats(), get_recent_signals()
Skills get_skills(), install_skill(), uninstall_skill(), get_skill_marketplace(), execute_skill_action()
Strategies get_strategies()
Webhooks register_webhook(), get_webhooks(), delete_webhook(), test_webhook()
Auth get_auth_token(), create_auth_key(), get_auth_keys(), revoke_auth_key()
Revenue get_revenue(), get_info()
Nodes get_nodes()
Payouts create_payout_run(), submit_payout(), onboard_payout_recipient(), submit_payout_onboard(), get_payout_runs(), get_payout_terms(), get_payout_info()
Audit Trail anchor_audit_record(), get_audit_info()
Reporting get_reporting_summary(), get_reporting_export()
Admin configure_llm()
WebSocket subscribe(), on() decorator
x402 Payments init_x402(), x402_fetch()
MPP Payments init_mpp(), mpp_fetch()

Requirements

  • Python >= 3.10
  • aiohttp >= 3.9.0
  • websockets >= 13.0

Links

License

Apache 2.0 — Nirium Protocol

Release files for nirium 0.9.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 nirium 0.9.1
File Size Uploaded
nirium-0.9.1.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nirium 0.9.1
File Interpreter ABI Platform
nirium-0.9.1-py3-none-any.whl Python 3 none any Details

Total release size:26.9 kB

Release files / nirium-0.9.1.tar.gz

Download URL nirium-0.9.1.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
754822222b91619558470406cab8837746ad5ee98182d25a00b5e08fc002775b
BLAKE2b-256 checksum
How to use checksums
59e6a5657f5a068b76d52d59c94ca6135b02fe78715a6245c01b5837edb68529
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / nirium-0.9.1-py3-none-any.whl

Download URL nirium-0.9.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cd6bfa4280de64554f68b41b01142f74c6afb02764bb2613256149ec80d5664
BLAKE2b-256 checksum
How to use checksums
5df5394e8abd3c22f6e48db21fc032ac627ec26c5d7f4bedac66237bc84b72ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.11.0

2 release files

0.10.0

2 release files

0.9.2

2 release files

This release

0.9.1 This release

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.2.1

2 release files

0.2.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