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.6.0.tar.gz (104.8 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.6.0-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uniqos-0.6.0.tar.gz
  • Upload date:
  • Size: 104.8 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.6.0.tar.gz
Algorithm Hash digest
SHA256 f742afb6069199985c3fea674b17ff7c7d6fa636bfd3e51a9565c4624483924f
MD5 88270a708fe2c9a236c700288c10eaf5
BLAKE2b-256 83c4ddccc8d655ded36d1cf7a89fd5e3a77312a127b05c354344503744071f45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uniqos-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 40.8 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10307f4b3eb6e8ad1fd3cfedf2dc106f291f2e0b5ae7f9b6fda6008149ede2c2
MD5 b48ac3f5d78c95e8ce7957caf613568a
BLAKE2b-256 2283a08dbe1a85dbf910106d54f03f80c7eddb21258c07d04fce0b8fd56b1b87

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