Skip to main content

Official Python SDK for Nirium autonomous agents on Stellar (x402 + MPP)

Project description

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

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()
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

Project details


Download files

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

Source Distribution

nirium-0.6.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

nirium-0.6.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file nirium-0.6.2.tar.gz.

File metadata

  • Download URL: nirium-0.6.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nirium-0.6.2.tar.gz
Algorithm Hash digest
SHA256 762dea130a79c85bba77f6a98bb2202eb65d33f0e9b1d4bc7855935e274f127f
MD5 83360db37359e1aa1f8244cafc95d67c
BLAKE2b-256 547e3f0cb5e42f77d871f8802802b3b39505d6707cedc7ded64486431bfc0f47

See more details on using hashes here.

File details

Details for the file nirium-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: nirium-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nirium-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b5b56c67dfc88e26c7a6acbb3c6a10f00fa2d1b642f6d84788df1699c5e85a77
MD5 7e4da60d756040aad8b7553005a64aa4
BLAKE2b-256 cb4e12b5caf8bd006b6abcd4a80e9866cf722a461c6ce4052f0b1efec9864dd1

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