khwan (Python client)
The Khwan hosted client — a thin HTTP wrapper with no engine code. Khwan is a memory layer (memory + constitutional identity + coherence + learning) that runs on our server; you bring your own model.
Khwan never generates text. It is a pure AI-memory layer — you always call
your own model. The only loop is prepare → your model → record.
pip install khwan
The memory loop — you call your own model
from khwan import Khwan
kw = Khwan(api_key="kwk_live_xxx", user_id="alice")
turn = kw.prepare("remember I prefer short answers in Thai") # Khwan builds context, no LLM
answer = your_model(turn.messages) # YOUR model + key
kw.record(turn, answer) # Khwan persists + learns
turn.messages is a standard [{role, content}] array with Khwan's value baked
into the system prompt (learned lessons + constitution + retrieved memory + coherence).
your_model is just your normal LLM call:
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...") # your key, Khwan never sees it
def your_model(messages):
system = next((m["content"] for m in messages if m["role"] == "system"), "")
chat = [m for m in messages if m["role"] != "system"]
r = client.messages.create(model="claude-sonnet-4-6", max_tokens=1024,
system=system, messages=chat)
return r.content[0].text
Isolated cores
One account can hold many cores — fully separate brains, each with its own
memory, identity, and learning. Point a client at one with core:
test = Khwan(api_key="kwk_live_xxx", user_id="alice", core="test")
client1 = Khwan(api_key="kwk_live_xxx", user_id="alice", core="client1")
kw.cores() # list the account's cores (the default core is included)
test and client1 never share memory. Omit core for the account's default brain.
On-prem
Same code, point at your instance:
kw = Khwan(api_key="kwk_...", user_id="alice",
base_url="https://khwan.internal.acme.com")
memory=/embedder= are server-managed and rejected here — they exist only in the
on-prem engine, shipped under license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file khwan-0.1.0.tar.gz.
File metadata
- Download URL: khwan-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8cd674d43b63ed49c29e64d0677c0d67dbe17416d31364382ae35d3ee927c48
|
|
| MD5 |
ca1879b7132ae8d00de70b00ba169868
|
|
| BLAKE2b-256 |
53516ba56518f8941fbdeeea17f8fe9bf6fc8f87164ec272bd2f55a3ab67816f
|
File details
Details for the file khwan-0.1.0-py3-none-any.whl.
File metadata
- Download URL: khwan-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7fd809275d4f029acb6358d741801002cf6dcdcd0f4ca9580659290ce60a4b0
|
|
| MD5 |
7e8b5384ec1db57fe890c3d4a1fb5e50
|
|
| BLAKE2b-256 |
a7e8e81496e21601073aa3be50c9130efe541c456304a474fbf563a187b75f21
|