Skip to main content

sannex-agent

Official Python SDK for the Sannex AICB Platform — connects standalone AICB bot engines to the AgentOS dashboard via telemetry tracking and remote config sync.

PyPI version License: MIT

Installation

pip install sannex-agent
# or
uv add sannex-agent

How it works

AgentOS Dashboard (Supabase)
       ??  sannex-agent SDK
AICB Engine (standalone FastAPI bot)
  • AICB calls get_config() to pull system prompt, knowledge docs, and catalog from AgentOS.
  • AICB calls track() after every message/order to push telemetry back.
  • FastAPI streaming endpoints use stream_chat() for SSE responses to the Telegram Mini App.

Quick Start (Sync — for scripts & workers)

from sannex_agent import SannexClient

client = SannexClient(
    api_key="snx_bot_xxxx",
    host="https://agentos.aicb.sannex.ng",
)

Quick Start (Async — for FastAPI)

from sannex_agent import AsyncSannexClient

client = AsyncSannexClient(
    api_key="snx_bot_xxxx",
    host="https://agentos.aicb.sannex.ng",
)

API Reference

get_config() / await client.get_config() — Pull config from AgentOS

# Sync
config_resp = client.get_config()

# Async
config_resp = await client.get_config()

print(config_resp.config.system_prompt)
print(config_resp.config.model_name)        # "gemini-2.5-flash"
print(len(config_resp.knowledge_docs))      # RAG docs
print(len(config_resp.catalog_items))       # Product catalog

track() / await client.track() — Push telemetry

Non-blocking. Batches and flushes in the background. Never raises.

# Sync (thread-safe, fire-and-forget)
client.track(
    channel="telegram",
    customer_id="tg_123456",
    event="order_created",
    amount=45000.0,
    metadata={"order_id": "ORD-001"},
)

# Async
await client.track(
    channel="whatsapp",
    customer_id="+2348012345678",
    event="message_received",
)

stream_chat() — Stream AI responses (SSE)

# Sync
for chunk in client.stream_chat("What dresses do you have?", user_id="user_123"):
    print(chunk, end="", flush=True)

# Async (FastAPI SSE endpoint)
async for chunk in client.stream_chat("What dresses do you have?", user_id="user_123"):
    yield f"data: {chunk}\n\n"

ping() / await client.ping() — Health check

is_up = client.ping()          # sync
is_up = await client.ping()    # async

get_bot() / await client.get_bot() — Bot identity

bot = client.get_bot()
print(bot.name)      # "Elena Luxe Bot"
print(bot.reseller)  # "Sannex Digital Agency"

FastAPI AICB Engine Integration

# aicb_engine/main.py
import os
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from sannex_agent import AsyncSannexClient, ChatMessage

sannex = AsyncSannexClient(
    api_key=os.environ["BOT_API_KEY"],
    host=os.environ.get("AGENTOS_URL", "https://agentos.aicb.sannex.ng"),
)

@asynccontextmanager
async def lifespan(app: FastAPI):
    # Pull config from AgentOS on startup
    config = await sannex.get_config()
    app.state.system_prompt = config.config.system_prompt
    app.state.knowledge_docs = config.knowledge_docs
    app.state.catalog_items = config.catalog_items
    yield
    await sannex.close()

app = FastAPI(lifespan=lifespan)

@app.post("/v1/chat")
async def chat(message: str, user_id: str):
    async def event_stream():
        async for chunk in sannex.stream_chat(message, user_id):
            yield f"data: {chunk}\n\n"
        yield "data: [DONE]\n\n"

    # Track the conversation event
    await sannex.track(
        channel="telegram",
        customer_id=user_id,
        event="message_received",
    )

    return StreamingResponse(event_stream(), media_type="text/event-stream")

Context Manager (Sync)

with SannexClient(api_key="snx_bot_xxxx") as client:
    config = client.get_config()
    # ... use client
# auto-flushes and closes on exit

Context Manager (Async)

async with AsyncSannexClient(api_key="snx_bot_xxxx") as client:
    config = await client.get_config()
    # ... use client

Environment Variables

BOT_API_KEY=snx_bot_xxxx              # From AgentOS Bot Settings
AGENTOS_URL=https://agentos.aicb.sannex.ng  # AgentOS host

Response Models (Pydantic v2)

All responses are typed Pydantic models:

from sannex_agent import SannexConfigResponse, BotConfig, KnowledgeDoc, CatalogItem, BotInfo

License

MIT — Sannex Tech LTD

Download files

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

Source Distribution

sannex_agent-0.1.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

sannex_agent-0.1.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file sannex_agent-0.1.3.tar.gz.

File metadata

  • Download URL: sannex_agent-0.1.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for sannex_agent-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b7f9ca12307656d27666eb4baf81491c0b4f48aabd3b8b9d54cdce4ba3eb8695
MD5 297f9563c65218d1abd1156ca760332f
BLAKE2b-256 04ee787a362405f8d9abfa748c99d6e55ae4d1e70489808ea96d54c13cdf4e3d

See more details on using hashes here.

File details

Details for the file sannex_agent-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sannex_agent-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for sannex_agent-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e58a32ad4a51cbb1fd1886f49e9dd16f9b9a1010cfcc1f1632fd87bf8a5201bc
MD5 4c436451b3bcf4f7537d1e8108b1d0c3
BLAKE2b-256 7af4b59f7a5cf5f2057c36895b87fccc2c539b4b6ba3e9198910d9f2db65ddef

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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