Python SDK for the Kraken Agent API
Project description
kraken-agent
Python SDK for Kraken Agent — an open-source AI assistant that remembers you.
What is Kraken?
Kraken is a self-hosted AI assistant that builds a knowledge graph of everything you tell it. Unlike stateless LLM wrappers, Kraken actually remembers — your projects, preferences, workflows, and goals — across every platform you connect (Discord, Telegram, CLI, or any HTTP client).
This package is the official Python SDK. It gives you a type-safe, batteries-included client for chat, memory, sessions, skills, schedules, and identity management.
Why use this SDK?
- Persistent memory via GraphRAG — query a Neo4j knowledge graph with 5 search modes (local, global, drift, auto, basic)
- Session routing — stable
session_key-based conversations the server owns, not your client - Streaming — real-time token streaming with a simple
for chunk in ...loop - Self-improving skills — the agent learns procedures from complex tasks and reuses them
- Scheduled automation — create recurring task runners and inspect upcoming jobs from Python
- Identity system — editable personality (
SOUL.md) and an auto-maintained model of you - Fully typed — Pydantic models for every request and response, IDE autocompletion everywhere
- Async-ready — optional HTTP/2 support via
pip install kraken-agent[async]
Install
pip install kraken-agent
Requirements: Python 3.10+ and a running Kraken Agent server (docker-compose up).
Quick Start
from kraken import KrakenClient
client = KrakenClient(
api_url="http://localhost:8080",
api_key="sk-kraken-...",
model="gpt-5.4",
)
# Simple chat
response = client.chat("Hello, what can you do?")
print(response.content)
Streaming
for chunk in client.chat("Explain GraphRAG in simple terms", stream=True):
print(chunk, end="")
Session Routing
Sessions are server-owned. Use a stable key and the agent remembers context across calls — no local state needed.
client.chat("My name is Alice", session_key="discord-12345", session_name="Discord DM")
r = client.chat("What's my name?", session_key="discord-12345")
print(r.content) # "Alice"
Context Manager
with KrakenClient("http://localhost:8080") as client:
response = client.chat("Hello!")
print(response.content)
# Connection closed automatically
Async Client
The package claimed async readiness, but had no async SDK surface. This adds a real async client and async sub-clients.
import asyncio
from kraken import AsyncKrakenClient
async def main() -> None:
async with AsyncKrakenClient(
api_url="http://localhost:8080",
api_key="sk-kraken-...",
model="gpt-5.4",
) as client:
response = await client.chat("Hello, async world!")
print(response.content)
async for chunk in client.chat_stream("Stream a short explanation of GraphRAG"):
print(chunk, end="")
asyncio.run(main())
Memory (GraphRAG)
Kraken builds a knowledge graph from every conversation. Entities, relationships, and communities are extracted automatically — and you can query or modify them directly.
# Query the knowledge graph
results = client.memory.query("What do you know about my projects?")
for entity in results.entities:
print(f"{entity.type}: {entity.name}")
Multi-mode search
| Mode | Best for | How it works |
|---|---|---|
auto |
General questions | Analyzes intent, routes to best strategy |
local |
Specific entity questions | Fans out from entity to neighbors |
global |
Overview / holistic questions | Maps query over community summaries |
drift |
Entity + broader context | Local search enriched with community context |
basic |
Simple factual recall | Vector similarity over messages |
results = client.memory.query(
"What patterns do you see in my work?",
mode="global",
)
Modify the graph
client.memory.add_entity("Kraken", "project", properties={"status": "active"})
client.memory.add_relationship("user", "kraken-id", "works_on")
# Visualize a neighborhood
graph = client.memory.graph(center="kraken-id", depth=3)
print(f"{len(graph.nodes)} nodes, {len(graph.edges)} edges")
Sessions
# List all sessions
for s in client.sessions.list():
print(f"{s.session_key or s.id} — {s.message_count} messages")
# Retrieve full history by stable key
detail = client.sessions.get_by_key("discord-12345")
for msg in detail.messages:
print(f"[{msg.role}] {msg.content}")
Skills
Skills are learned procedures the agent creates automatically after complex tasks. You can also create them manually.
# Create a skill
client.skills.create(
"git-workflow",
content="When committing: use conventional commits...",
tags=["git", "workflow"],
)
# List skills by tag
for skill in client.skills.list(tag="git"):
print(f"{skill.name} (v{skill.version})")
Schedules
Kraken supports recurring task execution through the schedules API, and the Python SDK can manage those directly.
schedule = client.schedules.create(
"daily-recap",
"Summarize yesterday's session activity",
"0 8 * * *",
origin_session_id="ops-session",
max_runs=30,
)
for item in client.schedules.list():
print(item.name, item.next_run_at)
updated = client.schedules.update(schedule.id, enabled=False)
print(updated.enabled)
Identity
Kraken has two identity layers: an editable personality (SOUL.md) and an auto-maintained user model that tracks who you are.
# Read the agent's personality
soul = client.identity.get_soul()
print(soul.content)
# Customize it
client.identity.set_soul("You are Kraken, a concise and technical assistant...")
# See what the agent knows about you
user = client.identity.get_user_model()
print(user.content)
Architecture at a Glance
Your Python App
│
▼
┌──────────────────────────┐
│ Kraken API (Hono) │
│ REST + WebSocket │
│ OpenAI-compatible │
└────────┬─────────────────┘
┌────┼────────────┐
▼ ▼ ▼
PostgreSQL Neo4j Redis
(sessions, (knowledge (queues,
vectors, graph) cache)
skills)
The SDK talks to the Kraken API server, which coordinates PostgreSQL (sessions, embeddings, skills), Neo4j (knowledge graph), and Redis (job queues). A background worker handles entity extraction, community detection, user model updates, skill reflection, and scheduled task execution.
Full docs: kraken-agent.com
License
MIT
Project details
Release history Release notifications | RSS feed
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 kraken_agent-0.2.0.tar.gz.
File metadata
- Download URL: kraken_agent-0.2.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e13bcb9af183d1e9cc720293e47d44217acbb39e61e1f1b125ff42e7bd1f2d99
|
|
| MD5 |
a70dae4975d483bfb0e94b6220a66a1b
|
|
| BLAKE2b-256 |
1ede3324e7e5a900a47c74c8c7e713aa9fa364f1e6d78238cf186d4083d2a71c
|
Provenance
The following attestation bundles were made for kraken_agent-0.2.0.tar.gz:
Publisher:
publish-sdk.yml on datastudy-nl/kraken-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kraken_agent-0.2.0.tar.gz -
Subject digest:
e13bcb9af183d1e9cc720293e47d44217acbb39e61e1f1b125ff42e7bd1f2d99 - Sigstore transparency entry: 1200965353
- Sigstore integration time:
-
Permalink:
datastudy-nl/kraken-agent@a71d59140348434f41c3299f09077b95c0f822af -
Branch / Tag:
refs/heads/main - Owner: https://github.com/datastudy-nl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@a71d59140348434f41c3299f09077b95c0f822af -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file kraken_agent-0.2.0-py3-none-any.whl.
File metadata
- Download URL: kraken_agent-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16ed9a9fd406b9a8fc5301e4876542de761899f622b6ac88b19b9ce434ddb404
|
|
| MD5 |
a44e2d503d367544902bced7c61636f7
|
|
| BLAKE2b-256 |
0b126c59c7b232bf067974ce9986bb4a743dddd53977513b6510de63161e02dc
|
Provenance
The following attestation bundles were made for kraken_agent-0.2.0-py3-none-any.whl:
Publisher:
publish-sdk.yml on datastudy-nl/kraken-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kraken_agent-0.2.0-py3-none-any.whl -
Subject digest:
16ed9a9fd406b9a8fc5301e4876542de761899f622b6ac88b19b9ce434ddb404 - Sigstore transparency entry: 1200965405
- Sigstore integration time:
-
Permalink:
datastudy-nl/kraken-agent@a71d59140348434f41c3299f09077b95c0f822af -
Branch / Tag:
refs/heads/main - Owner: https://github.com/datastudy-nl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@a71d59140348434f41c3299f09077b95c0f822af -
Trigger Event:
workflow_dispatch
-
Statement type: