Skip to main content

Python client for Iranti memory infrastructure

Project description

Iranti Python Client

Python client for the Iranti REST API.

Installation

pip install iranti

For local development from this repository:

cd clients/python
pip install -e .

Setup

Start the Iranti API server first:

# In your Iranti directory
npm run api

Usage

from iranti import IrantiClient

client = IrantiClient(
    base_url="http://localhost:3001",
    api_key="your_key_here"
)

# Or use environment variables
# IRANTI_URL=http://localhost:3001
# IRANTI_API_KEY=your_key_here
client = IrantiClient()

# Check server is running
print(client.health())

# Write a fact
result = client.write(
    entity="researcher/jane_smith",
    key="affiliation",
    value={"institution": "MIT"},
    summary="Affiliated with MIT",
    confidence=85,
    source="OpenAlex",
    agent="my_agent"
)
print(result.action)  # created / updated / rejected / escalated

# Ingest raw text
result = client.ingest(
    entity="researcher/jane_smith",
    content="Dr. Jane Smith has 24 publications and is at MIT CSAIL.",
    source="OpenAlex",
    confidence=80,
    agent="my_agent"
)
print(f"Written: {result.written}, Rejected: {result.rejected}")

# Get working memory before a task
brief = client.handshake(
    agent="my_agent",
    task="Research publication history",
    recent_messages=["Starting research..."]
)
print(brief.inferred_task_type)

# Per-turn memory decision (inject only when needed)
turn = client.attend(
    agent_id="my_agent",
    latest_message="What is my favorite snack?",
    current_context="User: What is my favorite snack?\nAssistant:",
    entity_hints=["user/main"]
)
print(turn["shouldInject"], turn["reason"])

# Query facts
result = client.query("researcher/jane_smith", "affiliation")
if result.found:
    print(result.value)

Error Handling

from iranti import IrantiClient, IrantiAuthError, IrantiValidationError, IrantiError

try:
    result = client.write(...)
except IrantiAuthError:
    print("Invalid API key")
except IrantiValidationError as e:
    print(f"Bad input: {e}")
except IrantiError as e:
    print(f"API error: {e}")

Environment Variables

Variable Description
IRANTI_URL API server URL (default: http://localhost:3001)
IRANTI_API_KEY API token (keyId.secret) or legacy shared server key

License

AGPL-3.0-or-later.

Project details


Release history Release notifications | RSS feed

This version

0.1.0

Download files

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

Source Distribution

iranti-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.

iranti-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iranti-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for iranti-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63316d3aeea4dafba869fae1f7e9c6398f82590634d778965016a785ba7de108
MD5 8dc242b3613cdff636c11457d6f8a0a9
BLAKE2b-256 684b53b058abb81cf792617fa7a87aa4e4e6941378c7d1d5c1d15beaaac679e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iranti-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for iranti-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6ced8ef8bab5f0851cf53826006be79f75147ce32f62fcc3665bcc7d9cfb2c8
MD5 c96d84e9fd7e12542c608543f34c7389
BLAKE2b-256 dfdae350958fd7def00357ae6ee940728d7d50c4fa6d47eec48c76639762631f

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