Skip to main content

Python SDK for Kognite — long-term memory for AI agents (hybrid semantic search, memory formation, knowledge graph)

Project description

kognite

Python SDK for Kognite — long-term memory for AI agents. Hybrid semantic + full-text search, LLM memory formation, and a knowledge graph, behind one API key. Zero dependencies (stdlib only), Python 3.9+.

pip install kognite

Quickstart

from kognite import Kognite

k = Kognite(api_key="kgn_...")

# Store a memory
k.memories.add("User prefers dark mode", kind="preference")

# Hybrid search (semantic + full-text, RRF-fused)
hits = k.memories.search("ui preferences", limit=5)["results"]

# Highest precision (cross-encoder rerank — slower):
k.memories.search("ui preferences", rerank=True)

Memory formation (the good stuff)

ingest runs the pipeline behind Kognite's published LoCoMo results: it stores raw messages as episodes and extracts atomic facts — pronouns resolved to names, relative dates converted to absolute ones. Prefer it over add for any multi-message context:

k.memories.ingest([
    {"speaker": "user", "timestamp": "2026-07-15", "content": "I moved to Berlin last month."},
    {"speaker": "assistant", "content": "Noted — how are you finding it?"},
])
# → {"raw": 2, "extracted": 1, "stored": 3}

Context assembly

A token-budgeted bundle of relevant memories, ready to drop into a prompt:

ctx = k.context.assemble("user's living situation", token_budget=2000)

Everything else

k.memories.get(memory_id)
k.memories.forget(memory_id)      # soft-delete (+ graph cascade)
k.memories.list(limit=50)         # newest-first paging
k.graph.query("Berlin")           # knowledge-graph search
k.health()

Errors raise KogniteError with .status (HTTP) and .code (validation_failed, quota_exceeded, not_found, …). Retries with exponential backoff on 429/5xx/network errors are built in.

The tenant scope is derived server-side from your API key — the SDK has no scope parameter and cannot reach another tenant. Get a key in the dashboard, and see the live, judge-audited benchmarks.

Self-hosted? Pass base_url= to the constructor.

Development

smoke_live.py is a full live-API exercise of every method (safe: runs in the key's own scope and forgets everything it creates):

KOGNITE_API_KEY=kgn_... python smoke_live.py

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

kognite-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

kognite-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kognite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9268f980b85acc716e3bb28ba3beb4dfcfa58d8966b647095a75ed7543dde83a
MD5 9dc0916a1b0e42e3b2bc851044f59b26
BLAKE2b-256 5abb8df19cb5226953f3e71e08800cdc112419b12f854bc45ef8df4c27e172d3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kognite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 587488dd3a8759ed0b31944986eee0f142679e280b12e418fd53a4ae737fb552
MD5 cccb1b5d9c56de001f86faa1cce0887d
BLAKE2b-256 9672d397403f4b06e7b132a9f63bd0e206996339365e59ec40d9464b6d26dbec

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