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 TINYHUMAN_BASE_URL from env (e.g. .env) or default https://api.tinyhumans.ai

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.4.0.tar.gz (7.6 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.4.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tinyhumansai-0.4.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tinyhumansai-0.4.0.tar.gz
Algorithm Hash digest
SHA256 07b66a14abb7d272aad1a93ce74bea8ac2dc96de35f4efb259860e7e46ec9b39
MD5 378703a6cb2f284cc9888aac8433d20a
BLAKE2b-256 4ca30d8906bfc30f0e535e44865b04bc5cf37d9b66e2b71abb2fcbcb75ddd766

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tinyhumansai-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tinyhumansai-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6fa296a812a8dd5107b1d59a5714dc7e61675771396ff1d18b22ebee4acb19e
MD5 ca64bbe6e76adb8b9ceb406d8f1b0ca9
BLAKE2b-256 bdd02ca11c8d9dde2207d31eb8a473a0187b576c97db08e347247645b8557dd7

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