Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

kortexio-contextmemory

What is ContextMemory?

ContextMemory is an agentic memory gateway. Your coding agent or chat app talks to a normal OpenAI-compatible URL (POST /v1/chat/completions), and the gateway keeps markdown memory you can open like a wiki — plus tools, sandbox, MCP, and human-in-the-loop when you need action.

It is not classic RAG (no “inject N chunks into the prompt”). Memory is retrieved on demand inside the agent loop (wiki_search and related tools). It is also not a vector black box: facts live as files you can read, edit, and version.

Use it when:

  • Cursor / Claude / your agent forgets staging names, decisions, and project context between sessions
  • You want auditable memory (markdown) instead of opaque embeddings
  • You want one /v1 URL for chat + memory + tools, self-hosted or on Kortexio Cloud

What is this package?

A thin header helper for Python — not a full SDK.

ContextMemory needs a few HTTP headers on every call (Authorization, and usually X-App-Id / X-User-Id / X-Session-Id). This package builds those headers (and kwargs for the official OpenAI client) so you do not hand-roll them.

Beta (0.0.1b*). APIs may still change.
PyPI name: kortexio-contextmemory · Import name: contextmemory

Install

pip install kortexio-contextmemory openai

Quick start (OpenAI Python client)

Point the client at your gateway /v1 base URL (self-host or Cloud):

import os
from openai import OpenAI
from contextmemory import openai_client_kwargs

client = OpenAI(
    **openai_client_kwargs(
        base_url=os.environ.get("CONTEXTMEMORY_BASE_URL", "http://localhost:5100/v1"),
        api_key=os.environ["CONTEXTMEMORY_API_KEY"],  # cm_live_… or self-host key
        app_id="demo-dev",
        user_id="user-42",
        session_id="sess-abc",  # same session → same wiki memory
    )
)

completion = client.chat.completions.create(
    model="qwen3.5:9b",
    messages=[{"role": "user", "content": "Remember that my staging DB is postgres-staging."}],
)
print(completion.choices[0].message.content)

Reuse the same session_id across turns so the gateway attaches the right session wiki.

Headers only (httpx, requests)

import httpx
from contextmemory import headers

h = headers(
    api_key="cm_live_...",
    app_id="demo-dev",
    user_id="user-42",
    session_id="sess-abc",
)

r = httpx.post(
    "http://localhost:5100/v1/chat/completions",
    headers=h,
    json={
        "model": "qwen3.5:9b",
        "messages": [{"role": "user", "content": "Hello"}],
    },
)
print(r.json())

API

Function Purpose
openai_client_kwargs(...) dict for OpenAI(**kwargs) / AsyncOpenAI(**kwargs)
headers(...) Plain dict[str, str] for any HTTP client

Required: api_key (and base_url for the OpenAI helper)
Optional: app_id, user_id, session_id, extra (merged into headers)

Cloud vs self-host

Base URL API key
Self-host http://localhost:5100/v1 (or your host) App key from Admin / config
Kortexio Cloud Cloud API /v1 cmk_live_…

More: GitHub · why we are not RAG · MCP aha demo

License

AGPL-3.0-or-later — same as the ContextMemory core.

Release files for kortexio-contextmemory 0.0.1b2

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

Source distribution (sdist)

Source distribution for kortexio-contextmemory 0.0.1b2
File Size Uploaded
kortexio_contextmemory-0.0.1b2.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kortexio-contextmemory 0.0.1b2
File Interpreter ABI Platform
kortexio_contextmemory-0.0.1b2-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / kortexio_contextmemory-0.0.1b2.tar.gz

Download URL kortexio_contextmemory-0.0.1b2.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dd374952f678651d303952338183b194831261363b9eb56d472735bd576d25e7
BLAKE2b-256 checksum
How to use checksums
e048021b601cd921f7c3dfdf1b43b55db2a1e94391917017e1e09170648d6c25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / kortexio_contextmemory-0.0.1b2-py3-none-any.whl

Download URL kortexio_contextmemory-0.0.1b2-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3abd433258770080599ae0c0ce412755a41d5771df1082add02c346b5f6dbd14
BLAKE2b-256 checksum
How to use checksums
96bf6e0bf4c60b4eff8f99a27c2f4f4ab265e9f4424fb7e6f47b290c6a5f63f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13
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