SDKs & Libraries
Official client libraries for Python and TypeScript with type safety, explicit typed errors, and async support.
Current versions
The current published releases are Python 2.12.0 on PyPI and TypeScript 2.10.1 on npm. Pin your tested version instead of relying on a mutable latest tag. Use the package pages for installation and the separately labeled GitHub links for source.
pip install 'hebbrix==2.12.0'
npm install hebbrix@2.10.1New HTTP options may not yet have typed SDK helpers; use the documented REST contract. Check live release metadata for exact compatible artifacts. Source-only helpers are not automatically published packages.
SDK overview
Features
- Type Safety: Full TypeScript types and Python type hints
- Explicit Errors: Typed authentication, rate-limit, validation, and API errors
- Async Support: Native async/await for non-blocking ops
Quick Start
import asyncio
from hebbrix import MemoryClient
async def main():
# The Python SDK is async-first. Pair it with `async with` so the
# underlying HTTP client is closed cleanly.
async with MemoryClient(api_key="mem_sk_...") as client:
# Create a collection
collection = await client.collections.create(name="My Agent")
# Store a memory verbatim and return once it is searchable
memory = await client.memories.create(
collection_id=collection["id"],
content="User prefers dark mode",
importance=0.7,
infer=False, # the SDK default; POST /v1/memories over REST extracts by default
wait_for_index=True,
)
# Adaptive hybrid search
results = await client.search(
query="user preferences",
collection_id=collection["id"],
limit=5,
)
asyncio.run(main())import { MemoryClient } from 'hebbrix';
const client = new MemoryClient({ apiKey: 'mem_sk_...' });
// Create a collection
const collection = await client.collections.create({
name: 'My Agent',
description: 'Personal memory for my chatbot',
});
// Store a memory verbatim and return once it is searchable
const memory = await client.memories.create({
collection_id: collection.id,
content: 'User prefers dark mode',
importance: 0.7,
infer: false, // the SDK default; POST /v1/memories over REST extracts by default
wait_for_index: true,
});
// Adaptive hybrid search
const results = await client.search({
query: 'user preferences',
collection_id: collection.id,
limit: 5,
});memories.create() and POST /v1/memories have different defaults. The SDKs store the content verbatim as one memory unless you pass infer=True (TypeScript infer: true); the REST endpoint called without infer extracts facts with the server's language model. Pass infer and wait_for_index explicitly, as above, so a call reads the same through the SDK and over HTTP. Use infer=True (or /v1/memories/process) for conversations, and infer=False for a fact you already have in final form.
Decide before you call your model
should_answer(response) / shouldAnswer(response) read a search_with_proof() / searchWithProof() or reason() response and return the rows you may pass to your model (memories), the other rows (context, never to answer from), and an action when you may not answer: say_unknown, abstain, verify_authorization (the question asks for a permission the store cannot confirm: state the rule and check the role in your own system), ask_user, retry, say_no_longer_current or use_as_context (a Reason suggestion or plan, or an unverified search whose rows include an evidence_role: "applicable_rule" rule: its memories shape what your model does, never an established fact or a permission). Pass require_ready=True / requireReady: true for a high-stakes flow: the answer is then also held, with action retry, until the index is ready and answer_risk is none. history=True lets earlier versions count for a question about the past, and never overrides unverified, no_relevant_memory, indexing, conflicting or no_match; a response marked answerable that also sets an abstention flag is declined in every mode. answer_context(response, decision) / answerContext(response, decision) renders the end user's standing profile (with include_profile) beside the usable rows, each with its date, memory type, subject and support, and says so when the profile is still being updated or could not be read. Both are in the current releases above; when to answer has the full table.
from hebbrix import MemoryClient, answer_context, should_answer
async def reply(client: MemoryClient, question: str, user_id: str) -> str:
response = await client.search_with_proof(
question, user_id=user_id, include_profile=True
)
decision = should_answer(response)
if not decision:
# decision.action: say_unknown, abstain, verify_authorization,
# ask_user, retry or say_no_longer_current. The model is never called.
return my_reply_for(decision.action)
# The standing profile and the usable rows, each with its date,
# memory type, subject and support.
return await my_llm(question, context=answer_context(response, decision))import { MemoryClient, answerContext, shouldAnswer } from 'hebbrix';
async function reply(client: MemoryClient, question: string, userId: string) {
const response = await client.searchWithProof({
query: question,
user_id: userId,
include_profile: true,
});
const decision = shouldAnswer(response);
if (!decision.answer) {
// decision.action: say_unknown, abstain, verify_authorization,
// ask_user, retry or say_no_longer_current. The model is never called.
return myReplyFor(decision.action);
}
// The standing profile and the usable rows, each with its date,
// memory type, subject and support.
return myLlm(question, answerContext(response, decision));
}Installation Options
# Using pip
pip install hebbrix
# Using poetry
poetry add hebbrix
# Using pipenv
pipenv install hebbrix# npm
npm install hebbrix
# yarn
yarn add hebbrix
# pnpm
pnpm add hebbrix
# bun
bun add hebbrixAsync usage and streaming
import asyncio
from hebbrix import MemoryClient
async def main():
async with MemoryClient(api_key="mem_sk_...") as client:
# Parallel requests: the client shares a single HTTP session
# so concurrent calls reuse the connection pool.
memory, results = await asyncio.gather(
client.memories.get("mem_abc"),
client.search(query="preferences", limit=10),
)
asyncio.run(main())import { MemoryClient } from 'hebbrix';
const client = new MemoryClient({ apiKey: 'mem_sk_...' });
// Run multiple calls in parallel: the client re-uses a single
// HTTP agent so concurrent requests share the connection pool.
const [memory, results] = await Promise.all([
client.memories.get('mem_abc'),
client.search({ query: 'preferences', limit: 10 }),
]);Error Handling
import asyncio
from hebbrix import MemoryClient
from hebbrix import (
HebbrixError, AuthenticationError,
RateLimitError, ValidationError,
)
async def main():
async with MemoryClient(api_key="mem_sk_...") as client:
try:
memory = await client.memories.create(
collection_id="YOUR_COLLECTION_ID",
content="Test",
infer=False,
wait_for_index=True,
)
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited; backend told us to slow down: {e}")
except ValidationError as e:
print(f"Request validation failed: {e}")
except HebbrixError as e:
print(f"Error: {e}")
asyncio.run(main())import {
MemoryClient, HebbrixError,
AuthenticationError, RateLimitError, ValidationError,
} from 'hebbrix';
const client = new MemoryClient({ apiKey: 'mem_sk_...' });
try {
await client.memories.create({
collection_id: 'YOUR_COLLECTION_ID',
content: 'Test',
infer: false,
wait_for_index: true,
});
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof RateLimitError) {
console.error('Rate limited; slow down and retry');
} else if (error instanceof ValidationError) {
console.error('Request validation failed:', error.message);
} else if (error instanceof HebbrixError) {
console.error('API error:', error.message);
}
}Configuration
from hebbrix import MemoryClient
# Constructor signature
client = MemoryClient(
api_key="mem_sk_...",
base_url="https://api.hebbrix.com", # default
timeout=120.0, # seconds
)import { MemoryClient } from 'hebbrix';
const client = new MemoryClient({
apiKey: 'mem_sk_...',
baseUrl: 'https://api.hebbrix.com', // default
timeout: 120000, // ms
});OpenAI Compatibility
Use Hebbrix as a drop-in replacement for OpenAI SDK:
from openai import OpenAI
# Drop-in replacement for OpenAI
client = OpenAI(
api_key="mem_sk_your_hebbrix_key",
base_url="https://api.hebbrix.com/v1"
)
response = client.chat.completions.create(
model="gpt-5-nano",
user="user-123", # OpenAI's end-user field: this user's memory
messages=[{"role": "user", "content": "Hello!"}]
)
# This user's memories are injected automatically
# (without user or collection_id: answered without memory)import OpenAI from 'openai';
// Drop-in replacement for OpenAI
const client = new OpenAI({
apiKey: 'mem_sk_your_hebbrix_key',
baseURL: 'https://api.hebbrix.com/v1'
});
const response = await client.chat.completions.create({
model: 'gpt-5-nano',
user: 'user-123', // OpenAI's end-user field: this user's memory
messages: [{ role: 'user', content: 'Hello!' }]
});
// This user's memories are injected automatically
// (without user or collection_id: answered without memory)Available Methods
| Field | Type | Description |
|---|---|---|
| client.auth | - | register, login, create_api_key, get_me |
| client.collections | - | create, list, get, update, delete |
| client.memories | - | create, list, list_page (cursor page + metadata), iter_all (async-iterate all pages), get, update, delete |
| client.search(...) | - | adaptive hybrid search (top-level method) |
| client.reason(...) | - | LLM-backed reasoning (top-level method) |
| should_answer(response), answer_context(response, decision) | - | answer policy: one action per outcome (verify_authorization included) and the model context with the standing profile; TypeScript shouldAnswer, answerContext |
| client.search_resource | - | search, similar, reason (lower-level) |
| client.rl | - | train_memory_manager, train_answer_agent, get_metrics, evaluate |
| client.temporal | - | temporal-knowledge-graph access |
| client.procedural | - | procedural (skills) memory |
| client.working_memory | - | short-term context buffer |
| client.consolidation | - | memory consolidation jobs |
| MemoryChat(api_key=...).send(...) | - | one-line chat integration (separate helper class) |