Skip to main content

Official uniqOS SDK — Personality & Emotional Intelligence Engine + Relational Memory for AI agents.

Project description

uniqos

Official Python SDK for uniqOS — a Personality & Emotional Intelligence Engine + Relational Memory layer for AI agents.

  • Sync and async clients (UniqOS / AsyncUniqOS)
  • Typed errors, automatic retries with backoff, automatic idempotency keys
  • SSE streaming as a plain iterator
  • Fully type-hinted (py.typed); one runtime dependency (httpx)
  • Python 3.10+

Install

pip install uniqos

Quickstart

from uniqos import UniqOS

client = UniqOS(api_key="uniq_test_...")
response = client.respond(personality_id="pers_...", message="hola", mode="stateless")

response is the parsed JSON (snake_case, mirroring the API): response["response"] is the agent's reply.

We pass mode="stateless" explicitly because catalog personalities default to stateful, which keeps per-user memory and therefore requires a user_id. For a stateful conversation, pass mode="stateful" and a user_id; see the stateless vs stateful guide.

Get an API key from the uniqOS dashboard. Keys start with uniq_live_ (production) or uniq_test_ (sandbox); the SDK detects the environment from the prefix and rejects a malformed key immediately.

Async

from uniqos import AsyncUniqOS

async with AsyncUniqOS(api_key="uniq_test_...") as client:
    response = await client.respond(personality_id="pers_...", message="hola")

Both clients expose the identical surface (client.personalities, client.end_users, client.billing, …); the async one just awaits.

Streaming

stream = client.respond(personality_id="pers_...", message="tell me a story", stream=True)
for event in stream:
    if event.type == "text":
        print(event.delta, end="", flush=True)
    elif event.type == "completion":
        print(f"\n[{event.latency_ms}ms]")

The five event types (metadata, text, guardrail_modulation, completion, error) are typed dataclasses with attribute access. Async uses async for.

Errors

from uniqos import RateLimitError, QuotaExhaustedError

try:
    response = client.respond(personality_id="pers_...", message="hi")
except RateLimitError as err:
    print(f"Rate limited. Retry after {err.retry_after_seconds}s")
except QuotaExhaustedError as err:
    print(f"Quota exhausted: {err.details}")

Every error carries code, message, request_id, http_status, and details. Catch UniqOSError for anything the SDK can raise. The SDK retries transient failures (429 rate_limit_exceeded, 500/502/503, network) automatically with exponential backoff; it never retries quota_exhausted, 401, 403, or 504 turn_timeout (see Configuration below).

Configuration

client = UniqOS(
    api_key="uniq_test_...",
    base_url="https://api.uniqos.ai",  # host only; do NOT include /v1
    timeout=90,                         # seconds; default 90s; 0 disables
    max_retries=3,                      # 0 disables retries (504 is never auto-retried)
    log_level="warning",               # debug | info | warning | error | silent
    logger=my_logger,                   # optional: any object with debug/info/warning/error
)

Default timeout is 90s, deliberately above the server's ~75s turn ceiling, so a slow turn surfaces as the server's clean 504 turn_timeout (a TurnTimeoutError) instead of a client-side abort. A 504 turn_timeout is not retried automatically: the turn already ran to the budget, so a blind retry risks a second long turn and — combined with client-vs-server timing — a double bill (ADR-0009). Retrying it is your explicit choice.

The SDK never logs the full API key (only the prefix) nor message content beyond 50 chars.

Examples

Runnable scripts live in examples/: hello_world.py, stateful.py, streaming.py, error_handling.py, and dogfood.py.

With a real (or local) API — set the environment and run:

export UNIQOS_API_KEY="uniq_test_..."
export UNIQOS_PERSONALITY_ID="pers_..."
# optional, for a local backend:
export UNIQOS_BASE_URL="http://localhost:3000"

python examples/hello_world.py

Without a network — the test suite drives every code path against a mocked HTTP layer (respx), so no live API is needed to exercise the SDK:

import httpx, respx
from uniqos import UniqOS

@respx.mock
def test_it():
    respx.post("https://api.uniqos.ai/v1/respond").mock(
        return_value=httpx.Response(200, json={"response": "hi"})
    )
    with UniqOS(api_key="uniq_test_abcd1234") as client:
        assert client.respond(personality_id="p_1", message="hi")["response"] == "hi"

Documentation

Full reference and guides live at docs.uniqos.ai. This README and the in-editor docstrings cover the essentials; the deep documentation is not duplicated here.

License

MIT

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

uniqos-0.5.0.tar.gz (102.2 kB view details)

Uploaded Source

Built Distribution

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

uniqos-0.5.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file uniqos-0.5.0.tar.gz.

File metadata

  • Download URL: uniqos-0.5.0.tar.gz
  • Upload date:
  • Size: 102.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for uniqos-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1579490d8e6cfe233cadb8339ef4452bdef318e2748b3990c3cb6889ceb8a537
MD5 bdb48ec94d2f43e2295c42e33ce89d8f
BLAKE2b-256 1e81c251e750ef6e212488fbaeaaabd553b0fbecfcefecf6f95090b87debb38e

See more details on using hashes here.

File details

Details for the file uniqos-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: uniqos-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for uniqos-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 553eb3352e9f739306820872ebdbc1dcd9bb6c980d2db24dbf0960b08f665486
MD5 4a0c70f6a07d80cab92d24050c0ea71f
BLAKE2b-256 05933311872654e9ce0672604c8a9c97fb191c956ee7867fbfb77c6a97f597bb

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