Skip to main content

Python SDK for TinyHumans API - ingest and delete memory

Project description

tinyhuman

Python SDK for the TinyHumans API.

Requirements

  • Python ≥ 3.9
  • httpx >= 0.25

Install

pip install tinyhuman

Quick start (synchronous)

from tinyhumansai import (
    TinyHumanMemoryClient,
    TinyHumanConfig,
    IngestMemoryRequest,
    ReadMemoryRequest,
    DeleteMemoryRequest,
    MemoryItem,
)

client = TinyHumanMemoryClient(TinyHumanConfig(token="your-api-key"))

# Ingest (upsert) memory
result = client.ingest_memory(
    IngestMemoryRequest(
        items=[
            MemoryItem(
                key="user-preference-theme",
                content="User prefers dark mode",
                namespace="preferences",
                metadata={"source": "onboarding"},
            )
        ]
    )
)
print(result)  # IngestMemoryResponse(ingested=1, updated=0, errors=0)

# Read memory
items = client.read_memory(ReadMemoryRequest(namespace="preferences"))
print(items.count, items.items)

# Delete by key
client.delete_memory(DeleteMemoryRequest(key="user-preference-theme", namespace="preferences"))

# Delete all user memory
client.delete_memory(DeleteMemoryRequest(delete_all=True))

The client implements the context-manager protocol for deterministic cleanup:

with TinyHumanMemoryClient(TinyHumanConfig(token="your-api-key")) as client:
    result = client.read_memory()

Async usage

Use AsyncTinyHumanMemoryClient inside async code to avoid blocking the event loop (e.g. FastAPI, LangGraph async pipelines):

import asyncio
from tinyhumansai import AsyncTinyHumanMemoryClient, TinyHumanConfig, ReadMemoryRequest

async def main():
    async with AsyncTinyHumanMemoryClient(TinyHumanConfig(token="your-api-key")) as client:
        result = await client.read_memory()
        print(result.items)

asyncio.run(main())

API reference

TinyHumanMemoryClient(config) / AsyncTinyHumanMemoryClient(config)

Param Type Required Description
config.token str JWT or API key
config.base_url str Override API URL. If not set, uses ALPHAHUMAN_BASE_URL from env (e.g. .env) or default https://staging-api.alphahuman.xyz

client.ingest_memory(request)

Upserts memory items. Items are deduplicated by (namespace, key).

Returns IngestMemoryResponse(ingested, updated, errors).

client.read_memory(request?)

Read memory items, optionally filtered by key, keys, or namespace.

Returns ReadMemoryResponse(items, count).

client.delete_memory(request)

Delete memory by key, keys, or delete_all=True, optionally scoped by namespace.

Returns DeleteMemoryResponse(deleted).

Error handling

from tinyhumansai import TinyHumanError

try:
    client.read_memory()
except TinyHumanError as e:
    print(e.status, str(e))

TinyHumanError carries .status (HTTP status code) and .body (parsed response or raw text for non-JSON responses such as gateway errors).

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

tinyhumansai-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

tinyhumansai-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file tinyhumansai-0.1.0.tar.gz.

File metadata

  • Download URL: tinyhumansai-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for tinyhumansai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 694ea5be0951ef4e299d64cf941371cf0f857607935a20514f54c2282ad27c3a
MD5 ae0a9a1ac5faaf1eb8c0b4ab0dc9f192
BLAKE2b-256 6491b012ed811bd8cfdfb27d41d7778115dc43d3986448223e01780c5d9d0b44

See more details on using hashes here.

File details

Details for the file tinyhumansai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tinyhumansai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be82d04c74105fbe069984e593b21b071ae34ce9088110378dae2b2ddd75ad72
MD5 04691c69c760c8e00d347570f2ca624f
BLAKE2b-256 b53f2dbbe0184f9cb10a5ff31f99565f02183ca3c7531b26a33ecd2a28095f2d

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