Hippocortex SDK Overview

The Hippocortex SDKs provide client libraries for integrating agent memory into any AI application. Available in TypeScript and Python with framework-specific adapters.

All SDK methods access the full pipeline: capture, synthesize (semantic search, graph retrieval, collective brain, behavioral context), learn, vault, and collective brain.


Integration Methods

The SDK offers three integration paths, from zero-effort to full manual control:

MethodEffortDescriptionReliabilityBest For
Gateway0 linesChange base URL, no SDK needed~99%Most users, any language
import auto1 lineMonkey-patching of OpenAI/Anthropic SDKs~95%Quick start, prototyping
wrap(client)1 lineTransparent client wrapping with type safety~95%Production apps, explicit control
new Hippocortex()ManualDirect capture/learn/synthesize/vault calls~95%Custom agent loops, non-OpenAI LLMs

Gateway (Recommended)

No SDK installation required. See the Gateway guide.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.hippocortex.dev/v1",
    api_key="hx_live_...",
    default_headers={"X-LLM-API-Key": "sk-..."},
)

Auto-Instrumentation

// TypeScript: one import, zero config
import '@hippocortex/sdk/auto'
# Python: one import, zero config
import hippocortex.auto

Every OpenAI and Anthropic SDK call automatically gets memory context injection and conversation capture.

wrap()

import { wrap } from '@hippocortex/sdk'
import OpenAI from 'openai'

const openai = wrap(new OpenAI())
// Use exactly as before. Memory is transparent.
from hippocortex import wrap
from openai import OpenAI

client = wrap(OpenAI())
# Use exactly as before. Memory is transparent.

Manual Client

The manual client exposes the full API:

OperationWhat It DoesWhen to Call It
capture()Record an agent interaction eventAfter every significant agent action
captureBatch()Record multiple events at onceBatch processing
learn()Trigger memory compilationPeriodically or after a batch of events
synthesize()Retrieve relevant context for a queryBefore the agent needs to make a decision
vaultQuery()Search vault for secrets (metadata only)When agent needs to find stored secrets
vaultReveal()Retrieve decrypted secret valueWhen agent needs to use a secret
listArtifacts()List compiled knowledge artifactsInspection and debugging
getMetrics()Get usage and performance metricsMonitoring and billing

Zero-Config

All integration methods support automatic configuration resolution:

  1. Explicit arguments passed to wrap(), new Hippocortex(), etc.
  2. Environment variables: HIPPOCORTEX_API_KEY, HIPPOCORTEX_BASE_URL
  3. Config file: .hippocortex.json (searched from cwd upward to filesystem root)

.hippocortex.json

{
  "apiKey": "hx_live_your_key_here",
  "baseUrl": "https://api.hippocortex.dev/v1"
}

Language Support

LanguagePackageVersionInstall CommandMin Version
TypeScript@hippocortex/sdk1.2.1npm install @hippocortex/sdk@1.2.1Node 18+
Pythonhippocortex1.2.1pip install hippocortex==1.2.1Python 3.9+

Both SDKs provide identical functionality and API parity.

Package Exports (TypeScript)

ExportDescription
@hippocortex/sdkCore client (Hippocortex, wrap, types)
@hippocortex/sdk/autoAuto-instrumentation (monkey-patching)
@hippocortex/sdk/registerRegistration utilities
@hippocortex/sdk/adaptersFramework adapters

Framework Adapters

Adapters wrap the core SDK to integrate with popular AI agent frameworks.

AdapterFrameworkLanguageAuto-captures
OpenAI AgentsOpenAI AgentsPythonMessages, tool calls, tool results
LangGraphLangGraphPythonNode events, tool calls, state
CrewAICrewAIPythonTask events, agent actions
AutoGenAutoGenPythonMessages, function calls
OpenClawOpenClawBothAll event types

Authentication

All SDK operations require an API key:

const hx = new Hippocortex({
  apiKey: 'hx_live_your_key_here'
});

API Key Formats

PrefixEnvironmentPurpose
hx_live_ProductionProduction data operations
hx_test_TestTest environment, no billing

Key Permissions

PermissionOperations
readsynthesize, listArtifacts, getArtifact, getMetrics, vaultQuery
writecapture, captureBatch, learn, vaultReveal

Error Handling

Both SDKs throw typed errors with structured error information:

TypeScript

import { HippocortexError } from '@hippocortex/sdk';

try {
  await hx.capture(event);
} catch (error) {
  if (error instanceof HippocortexError) {
    console.error(`Code: ${error.code}, Status: ${error.statusCode}`);
  }
}

Python

from hippocortex import HippocortexError

try:
    await hx.capture(event)
except HippocortexError as e:
    print(f"Code: {e.code}, Status: {e.status_code}")

Error Codes

CodeHTTP StatusDescription
validation_error400Invalid request body
unauthorized401Missing or invalid API key
forbidden403Insufficient permissions
not_found404Resource does not exist
rate_limited429Too many requests
internal_error500Server-side error
duplicate_event409Event already captured (idempotency)

Rate Limits

Rate limits are enforced per API key based on the account plan:

PlanRequests/MinuteBurst Allowance
Free6010
Pro600100
Unlimited3,000500
TeamCustomCustom

Next Steps