Skip to main content

korely-memory

The Python SDK for Korely Agents — memory for AI agents, with bi-temporal typed facts and contradiction checking built in.

A typed, zero-dependency client over the Korely REST API. Every method maps 1:1 onto an endpoint, so anything you can do with curl you can do here, and the JSON shapes in the API reference are the attribute shapes you get back. All the intelligence — embeddings, entity and typed-fact extraction, contradiction checking, bi-temporal validity — runs server-side, so your install stays small and your process stays light.

Install

pip install korely-memory

Python 3.9 or later.

Quickstart

from korely_memory import Korely

korely = Korely(api_key="kor_live_...", region="eu")
# or read the key from the environment (KORELY_API_KEY)
korely = Korely(region="eu")

# Remember — the write path extracts facts and resolves contradictions
korely.add("User prefers TypeScript with strict mode", agent_id="coding-assistant")
korely.add("Actually I switched to Rust", agent_id="coding-assistant")

# Recall — superseded facts drop out automatically
for hit in korely.search("user's preferred language", limit=5):
    print(hit.id, hit.score, hit.snippet)

# One-call, prompt-ready context for your LLM
ctx = korely.get_context(query="plan the project", user_id="dana", token_budget=800)
messages = [{"role": "system", "content": f"You are helpful.\n\n{ctx.context}"}]

Methods

Every method wraps exactly one REST endpoint.

Method Endpoint
add(content, *, agent_id=, user_id=, run_id=, metadata=, timestamp=) POST /v1/memories
search(query, *, user_id=, agent_id=, limit=) POST /v1/memories/search
get_all(*, user_id=, agent_id=, limit=, offset=) GET /v1/memories
get(memory_id) GET /v1/memories/:id
update(memory_id, *, content, expected_updated_at=) PATCH /v1/memories/:id
delete(memory_id) DELETE /v1/memories/:id
delete_all(*, user_id) DELETE /v1/users/:user_id/memories
list_agents(*, limit=, offset=) GET /v1/agents
delete_agent(agent_id) DELETE /v1/agents/:agent_id
get_facts(*, subject=, entity=, predicate=, predicate_family=, include_invalidated=, as_of=, …) GET /v1/facts
get_context(*, query, user_id=, agent_id=, token_budget=) GET /v1/context
batch(memories) POST /v1/batch
batch_status(job_id) GET /v1/batch/:id

add(..., timestamp="2026-01-15") backfills the past: facts extracted inherit the timestamp as their valid_from, so as_of point-in-time queries reflect when things were true, not when they were ingested. list_agents() / delete_agent(agent_id) manage your agent namespaces — call list_agents() after an agent_cap_exceeded error to reuse an existing agent_id, or delete_agent() to purge a throwaway one and free its cap slot.

Bi-temporal facts

The differentiator: typed (subject, predicate, object) facts with validity over time. Ask what was true on any date.

# Current state
facts = korely.get_facts(entity="Northwind Hosting")
print(facts[0].object)      # 50 euro per month
print(facts[0].invalid_at)  # None — active

# Point-in-time: what did we believe on June 1?
facts = korely.get_facts(entity="Northwind Hosting", as_of="2026-06-01")
print(facts[0].object)      # 40 euro per month

Scoping

Three identifiers, three levels of scope — the same everywhere (SDK, REST, MCP):

  • agent_id — your application or agent (one namespace per product surface)
  • user_id — your end user (free-form string; unlimited on every tier)
  • run_id — one session or run (sub-scope inside a user)
korely.add("Asked to be contacted on Slack", agent_id="support-bot", user_id="customer-4812")
results = korely.search("contact preference", user_id="customer-4812")

Always pass user_id on reads in multi-tenant products. Filters are additive (AND); a search without user_id spans every end user in the namespace.

Error handling

The SDK raises typed exceptions that map onto the REST error codes; all subclass KorelyError.

import time
from korely_memory import Korely, AuthenticationError, NotFoundError, QuotaExceededError

korely = Korely(api_key="kor_live_...")
try:
    memory = korely.get("mem_8f2c1a")
except AuthenticationError:
    raise                       # 401 — check or rotate the key
except NotFoundError:
    memory = None               # 404 — forgotten or never existed
except QuotaExceededError as err:
    time.sleep(err.retry_after) # 429 — back off and retry
    memory = korely.get("mem_8f2c1a")
Exception Status
AuthenticationError 401
NamespaceForbiddenError 403
NotFoundError 404
StaleWriteError 409
QuotaExceededError (.retry_after) 429
APIError other

Links

MIT licensed.

Metadata

Release files for korely-memory 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for korely-memory 0.1.4
File Size Uploaded
korely_memory-0.1.4.tar.gz 20.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for korely-memory 0.1.4
File Interpreter ABI Platform
korely_memory-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 40.9 kB

Release files / korely_memory-0.1.4.tar.gz

Download URL korely_memory-0.1.4.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
966ddd7828dd1da81fcc8ff8955e7c043221006527d37a31a7e65af855a6e701
BLAKE2b-256 checksum
How to use checksums
655c9340216189ba50c544141cf601e5bfd75a97863d3e5f73195bd279663ae6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / korely_memory-0.1.4-py3-none-any.whl

Download URL korely_memory-0.1.4-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3450d59e1ba1bc5abb8fb429fd5cee1edf8b218ff6b0ada4707adb3ca1244de8
BLAKE2b-256 checksum
How to use checksums
33f6b3f07a4a5ea054b538e18a1ff5402adefb5038bad2c1899a1af1b2eb5689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

2 release files

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page